Skip to content
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

Build Python wheels #159

Merged
merged 116 commits into from
Sep 27, 2024
Merged

Build Python wheels #159

merged 116 commits into from
Sep 27, 2024

Conversation

arahlin
Copy link
Member

@arahlin arahlin commented Aug 23, 2024

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.

@arahlin arahlin requested a review from tskisner August 23, 2024 19:35
@arahlin arahlin self-assigned this Aug 23, 2024
@tskisner
Copy link
Member

These changes look good. Give me a little time to try running a test within the so3g wheel builds and see if this branch removes the need for our local patching.

@arahlin
Copy link
Member Author

arahlin commented Sep 24, 2024

Ok I've rearranged a bit so that the bits that are specific to the GitHub runner just check the CIBUILDHWEEL environment variable, and otherwise the python build assembles everything that the cmake one did. I've also tried to make the cmake version handling a bit smoother.

@arahlin arahlin force-pushed the cmake_wheels_option branch from 9c8cf93 to 32c9be4 Compare September 24, 2024 19:27
Only link executables against libpython, and ensure libraries use dynamic lookup
on all platforms
@arahlin arahlin force-pushed the cmake_wheels_option branch from ae5bc06 to 8ab46b4 Compare September 24, 2024 21:50
@arahlin
Copy link
Member Author

arahlin commented Sep 25, 2024

The runner now handles linux and macOS wheels identically, not building any executables that require linking against libpython, and linking all shared libraries and modules against the Python::Module smart target with dynamic lookups enabled. The parts of the build specific to cibuildwheel are otherwise very few and well-contained.

@arahlin arahlin force-pushed the cmake_wheels_option branch from 8bbc639 to d5596c4 Compare September 25, 2024 05:05
@arahlin arahlin force-pushed the cmake_wheels_option branch 2 times, most recently from 1be12d0 to 5050cbc Compare September 26, 2024 02:16
@arahlin arahlin force-pushed the cmake_wheels_option branch from 5050cbc to fac02c0 Compare September 26, 2024 03:20
@arahlin arahlin force-pushed the cmake_wheels_option branch from fa25018 to 2f6aa91 Compare September 26, 2024 05:27
@arahlin arahlin force-pushed the cmake_wheels_option branch from 2f6aa91 to 49c17b9 Compare September 26, 2024 05:38
@arahlin
Copy link
Member Author

arahlin commented Sep 26, 2024

I've split off the library rearranging bits into a separate PR #163 to make this one a bit less of a monster.

@arahlin arahlin merged commit 5232274 into master Sep 27, 2024
18 checks passed
@arahlin arahlin deleted the cmake_wheels_option branch September 27, 2024 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants