Skip to content

Commit

Permalink
Conformant wheel building and testing. (#31)
Browse files Browse the repository at this point in the history
* CI testing and limited ABI wheels.

* Bump osx deployment target.

* Change osx arch config.

* Fix runner version.

* Try fix arch.
  • Loading branch information
eliphatfs authored Oct 11, 2023
1 parent 9e626d4 commit f945f7b
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 18 deletions.
51 changes: 39 additions & 12 deletions .github/workflows/wheel.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,60 @@
name: Wheel
name: Wheel and Test

on: workflow_dispatch

jobs:
build:
runs-on: ${{ matrix.config.os }}
name: Build on ${{ matrix.config.os }}
name: Build ${{ matrix.config.os }}-${{ matrix.config.arch }}
strategy:
fail-fast: false
matrix:
config:
- { os: "ubuntu-20.04", build-dir: "build-linux" }
- { os: "windows-2019", build-dir: "build-windows" }
- { os: "macos-11", build-dir: "build-macos" }
- { os: "ubuntu-20.04", arch: "auto64" }
- { os: "windows-2019", arch: "auto64" }
- { os: "macos-11", arch: "auto64" }
- { os: "macos-11", arch: "universal2" }
steps:
- uses: actions/checkout@v2
with:
submodules: "true"
- name: Install Dependencies
run: |
python3 -m pip install wheel
- name: Wheel
run: |
python3 setup.py bdist_wheel
- name: Build Wheels
uses: pypa/[email protected]
env:
CIBW_ARCHS: ${{ matrix.config.arch }}
CIBW_BUILD: cp36-* cp38-macosx_universal2
MACOSX_DEPLOYMENT_TARGET: "10.14"
- name: List Build Results
run: |
ls dist
ls wheelhouse
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.config.os }}-build-wheel
path: ./dist/*.whl
name: wheels
path: ./wheelhouse/*.whl
run:
name: Test on ${{ matrix.os }} with python ${{ matrix.python-version }}
needs: [build]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, windows-2019, macos-11]
python-version: ['3.6', '3.11']

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- uses: actions/download-artifact@v2
with:
name: wheels
path: built_wheels
- name: Install Dependencies
run: python -m pip install trimesh numpy
- name: Install Packages
run: python -m pip install --no-index --find-links=./built_wheels coacd
- name: Run Tests
run: python run_tests.py -v
8 changes: 4 additions & 4 deletions python/package/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
)


try:
_lib = ctypes.CDLL(os.path.join(os.path.dirname(__file__), "lib_coacd.so"))
except OSError:
_lib = ctypes.CDLL(os.path.join(os.path.dirname(__file__), "lib_coacd.dll"))
_lib_files = os.listdir(os.path.dirname(os.path.abspath(__file__)))
for _file in _lib_files:
if _file.startswith("lib_coacd"):
_lib = ctypes.CDLL(os.path.join(os.path.dirname(os.path.abspath(__file__)), _file))


class CoACD_Mesh(ctypes.Structure):
Expand Down
26 changes: 26 additions & 0 deletions run_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import trimesh
import os
import glob
import coacd
import unittest


class TestExamples(unittest.TestCase):
@staticmethod
def single(input_file):

def _test(self: 'TestExamples'):
coacd.set_log_level("warn")
mesh = trimesh.load(input_file, force="mesh")
mesh = coacd.Mesh(mesh.vertices, mesh.faces)
self.assertLessEqual(len(coacd.run_coacd(mesh)), 1000)

return _test


for f in glob.glob("examples/*.obj"):
setattr(TestExamples, f'test_{os.path.splitext(os.path.basename(f))[0].lower()}', TestExamples.single(f))


if __name__ == '__main__':
unittest.main()
16 changes: 14 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,20 @@
import platform
import subprocess

from setuptools import setup, find_packages, Extension
from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext
from wheel.bdist_wheel import bdist_wheel


class bdist_wheel_abi3(bdist_wheel):
def get_tag(self):
python, abi, plat = super().get_tag()

if python.startswith("cp"):
# on CPython, our wheels are abi3 and compatible back to 3.6
return python, "abi3", plat

return python, abi, plat


class CMakeExtension(Extension):
Expand Down Expand Up @@ -91,7 +103,7 @@ def build_extension(self, ext):
python_requires=">=3.6",
install_requires=["numpy"],
ext_modules=[CMakeExtension("coacd")],
cmdclass={"build_ext": CMakeBuild},
cmdclass={"build_ext": CMakeBuild, "bdist_wheel": bdist_wheel_abi3},
zip_safe=False,
package_dir={"coacd": os.path.join("python/package")},
scripts=["python/package/bin/coacd"]
Expand Down

0 comments on commit f945f7b

Please sign in to comment.