Skip to content

Commit

Permalink
Create archive during build and use new ansys action option to only c…
Browse files Browse the repository at this point in the history
…reate archive (#23)
  • Loading branch information
mariostieriansys authored Oct 31, 2024
1 parent aa8f055 commit a42888d
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ jobs:
with:
library-name: ${{ env.PACKAGE_NAME }}
python-version: ${{ env.MAIN_PYTHON_VERSION }}
- name: Remove Dummy Wheel
run: |
python post_build_cleanup.py
release:
name: Release
Expand All @@ -88,3 +93,4 @@ jobs:
uses: ansys/actions/release-github@v8
with:
library-name: ${{ env.PACKAGE_NAME }}
only-code: true
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ repos:
- id: numpydoc-validation
exclude: |
(?x)(
tests/ | __init__.py
tests/ | __init__.py | post_build_cleanup.py | setup.py
)
- repo: https://github.com/codespell-project/codespell
Expand Down
12 changes: 12 additions & 0 deletions post_build_cleanup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import glob
import os


def clean_dist():
for file in glob.glob("dist/*.whl"):
os.remove(file)
print(f"Removed {file}")


if __name__ == "__main__":
clean_dist()
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[build-system]
requires = ["setuptools >= 42.0.0", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "ansys-tools-omniverse"
version = "1.0.0.dev0"
Expand Down
56 changes: 56 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import os

from setuptools import find_packages, setup
from setuptools.command.bdist_wheel import bdist_wheel as _bdist_wheel
from setuptools.command.sdist import sdist as _sdist

description = "Ansys Tools Ominverse Extension"
HERE = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(HERE, "README.rst"), encoding="utf-8") as f:
long_description = f.read()


class CustomSdist(_sdist):
def make_distribution(self):
# Ensure the 'exts' folder is included in the tar archive
self.filelist.files = [
f
for f in self.filelist.files
if f.startswith("exts") or f in ["setup.py", "pyproject.toml", "README.rst"]
]
for root, dirs, files in os.walk("exts"):
for file in files:
self.filelist.files.append(os.path.join(root, file))
super().make_distribution()


class CustomBdistWheel(_bdist_wheel):
def run(self):
# Create a dummy wheel file to satisfy the build process
dist_dir = os.path.join(
self.dist_dir,
f"{self.distribution.get_name()}-{self.distribution.get_version()}-py3-none-any.whl",
)
with open(dist_dir, "w") as f:
f.write("")
print(f"Created dummy wheel file at {dist_dir}")
# Call the original run method to ensure any other necessary steps are completed
super().run()

# Remove the dummy wheel file
if os.path.exists(dist_dir):
os.remove(dist_dir)
print(f"Removed dummy wheel file at {dist_dir}")


setup(
name="ansys-tools-omniverse",
packages=find_packages(),
cmdclass={
"sdist": CustomSdist,
"bdist_wheel": CustomBdistWheel,
},
include_package_data=True,
long_description=long_description,
long_description_content_type="text/x-rst", # This is the key line
)

0 comments on commit a42888d

Please sign in to comment.