Fix macos builds and windows Python 3.12 build. #23
Workflow file for this run
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
name: build | |
on: | |
push: | |
branches: [ develop ] | |
pull_request: | |
branches: [ develop ] | |
jobs: | |
build-sdist: | |
runs-on: 'ubuntu-latest' | |
steps: | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' | |
- uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- name: Create sdist | |
run: | | |
./cddlib-makefile-gmp.sh | |
pip install setuptools | |
python setup.py sdist | |
- name: Check files | |
run: | | |
python -m pip install twine | |
twine check dist/* | |
- name: Upload sdist | |
uses: actions/upload-artifact@v4 | |
with: | |
name: sdist | |
path: dist/* | |
if-no-files-found: error | |
test-ubuntu-macos: | |
runs-on: ${{ matrix.os }} | |
needs: build-sdist | |
strategy: | |
fail-fast: false | |
matrix: | |
os: ['ubuntu-latest', 'macos-latest'] | |
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] | |
cython-version: [''] | |
include: | |
# test oldest supported Cython version on most recent Python | |
- os: 'ubuntu-latest' | |
python-version: '3.12' | |
cython-version: '==3.0.0' | |
steps: | |
- uses: actions/checkout@v3 # no submodules needed here, just checking out for the test suite | |
- name: Download sdist | |
uses: actions/download-artifact@v4 | |
with: | |
name: sdist | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install libgmp (Ubuntu) | |
if: matrix.os == 'ubuntu-latest' | |
run: sudo apt-get install -y libgmp-dev | |
- name: Install libgmp (MacOS) | |
if: matrix.os == 'macos-latest' | |
run: brew install gmp | |
- name: Install Python dependencies | |
run: python -m pip install setuptools Cython${{ matrix.cython-version }} Sphinx pytest wheel numpy | |
- name: Install tarball (Ubuntu) | |
if: matrix.os == 'ubuntu-latest' | |
run: python -m pip install --pre --no-index --find-links=. pycddlib | |
- name: Install tarball (MacOS) | |
if: matrix.os == 'macos-latest' | |
run: | | |
brew --prefix | |
ls $(brew --prefix)/include/*gmp* | |
ls $(brew --prefix)/lib/*gmp* | |
env "CFLAGS=-I$(brew --prefix)/include -L$(brew --prefix)/lib" python -m pip install --pre --no-index --find-links=. pycddlib | |
- name: Run test suite | |
run: | | |
pytest | |
cd docs | |
make doctest | |
build-mpir: | |
runs-on: 'windows-latest' | |
strategy: | |
fail-fast: false | |
matrix: | |
architecture: ['x86', 'x64'] | |
platformtoolset: ['v143'] # all supported python versions can use this one | |
steps: | |
- name: Setup msbuild (Windows) | |
uses: microsoft/[email protected] | |
- uses: actions/cache@v3 | |
id: mpir-installed-cache | |
with: | |
path: mpir-mpir-3.0.0/lib/*/Release/ | |
key: mpir-0-${{ matrix.platformtoolset }}-${{ matrix.architecture }} | |
- name: Install mpir | |
if: steps.mpir-installed-cache.outputs.cache-hit != 'true' | |
run: | | |
Invoke-WebRequest -Uri "https://github.com/wbhart/mpir/archive/refs/heads/mpir-3.0.0.zip" -OutFile "mpir-3.0.0.zip" | |
7z x mpir-3.0.0.zip > NUL | |
if ("${{ matrix.architecture }}" -eq "x86") { $platform = "Win32" } else { $platform = "x64" } | |
msbuild mpir-mpir-3.0.0\build.vc14\lib_mpir_gc\lib_mpir_gc.vcxproj /p:Configuration=Release /p:Platform=$platform /p:PlatformToolset=${{ matrix.platformtoolset }} /verbosity:normal | |
dir mpir-mpir-3.0.0/lib/$platform/Release/ | |
- name: Upload mpir | |
uses: actions/upload-artifact@v4 | |
with: | |
name: mpir-${{ matrix.platformtoolset }}-${{ matrix.architecture }} | |
path: mpir-mpir-3.0.0/lib/*/Release/ | |
if-no-files-found: error | |
build-test-windows: | |
runs-on: 'windows-latest' | |
needs: build-mpir | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] | |
architecture: ['x86', 'x64'] | |
platformtoolset: ['v143'] # all supported python versions can use this one | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- name: Download mpir | |
uses: actions/download-artifact@v4 | |
with: | |
name: mpir-${{ matrix.platformtoolset }}-${{ matrix.architecture }} | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
architecture: ${{ matrix.architecture }} | |
- name: Check Python | |
run: | | |
if ("${{ matrix.architecture }}" -eq "x86") { $platform = "Win32" } else { $platform = "x64" } | |
ls $platform/Release/ | |
python --version | |
python -c "import struct; print(struct.calcsize('P') * 8)" | |
- name: Install Python dependencies | |
run: | | |
python -m pip install Cython Sphinx pytest wheel numpy twine build | |
- name: Create bdist_wheel | |
run: | | |
./cddlib-makefile-gmp.ps1 | |
dir cddlib/lib-src/ | |
if ("${{ matrix.architecture }}" -eq "x86") { $platform = "Win32" } else { $platform = "x64" } | |
mkdir dist -Force | |
python -m build --wheel -C="--global-option=build_ext" -C="--global-option=-I$platform/Release/" -C="--global-option=-L$platform/Release/" . | |
# pip wheel -w dist --global-option="build_ext" --global-option="-I$platform/Release/" --global-option="-L$platform/Release/" . | |
- name: Check files | |
run: twine check dist/* | |
- name: Upload wheel | |
uses: actions/upload-artifact@v4 | |
with: | |
name: windows-wheels-${{ matrix.python-version }}-${{ matrix.architecture }} | |
path: dist/* | |
if-no-files-found: error | |
- name: Install wheel | |
run: | | |
cd dist | |
ls | |
pip install --pre --no-index --find-links=. pycddlib | |
cd .. | |
- name: Run test suite | |
run: | | |
pytest | |
cd docs | |
make doctest | |
release: | |
if: github.repository == 'mcmtroffaes/pycddlib' | |
runs-on: 'ubuntu-latest' | |
needs: [ build-sdist, test-ubuntu-macos, build-test-windows ] | |
steps: | |
- name: Download sdist | |
uses: actions/download-artifact@v4 | |
with: | |
name: sdist | |
path: dist/ | |
- name: Download wheels | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: windows-wheels-* | |
path: dist/ | |
merge-multiple: true | |
- name: List files | |
run: ls -R dist/ | |
- name: Publish to Test PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
password: ${{ secrets.TEST_PYPI_API_TOKEN }} | |
repository-url: https://test.pypi.org/legacy/ | |
- name: Publish to PyPI | |
if: startsWith(github.ref, 'refs/tags') | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
password: ${{ secrets.PYPI_API_TOKEN }} |