Skip to content

Commit

Permalink
Build wheels on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Luthaf committed Dec 5, 2022
1 parent 672460f commit 323523d
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 11 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
@@ -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
9 changes: 7 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
16 changes: 7 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(
Expand All @@ -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"
Expand All @@ -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
Expand Down

0 comments on commit 323523d

Please sign in to comment.