-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR rearranges this code to facilitate building and installing the `spt3g` python package with standard python tools like `pip` and `build`. The shared libraries, headers, and cmake configuration files are installed relative to `CMAKE_INSTALL_PREFIX` as usual. The `pip` installer handles versioning, and passes appropriate cmake definitions to the cmake builder that compiles all of the libraries and modules, then installs the python package into the appropriate location, and triggers the cmake installer. The `pip` installer can also be run in an `--editable` mode that works much like the cmake build directory, enabling code development without the need to make changes to various path environment variables. It also should install all of the components into appropriate locations when run in a virtual environment. Versioning is done using `setuptools_scm` with the `pip` build system, or with a custom shell script with the `cmake` build system. In both cases, the version information is determined by running a series of `git` commands or by parsing the `.git_archival.txt` file, then output to `spt3g/version.py` for access in the Python package and to the `SPT3G_VERSION` preprocessor directive for access in C++. Finally, this PR includes a github workflow for producing pre-compiled wheels for Linux and OSX platforms.
- Loading branch information
Showing
20 changed files
with
510 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node: $Format:%H$ | ||
node-date: $Format:%cI$ | ||
describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
VERSION filter=exportversion | ||
.gitattributes export-ignore | ||
.gitignore export-ignore | ||
.git_archival.txt export-subst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
name: Wheels | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
release: | ||
types: [ published ] | ||
|
||
jobs: | ||
build_wheels: | ||
name: Build wheels for ${{ matrix.build }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
# macos-13 is an intel runner, macos-14 is apple silicon | ||
- os: macos-13 | ||
build: cp38-macosx_x86_64 | ||
target: 13.0 | ||
- os: macos-13 | ||
build: cp39-macosx_x86_64 | ||
target: 13.0 | ||
- os: macos-13 | ||
build: cp310-macosx_x86_64 | ||
target: 13.0 | ||
- os: macos-13 | ||
build: cp311-macosx_x86_64 | ||
target: 13.0 | ||
- os: macos-13 | ||
build: cp312-macosx_x86_64 | ||
target: 13.0 | ||
|
||
- os: macos-14 | ||
build: cp39-macosx_arm64 | ||
target: 14.0 | ||
- os: macos-14 | ||
build: cp310-macosx_arm64 | ||
target: 14.0 | ||
- os: macos-14 | ||
build: cp311-macosx_arm64 | ||
target: 14.0 | ||
- os: macos-14 | ||
build: cp312-macosx_arm64 | ||
target: 14.0 | ||
|
||
- os: ubuntu-latest | ||
build: cp38-manylinux_x86_64 | ||
- os: ubuntu-latest | ||
build: cp39-manylinux_x86_64 | ||
- os: ubuntu-latest | ||
build: cp310-manylinux_x86_64 | ||
- os: ubuntu-latest | ||
build: cp311-manylinux_x86_64 | ||
- os: ubuntu-latest | ||
build: cp312-manylinux_x86_64 | ||
|
||
steps: | ||
- name: Set macOS deployment target | ||
if: runner.os == 'macOS' | ||
run: echo "MACOSX_DEPLOYMENT_TARGET=${{ matrix.target }}" >> $GITHUB_ENV | ||
|
||
# missing build tools on some macos runners | ||
- name: Install macOS build dependencies | ||
if: runner.os == 'macOS' | ||
run: brew install automake libtool | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
fetch-tags: true | ||
|
||
- name: Build wheels | ||
uses: pypa/[email protected] | ||
env: | ||
CIBW_BUILD: ${{ matrix.build }} | ||
CIBW_BEFORE_ALL_LINUX: yum install -y bzip2-devel flac-devel netcdf-devel | ||
CIBW_BEFORE_ALL_MACOS: brew install bzip2 flac netcdf | ||
CIBW_BEFORE_BUILD: ./deps/install_boost.sh | ||
CIBW_REPAIR_WHEEL_COMMAND_MACOS: > | ||
DYLD_LIBRARY_PATH=$PWD/deps/lib delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel} | ||
CIBW_BUILD_VERBOSITY: 1 | ||
CIBW_ENVIRONMENT: > | ||
CMAKE_BUILD_PARALLEL_LEVEL=4 CMAKE_PREFIX_PATH=$PWD/deps | ||
CIBW_TEST_COMMAND: ctest --test-dir {package}/build --output-on-failure | ||
|
||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: cibw-wheel-${{ matrix.build }} | ||
path: ./wheelhouse/spt3g*.whl | ||
|
||
build_sdist: | ||
name: Build source distribution | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
fetch-tags: true | ||
|
||
- name: Build sdist | ||
run: pipx run build --sdist | ||
|
||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: cibw-sdist | ||
path: dist/*.tar.gz | ||
|
||
upload_pypi: | ||
needs: [build_wheels, build_sdist] | ||
runs-on: ubuntu-latest | ||
environment: pypi | ||
permissions: | ||
id-token: write | ||
if: github.event_name == 'release' && github.event.action == 'published' | ||
steps: | ||
- name: Download artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
# unpacks all CIBW artifacts into dist/ | ||
pattern: cibw-* | ||
path: dist | ||
merge-multiple: true | ||
|
||
- name: Publish package distributions to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.