Files
CoolProp/.github/workflows/python_buildwheels.yml
Ian Bell 70d03056e0 Modernize Python build system to use scikit-build-core (#2632)
* Modernize Python build system to use scikit-build-core

This commit replaces the old setuptools-based build system with a modern
scikit-build-core + CMake build system for the Python bindings.

Key changes:
- Replace setup.py with pyproject.toml using scikit-build-core backend
- Create new CMakeLists.txt for Cython module compilation
- Add FindCython.cmake helper module
- Update README from .rst to .md format
- Enable incremental builds with proper CMake dependency tracking
- Support Python 3.8-3.14 with proper Cython directives

Benefits:
- Incremental builds work correctly (only rebuild changed files)
- Modern PEP 517/518 compliant build system
- Build artifacts cached in build/{wheel_tag} directories
- Better integration with pip and modern Python tooling
- No more need for custom _py_backend build hooks

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Add build-time file generation and ignore generated files

This commit adds the missing build-time steps from setup.py:
- Header generation from JSON files (generate_headers.py)
- Cython constants module generation (generate_constants_module.py)
- Copying headers, fmtlib, and BibTeX file to package directory

Also updates .gitignore to ignore:
- wrappers/Python/CoolProp/include/ (generated during build)
- wrappers/Python/CoolProp/CoolPropBibTeXLibrary.bib (copied during build)

Includes test script to verify wheel contents match between old and new build approaches.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Set CMAKE_POSITION_INDEPENDENT_CODE for shared library build

Enable -fPIC flag for all targets to ensure proper shared library compilation.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Remove deprecated buildbot configuration

The buildbot system is deprecated and no longer in use.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Update extract_version.py to use .version file instead of setup.py

With the migration to scikit-build-core, version information is now stored
in the .version file and read by pyproject.toml. Updated the script to:

- Rename replace_setup_py() to replace_version_file()
- Update .version file instead of modifying setup.py
- Change --replace-setup-py flag to --replace-version

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Update build scripts and documentation for scikit-build-core

Changes:
- Updated documentation to show modern pip-based installation
- Updated manylinux build script to use pip wheel instead of setup.py
- Updated conda metadata generator to use pip install
- Removed deprecated PyPI preparation script (replaced by `python -m build --sdist`)

All build infrastructure now uses the new scikit-build-core build system.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Update manylinux Docker script for scikit-build-core

Removed SETUP_PY_ARGS since cmake options are no longer passed via
setup.py arguments. The new build system uses CMake directly via
scikit-build-core. Also fixed typo and updated install_root path.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Remove deprecated _py_backend custom build backend

The _py_backend was a custom setuptools build backend wrapper used
with the old setup.py build system. It's no longer needed with
scikit-build-core.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Add uv package manager documentation

Added section on using uv (Astral's fast Python package manager) to
install and work with CoolProp. Includes examples for:
- Installing in current environment
- Creating new projects with CoolProp
- Running scripts with automatic environment management
- Development installations from source

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix sdist packaging and update scikit-build-core config

Changes:
- Updated pyproject.toml to use newer scikit-build-core config syntax
  - cmake.minimum-version → cmake.version
  - cmake.verbose → build.verbose
- Added sdist.include to ensure .version file is in source distributions
- Added .version to MANIFEST.in for completeness

This fixes the issue where building a wheel from an sdist would fail
due to missing .version file. Now sdist → wheel builds work correctly.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Rename setup.py to deprecated_setup.py

The old setuptools-based build system has been fully replaced with
scikit-build-core. Renaming setup.py to deprecated_setup.py to:
- Clearly indicate it's no longer the primary build method
- Keep it available for reference and backward compatibility
- Prevent accidental use of the old build system

Users should now use: pip install .

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Update GitHub Actions workflows for new build system

Changes:
- Replace --replace-setup-py with --replace-version flag
- Update sdist build to use 'python -m build --sdist' instead of deprecated prepare_pypi.py
- Workflows now work with scikit-build-core build system

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix cibuildwheel to build from repository root

With scikit-build-core, the pyproject.toml is at the repository root,
not in wrappers/Python/. Updated cibuildwheel configuration:
- Changed package-dir from ./wrappers/Python/ to .
- Removed redundant CIBW_BEFORE_BUILD (dependencies are in pyproject.toml)
- Build dependencies are now automatically installed by pip from pyproject.toml

This fixes the "Multiple top-level packages discovered" error.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Set macOS deployment target to 11.0 in pyproject.toml

Configure MACOSX_DEPLOYMENT_TARGET=11.0 (Big Sur) in cibuildwheel config.
This matches the setting in GitHub Actions and ensures wheels are built
with consistent compatibility for macOS 11.0 and later.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Remove old pyproject.toml from wrappers/Python

This file was used by the old setuptools build system. With
scikit-build-core, the main pyproject.toml at the repository root
is now used for all Python packaging configuration.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Remove redundant PyPy skip selector from cibuildwheel

The 'pp*' skip selector was causing a warning because PyPy isn't enabled
in the build matrix anyway. Since we explicitly specify only CPython
versions in the build directive (cp38-*, cp39-*, etc.), the pp* skip is
unnecessary.

Fixes warning: "Invalid skip selector: 'pp*'. This selector matches a
group that wasn't enabled."

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Update fmtlib from 11.1.3 to 12.0.0

Updated the fmtlib submodule to the latest stable release (12.0.0).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Remove pdsim

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-10-11 13:07:10 -04:00

190 lines
5.6 KiB
YAML

name: Python cibuildwheel
on:
push:
branches: [ 'master', 'main', 'develop', 'actions_pypi' ]
tags: [ 'v*' ]
pull_request:
branches: [ 'master', 'main', 'develop' ]
jobs:
set-version:
runs-on: ubuntu-latest
outputs:
testpypiversion: ${{ steps.set.outputs.testpypiversion }}
steps:
- name: Set version for testpypi
id: set
run: echo "testpypiversion=$(date +%Y%m%d%H%M%S)" >> $GITHUB_OUTPUT
python_source:
needs: set-version
name: Build source package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.13.x
- name: Install dependencies
run: pip install setuptools wheel Cython requests jinja2 pyyaml packaging
- name: Figure out the TestPyPi/PyPi Version
shell: bash
run: |
if [[ "$GITHUB_REF" == *"refs/tags"* ]]; then
python dev/extract_version.py --pypi --replace-version
else
python dev/extract_version.py --replace-version --version "${{ needs.set-version.outputs.testpypiversion }}"
fi;
- name: Build package, sdist
run: |
pip install build
python -m build --sdist --outdir ${GITHUB_WORKSPACE}/Python
- name: Store artifacts
uses: actions/upload-artifact@v4
with:
name: Python-sdist
path: |
./Python/*.tar.gz
python_ubuntu:
needs: set-version
strategy:
# Ensure that a wheel builder finishes even if another fails
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: [39, 310, 311, 312, 313, 314]
arch: [i686, x86_64, ppc64le, s390x]
exclude:
- os: ubuntu-latest
arch: i686 # reduce the build time until people ask for the binaries
- os: ubuntu-latest
arch: ppc64le # reduce the build time until people ask for the binaries
- os: ubuntu-latest
arch: s390x # reduce the build time until people ask for the binaries
uses: ./.github/workflows/python_cibuildwheel.yml
with:
os: ${{ matrix.os }}
python-version: ${{ matrix.python-version }}
arch: ${{ matrix.arch }}
TESTPYPI_VERSION: ${{ needs.set-version.outputs.testpypiversion }}
python_ubuntu_arm:
needs: set-version
strategy:
# Ensure that a wheel builder finishes even if another fails
fail-fast: false
matrix:
os: [ubuntu-24.04-arm]
python-version: [39, 310, 311, 312, 313, 314]
arch: [aarch64]
uses: ./.github/workflows/python_cibuildwheel.yml
with:
os: ${{ matrix.os }}
python-version: ${{ matrix.python-version }}
arch: ${{ matrix.arch }}
TESTPYPI_VERSION: ${{ needs.set-version.outputs.testpypiversion }}
python_windows:
needs: set-version
strategy:
# Ensure that a wheel builder finishes even if another fails
fail-fast: false
matrix:
os: [windows-latest]
python-version: [39, 310, 311, 312, 313, 314]
arch: [AMD64, x86, ARM64]
#exclude:
# - os: windows
# arch: ARM64 # creates problems with msgpack-c
uses: ./.github/workflows/python_cibuildwheel.yml
with:
os: ${{ matrix.os }}
python-version: ${{ matrix.python-version }}
arch: ${{ matrix.arch }}
TESTPYPI_VERSION: ${{ needs.set-version.outputs.testpypiversion }}
python_macos:
needs: set-version
strategy:
# Ensure that a wheel builder finishes even if another fails
fail-fast: false
matrix:
os: [macos-latest]
python-version: [39, 310, 311, 312, 313, 314]
arch: [x86_64, arm64, universal2]
exclude:
- os: macos-latest
arch: universal2 # is redundant
uses: ./.github/workflows/python_cibuildwheel.yml
with:
os: ${{ matrix.os }}
python-version: ${{ matrix.python-version }}
arch: ${{ matrix.arch }}
TESTPYPI_VERSION: ${{ needs.set-version.outputs.testpypiversion }}
merge_wheels:
runs-on: ubuntu-latest
needs: [python_source, python_ubuntu, python_ubuntu_arm, python_windows, python_macos]
steps:
- name: Merge Artifacts
uses: actions/upload-artifact/merge@v4
with:
name: Python
pattern: Python-*
upload_python_bindings_to_pypi:
needs: merge_wheels
name: Upload to PyPi
runs-on: ubuntu-latest
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.13.x
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine requests packaging
if [[ "$GITHUB_REF" == *"refs/tags"* ]]; then
TWINE_REPOSITORY=pypi
TWINE_PASSWORD=${{ secrets.PYPI_TOKEN }}
else
TWINE_REPOSITORY=testpypi
TWINE_PASSWORD=${{ secrets.TESTPYPI_TOKEN }}
fi;
echo "Using TWINE_REPOSITORY=$TWINE_REPOSITORY"
echo "TWINE_REPOSITORY=$TWINE_REPOSITORY" >> $GITHUB_ENV
echo "TWINE_PASSWORD=$TWINE_PASSWORD" >> $GITHUB_ENV
- name: Download ALL wheels
uses: actions/download-artifact@v4.1.7
with:
name: Python
path: Python
- name: Display structure of downloaded files
run: |
set -x
ls -R
du -sh
- name: Publish wheels to (Test)PyPI
if: ${{ github.event_name != 'pull_request' }}
env:
TWINE_USERNAME: __token__
run: python -m twine upload --verbose --skip-existing Python/*.whl Python/*.tar.gz