diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml new file mode 100644 index 0000000..20771a3 --- /dev/null +++ b/.github/workflows/wheels.yml @@ -0,0 +1,36 @@ +name: build wheels + +on: + push: + branches: [master] + pull_request: + # Check all PR + +jobs: + build_wheels: + name: ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-20.04, windows-2019, macOS-11] + + steps: + - uses: actions/checkout@v3 + with: + submodules: true + + - uses: actions/setup-python@v3 + + - name: Install cibuildwheel + run: python -m pip install cibuildwheel==2.11.2 + + - name: Build wheels + run: python -m cibuildwheel --output-dir wheelhouse + env: + CIBW_BUILD: cp39-* + CIBW_SKIP: cp39-musllinux* + CIBW_ARCHS_MACOS: x86_64 arm64 + + - uses: actions/upload-artifact@v3 + with: + path: ./wheelhouse/*.whl diff --git a/setup.cfg b/setup.cfg index 71b824f..f662014 100644 --- a/setup.cfg +++ b/setup.cfg @@ -24,10 +24,15 @@ classifiers = Topic :: Software Development :: Libraries :: Python Modules Topic :: Utilities +python_requires = >=3.6 + [options] zip_safe = False -packages=find: -package_dir= +install_requires = + numpy + +packages = find: +package_dir = =src [options.packages.find] diff --git a/setup.py b/setup.py index 5e79110..948a9b5 100644 --- a/setup.py +++ b/setup.py @@ -69,11 +69,16 @@ def run(self): if sys.platform.startswith("darwin"): cmake_options.append("-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.9") + # ARCHFLAGS is used by cibuildwheel to pass the requested arch to the + # compilers + ARCHFLAGS = os.environ.get("ARCHFLAGS") + if ARCHFLAGS is not None: + cmake_options.append(f"-DCMAKE_C_FLAGS={ARCHFLAGS}") + cmake_options.append(f"-DCMAKE_CXX_FLAGS={ARCHFLAGS}") + if os.getenv("CHFL_PY_INTERNAL_CHEMFILES"): cmake_options.append("-DCHFL_PY_INTERNAL_CHEMFILES=ON") - ninja_args = [] - subprocess.run( [CMAKE_EXECUTABLE, source_dir, *cmake_options], cwd=build_dir, @@ -87,7 +92,6 @@ class cmake_build(build_ext): """build and install chemfiles with cmake""" def run(self): - source_dir = ROOT build_dir = os.path.join(ROOT, "build", "cmake-build") subprocess.run( @@ -96,11 +100,6 @@ def run(self): ) -install_requires = ["numpy"] -if sys.hexversion < 0x03040000: - install_requires.append("enum34") - - def _get_lib_ext(): if sys.platform.startswith("win32"): ext = ".dll" @@ -115,7 +114,6 @@ def _get_lib_ext(): setup( version=__version__, - install_requires=install_requires, ext_modules=[ # only declare the extension, it is built & copied as required by cmake # in the build_ext command