-
Notifications
You must be signed in to change notification settings - Fork 7
cmake: modernize CMake infrastructure; adds modules, bindings; build Windows wheels #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
5e144e7
f9cff67
3baa45e
fe8536d
2355082
f99b653
5092790
7053593
7580825
665d827
f10a2ca
513dba5
7dc518c
855ec88
b91b7d6
d509ce0
5d13185
1da0110
938b4fd
153982c
bdf7dde
f7099e1
9ce55ba
d626c9c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| name: CMake CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ master ] | ||
| pull_request: | ||
| branches: [ master ] | ||
|
|
||
| jobs: | ||
| cmake-build-test: | ||
| name: CMake on ${{ matrix.os }} | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| - os: ubuntu-latest | ||
| deps: sudo apt-get update && sudo apt-get install -y cmake bzip2 gzip xz-utils flac zip unzip libbz2-dev liblzma-dev libflac-dev libpcre3-dev libzzip-dev | ||
| - os: macos-latest | ||
| deps: brew install --quiet cmake bzip2 flac xz pcre libzzip | ||
| - os: windows-latest | ||
| deps: choco install cmake --no-progress | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.12' | ||
|
|
||
| - name: Install Python dependencies | ||
| run: python -m pip install numpy>2 | ||
|
|
||
| - name: Install system dependencies | ||
| run: ${{ matrix.deps }} | ||
|
|
||
| - name: Configure CMake | ||
| working-directory: cmake | ||
| run: cmake -B build -DBUILD_PYTHON=ON -DGD_TEST=ON | ||
|
|
||
| - name: Build | ||
| working-directory: cmake | ||
| run: cmake --build build --config Release | ||
|
|
||
| - name: Run tests | ||
| working-directory: cmake | ||
| run: ctest --test-dir build --output-on-failure --build-config Release --no-tests=error |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,51 +16,15 @@ jobs: | |
| matrix: | ||
| include: | ||
| # macos-15-intel for x86_64 (min macOS 15.0), macos-14 for ARM (min macOS 14.0) | ||
| - os: macos-15-intel | ||
| python: '3.9' | ||
| build: 'cp39-macosx_x86_64' | ||
| target: '15.0' | ||
| prefix: /usr/local | ||
|
|
||
| - os: macos-15-intel | ||
| python: '3.10' | ||
| build: 'cp310-macosx_x86_64' | ||
| target: '15.0' | ||
| prefix: /usr/local | ||
|
|
||
| - os: macos-15-intel | ||
| python: '3.11' | ||
| build: 'cp311-macosx_x86_64' | ||
| target: '15.0' | ||
| prefix: /usr/local | ||
|
|
||
| - os: macos-15-intel | ||
| python: '3.12' | ||
| build: 'cp312-macosx_x86_64' | ||
| build: 'cp*-macosx_x86_64' | ||
| target: '15.0' | ||
| prefix: /usr/local | ||
|
|
||
| - os: macos-14 | ||
| python: '3.9' | ||
| build: 'cp39-macosx_arm64' | ||
| target: '14.0' | ||
| prefix: /opt/homebrew | ||
|
|
||
| - os: macos-14 | ||
| python: '3.10' | ||
| build: 'cp310-macosx_arm64' | ||
| target: '14.0' | ||
| prefix: /opt/homebrew | ||
|
|
||
| - os: macos-14 | ||
| python: '3.11' | ||
| build: 'cp311-macosx_arm64' | ||
| target: '14.0' | ||
| prefix: /opt/homebrew | ||
|
|
||
| - os: macos-14 | ||
| python: '3.12' | ||
| build: 'cp312-macosx_arm64' | ||
| build: 'cp*-macosx_arm64' | ||
| target: '14.0' | ||
| prefix: /opt/homebrew | ||
|
|
||
|
|
@@ -69,6 +33,11 @@ jobs: | |
| build: 'cp*-manylinux_x86_64' | ||
| prefix: /usr | ||
|
|
||
| - os: windows-latest | ||
| python: '3.12' | ||
| build: 'cp*-win_amd64' | ||
| prefix: 'C:\Program Files' | ||
|
|
||
| steps: | ||
| - name: Setup environment | ||
| run: echo "PREFIX=${{ matrix.prefix }}" >> $GITHUB_ENV | ||
|
|
@@ -87,43 +56,46 @@ jobs: | |
| - name: Setup macOS environment | ||
| if: runner.os == 'macOS' | ||
| run: | | ||
| brew install automake libtool | ||
| echo "MACOSX_DEPLOYMENT_TARGET=${{ matrix.target }}" >> $GITHUB_ENV | ||
| echo CPPFLAGS="`python3-config --includes`" >> $GITHUB_ENV | ||
|
|
||
| - name: Install cibuildwheel | ||
| run: python -m pip install cibuildwheel==2.21.3 | ||
| run: python -m pip install cibuildwheel==3.3.0 | ||
|
|
||
| - name: Build wheels | ||
| run: python -m cibuildwheel --output-dir wheelhouse bindings/python | ||
| env: | ||
| CIBW_BUILD: ${{ matrix.build }} | ||
| CIBW_SKIP: cp36* cp37* cp38* | ||
| CIBW_SKIP: cp38* | ||
| CIBW_BEFORE_ALL_LINUX: > | ||
| yum install -y bzip2-devel flac-devel xz-devel pcre-devel zziplib-devel && | ||
| .github/workflows/bootstrap.sh --disable-python && | ||
| make | ||
| yum install -y cmake bzip2-devel flac-devel xz-devel pcre-devel zziplib-devel | ||
| CIBW_BEFORE_ALL_MACOS: > | ||
| brew install bzip2 flac xz pcre libzzip && | ||
| .github/workflows/bootstrap.sh --disable-python && | ||
| make | ||
| brew install --quiet cmake bzip2 flac xz pcre libzzip | ||
| CIBW_BEFORE_ALL_WINDOWS: > | ||
| choco install cmake --no-progress | ||
| CIBW_BEFORE_BUILD: > | ||
| python -m pip install "numpy>=2.0" && | ||
| .github/workflows/bootstrap.sh && | ||
| make -C bindings/python pyconstants.c | ||
| CIBW_REPAIR_WHEEL_COMMAND_LINUX: > | ||
| LD_LIBRARY_PATH=$PWD/src/.libs auditwheel repair -w {dest_dir} {wheel} | ||
| CIBW_REPAIR_WHEEL_COMMAND_MACOS: > | ||
| DYLD_LIBRARY_PATH=$PWD/src/.libs delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel} | ||
|
Comment on lines
-114
to
-117
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you sure these repair wheel command tweaks are not needed for linux and osx? IIRC I've had to set the library paths by hand like this for the repair tools to find the shared libraries and set RPATH correctly. |
||
| python -m pip install "scikit-build-core>=0.5" "numpy>=2.0" | ||
| CIBW_BEFORE_BUILD_WINDOWS: > | ||
| pip install delvewheel "scikit-build-core>=0.5" "numpy>=2.0" | ||
| CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: > | ||
| delvewheel repair --extract-dir {dest_dir}\..\extract --add-path {dest_dir}\..\extract\bin -vv -w {dest_dir} {wheel} | ||
| CIBW_BUILD_VERBOSITY: 1 | ||
| CIBW_TEST_COMMAND: > | ||
| cd {package}/test && | ||
| PYTHONPATH=`python -c 'import sysconfig; print(sysconfig.get_paths()["purelib"])'`:$PYTHONPATH make check | ||
| CIBW_TEST_COMMAND_LINUX: > | ||
| python -c "import pygetdata; print(f'pygetdata version: {pygetdata.__version__}')" && | ||
| cd {project}/bindings/python/test && | ||
| python big_test.py | ||
| CIBW_TEST_COMMAND_MACOS: > | ||
| python -c "import pygetdata; print(f'pygetdata version: {pygetdata.__version__}')" && | ||
| cd {project}/bindings/python/test && | ||
| python big_test.py | ||
| CIBW_TEST_COMMAND_WINDOWS: > | ||
| python -c "import pygetdata; print(f'pygetdata version: {pygetdata.__version__}')" && | ||
| cd /d {project}\bindings\python\test && | ||
| python big_test.py | ||
|
|
||
| - name: Upload artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: cibw-wheel-${{ matrix.os }}-${{ matrix.python }} | ||
| name: cibw-wheel-${{ matrix.os }} | ||
| path: ./wheelhouse/pygetdata*.whl | ||
|
|
||
| upload_pypi: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,9 @@ libpath_mangled | |
| Makefile | ||
| Makefile.in | ||
|
|
||
| CMakeFiles | ||
| CMakeCache.txt | ||
|
|
||
| /*.zip | ||
| /*.tar.* | ||
| /*.sig | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,23 @@ | ||
| [build-system] | ||
| requires = ["setuptools", "setuptools-scm", "wheel", "numpy>=2.0"] | ||
| build-backend = "setuptools.build_meta" | ||
| requires = ["scikit-build-core>=0.5", "numpy>=2.0", "setuptools-scm"] | ||
| build-backend = "scikit_build_core.build" | ||
|
|
||
| [project] | ||
| name = "pygetdata" | ||
| dependencies = ["numpy>=1.7"] | ||
| dynamic = ["version"] | ||
|
|
||
| [tool.setuptools] | ||
| script-files = ["../../util/dirfile2ascii", "../../util/checkdirfile"] | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These utilities are actually quite useful to include in the wheels if possible.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, halfway there. The wheels now
Unfortunately, two limitations
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am losing all steam on making the windows build work, to be honest. I'd just turn the utils off on the windows build altogether. For the linux/osx builds, I think you can tell cmake to install binary files in the top level bin directory (something like
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps |
||
| [tool.scikit-build] | ||
| cmake.source-dir = "../../cmake" | ||
| cmake.build-type = "Release" | ||
| cmake.args = ["-DBUILD_PYTHON=ON", "-DGD_TEST=OFF", "-DGD_UTIL=ON", "-DBUILD_CXX=OFF"] | ||
| wheel.install-dir = "." | ||
|
|
||
| [tool.scikit-build.metadata.version] | ||
| provider = "scikit_build_core.metadata.setuptools_scm" | ||
|
|
||
| [tool.setuptools_scm] | ||
| version_scheme = "only-version" | ||
| root = "../.." | ||
| version_scheme = "no-guess-dev" | ||
| local_scheme = "no-local-version" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are all of these plugin libraries being found correctly by cmake? IIRC, I had to give hints to autotools with the bootstrap command to make sure that all of the. compression plugins built properly.