Add new params margins #366
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 and test wheels then upload to PyPI | |
# on: [push, pull_request] | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
checkout-code: | |
name: Checkout source code | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout cxx-image-io source code | |
uses: actions/checkout@v4 | |
with: | |
lfs: 'true' | |
- name: Upload the source code to artifact for build in matrix later | |
uses: actions/upload-artifact@v4 | |
with: | |
name: source | |
path: . | |
- name: Upload the test code to artifact for using later | |
uses: actions/upload-artifact@v4 | |
with: | |
name: test | |
path: ./test/ | |
build_and_test_sdist: | |
needs: checkout-code | |
name: Build and test source distribution | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Download source code artifact | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: source | |
path: . | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12" | |
- name: Build sdist | |
run: | | |
cd source && | |
python3 -m pip install build pytest | |
python3 -m build --sdist | |
- name: Installation from sdist | |
run: | | |
sudo apt install nasm -y | |
cd source && | |
pip install dist/*tar.gz --break-system-packages --verbose | |
- name: Download test code artifact | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: test | |
path: test-cxx-image-io | |
- name: Test installed package | |
run: | | |
cd test-cxx-image-io && | |
ls -l .. && | |
pytest -sv | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: cibw-sdist | |
path: source/dist/*.tar.gz | |
build_and_test_windows: | |
needs: checkout-code | |
name: Windows wheel ${{ matrix.os }}-${{matrix.cp-version}} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [windows-latest] | |
cp-version: ["cp39", "cp310", "cp311","cp312", "cp313"] | |
steps: | |
- name: Download source code artifact | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: source | |
path: . | |
- name: Install Msys2 mingw64 for g++ and gcc tools on windows | |
uses: msys2/setup-msys2@v2 | |
with: | |
msystem: MINGW64 | |
location: D:\ | |
update: true | |
install: mingw-w64-x86_64-gcc mingw-w64-x86_64-cmake mingw-w64-x86_64-nasm mingw-w64-x86_64-ninja | |
- name: Install cibuildwheel for Windows | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install setuptools wheel numpy | |
python -m pip install cibuildwheel==2.21.3 | |
- name: Download test code artifact | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: test | |
path: ./test-cxx-image-io | |
- name: Build wheels for Windows AMD64 | |
run: | | |
cd source && | |
python -m cibuildwheel --output-dir wheelhouse | |
# to supply options, put them in 'env', like: | |
env: | |
CIBW_ARCHS: AMD64 | |
CIBW_ENVIRONMENT_WINDOWS: > | |
PATH="D:\\msys64\\mingw64\\bin;D:\\msys64\\mingw64;$PATH" | |
CIBW_BEFORE_BUILD: > | |
rm -rf C:\\hostedtoolcache\\windows\\Python\\3.9.13\\x64\\python3.exe && | |
rm -rf C:\\hostedtoolcache\\windows\\Python\\3.9.13\\x64\\libs\\python39.lib && | |
git config --system core.longpaths true | |
CIBW_TEST_REQUIRES: pytest | |
CIBW_TEST_COMMAND: "pytest -sv {project}/../test-cxx-image-io/test" | |
CIBW_BUILD: ${{matrix.cp-version}}-* | |
CIBW_SKIP: pp* cp36-* cp37-* cp38-* | |
CIBW_BUILD_VERBOSITY: 1 | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: cibw-wheels-${{ matrix.os }}-${{ matrix.cp-version }} | |
path: ./source/wheelhouse/*.whl | |
build_and_test_linux: | |
needs: checkout-code | |
name: wheel-${{ matrix.linux }}-${{ matrix.arch }}-${{matrix.cp-version}} | |
runs-on: ubuntu-22.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
arch: [aarch64, x86_64] | |
cp-version: ["cp39", "cp310", "cp311","cp312", "cp313"] | |
linux: ["manylinux", "musllinux"] | |
steps: | |
- name: Download source code artifact | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: source | |
path: . | |
- if: matrix.arch == 'aarch64' | |
name: Set up QEMU for aarch64 linux simulation | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: all | |
- name: Install cibuildwheel for Linux | |
run: | | |
python3 -m pip install --upgrade pip | |
python3 -m pip install setuptools wheel pytest numpy | |
python3 -m pip install cibuildwheel==2.21.3 | |
- name: Download test code artifact | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: test | |
path: ./source/test-cxx-image-io | |
- if: matrix.arch == 'x86_64' && matrix.linux == 'manylinux' | |
name: wheels x86_64 Many Linux | |
run: | | |
cd source && | |
python3 -m cibuildwheel --output-dir wheelhouse | |
# to supply options, put them in 'env', like: | |
env: | |
CIBW_ARCHS_LINUX: x86_64 | |
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 | |
CIBW_BEFORE_ALL: > | |
yum install -y nasm ninja-build | |
CIBW_BEFORE_BUILD: > | |
rm -rf /usr/local/bin/python3* | |
CIBW_TEST_REQUIRES: pytest | |
CIBW_TEST_COMMAND: "pytest -sv {project}/test-cxx-image-io/test" | |
CIBW_BUILD: ${{matrix.cp-version}}-* | |
CIBW_SKIP: pp* cp36-* cp37-* cp38-* *musllinux* | |
CIBW_REPAIR_WHEEL_COMMAND_LINUX: > | |
export LD_LIBRARY_PATH=/project/cxx_image_io && | |
auditwheel repair -w {dest_dir} {wheel} --only-plat | |
CIBW_BUILD_VERBOSITY: 1 | |
- if: matrix.arch == 'x86_64' && matrix.linux == 'musllinux' | |
name: wheels x86_64 musllinux | |
run: | | |
cd source && | |
python3 -m cibuildwheel --output-dir wheelhouse | |
# to supply options, put them in 'env', like: | |
env: | |
CIBW_ARCHS_LINUX: x86_64 | |
CIBW_MUSLLINUX_X86_64_IMAGE: musllinux_1_2 | |
CIBW_BEFORE_ALL: > | |
apk add --update nasm samurai | |
CIBW_BEFORE_BUILD: > | |
rm -rf /usr/local/bin/python3* | |
CIBW_TEST_REQUIRES: pytest | |
CIBW_TEST_COMMAND: "pytest -sv {project}/test-cxx-image-io/test" | |
CIBW_BUILD: ${{matrix.cp-version}}-* | |
CIBW_SKIP: pp* cp36-* cp37-* cp38-* *manylinux* | |
CIBW_REPAIR_WHEEL_COMMAND_LINUX: > | |
export LD_LIBRARY_PATH=/project/cxx_image_io && | |
auditwheel repair -w {dest_dir} {wheel} --only-plat | |
CIBW_BUILD_VERBOSITY: 1 | |
- if: matrix.arch == 'aarch64' && matrix.linux == 'manylinux' | |
name: wheels aarch64 manylinux | |
run: | | |
cd source && | |
python3 -m cibuildwheel --output-dir wheelhouse | |
# to supply options, put them in 'env', like: | |
env: | |
CIBW_ARCHS_LINUX: aarch64 | |
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux_2_28 | |
CIBW_BEFORE_ALL: > | |
yum install -y cmake nasm ninja-build | |
CIBW_BEFORE_BUILD: > | |
rm -rf /usr/local/bin/python3* | |
CIBW_TEST_REQUIRES: pytest | |
CIBW_TEST_COMMAND: "pytest -sv {project}/test-cxx-image-io/test" | |
CIBW_BUILD: ${{matrix.cp-version}}-* | |
CIBW_SKIP: pp* cp36-* cp37-* cp38-* *musllinux* | |
CIBW_REPAIR_WHEEL_COMMAND_LINUX: > | |
export LD_LIBRARY_PATH=/project/cxx_image_io && | |
auditwheel repair -w {dest_dir} {wheel} --only-plat | |
CIBW_BUILD_VERBOSITY: 1 | |
- if: matrix.arch == 'aarch64' && matrix.linux == 'musllinux' | |
name: wheels aarch64 musllinux | |
run: | | |
cd source && | |
python3 -m cibuildwheel --output-dir wheelhouse | |
# to supply options, put them in 'env', like: | |
env: | |
CIBW_ARCHS_LINUX: aarch64 | |
CIBW_MANYLINUX_AARCH64_IMAGE: musllinux_1_2 | |
CIBW_BEFORE_ALL: > | |
apk add --update cmake nasm samurai | |
CIBW_BEFORE_BUILD: > | |
rm -rf /usr/local/bin/python3* | |
CIBW_TEST_REQUIRES: pytest | |
CIBW_TEST_COMMAND: "pytest -sv {project}/test-cxx-image-io/test" | |
CIBW_BUILD: ${{matrix.cp-version}}-* | |
CIBW_SKIP: pp* cp36-* cp37-* cp38-* *manylinux* | |
CIBW_REPAIR_WHEEL_COMMAND_LINUX: > | |
export LD_LIBRARY_PATH=/project/cxx_image_io && | |
auditwheel repair -w {dest_dir} {wheel} --only-plat | |
CIBW_BUILD_VERBOSITY: 1 | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: cibw-wheels-${{ matrix.arch }}-${{ matrix.cp-version }}-${{matrix.linux}} | |
path: ./source/wheelhouse/*.whl | |
build_and_test_macos: | |
needs: checkout-code | |
name: MACOS wheel ${{ matrix.os }}-${{matrix.cp-version}} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [macos-13, macos-14] | |
cp-version: ["cp39", "cp310", "cp311","cp312", "cp313"] | |
steps: | |
- name: Download source code artifact | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: source | |
path: . | |
- name: Remove firstly the installed libs from MacOS | |
run : | | |
brew install nasm ninja | |
sudo rm -rf /Library/Frameworks/Mono.framework | |
brew uninstall --ignore-dependencies jpeg-turbo libpng libtiff | |
- name: Install cibuildwheel for MacOS | |
run: | | |
python3 -m pip install --upgrade pip --break-system-packages | |
python3 -m pip install setuptools wheel numpy --break-system-packages | |
python3 -m pip install cibuildwheel==2.21.3 --break-system-packages | |
- name: Download test code artifact | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: test | |
path: ./test-cxx-image-io | |
- name: wheels MacOS | |
run: | | |
cd source && | |
python3 -m cibuildwheel --output-dir wheelhouse | |
# to supply options, put them in 'env', like: | |
env: | |
MACOSX_DEPLOYMENT_TARGET: 11.0 | |
CIBW_TEST_REQUIRES: pytest | |
CIBW_TEST_COMMAND: "pytest -sv {project}/../test-cxx-image-io/test" | |
CIBW_BUILD: ${{matrix.cp-version}}-* | |
CIBW_SKIP: pp* cp36-* cp37-* cp38-* | |
CIBW_REPAIR_WHEEL_COMMAND_MACOS: > | |
DYLD_LIBRARY_PATH=${{github.workspace}}/source/cxx_image_io delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel} | |
CIBW_BUILD_VERBOSITY: 1 | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: cibw-wheels-${{ matrix.os }}-${{ matrix.cp-version }} | |
path: ./source/wheelhouse/*.whl | |
publish-to-test-pypi: | |
if: contains(github.event.head_commit.message,'[Release]') # only publish to Test PyPI when [Release] in commit | |
needs: [build_and_test_windows, build_and_test_linux, build_and_test_macos, build_and_test_sdist] | |
environment: | |
name: testpypi | |
url: https://test.pypi.org/project/cxx-image-io | |
permissions: | |
id-token: write | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download all the dists | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: cibw-* | |
path: dist | |
merge-multiple: true | |
- name: Publish distribution to TestPyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
repository-url: https://test.pypi.org/legacy/ | |
skip-existing: true | |
test-download-package: | |
if: contains(github.event.head_commit.message,'[Release]') # only publish to Test PyPI when [Release] in commit | |
needs: | |
- publish-to-test-pypi | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [windows-2019, ubuntu-24.04, macos-15] | |
python-version: ["3.9", "3.10", "3.11","3.12", "3.13"] | |
steps: | |
- name: Download git repo code | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: test | |
path: image_io/ | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install cxx-image-io from test pypi and run NRT test | |
run: | | |
python -c "import sys; print(sys.version)" | |
python -m pip install --upgrade pip | |
python -m pip install numpy pytest | |
pip install -i https://test.pypi.org/simple/ cxx-image-io | |
cd image_io/ | |
mkdir -p test/_outputs | |
pytest -sv | |
publish-to-pypi: | |
if: contains(github.event.head_commit.message,'[Release]') # only publish to PyPI when [Release] in commit message | |
needs: | |
- test-download-package | |
runs-on: ubuntu-latest | |
environment: | |
name: pypi | |
url: https://pypi.org/project/cxx-image-io/ | |
permissions: | |
id-token: write # IMPORTANT: mandatory for trusted publishing | |
steps: | |
- name: Download all the dists | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: cibw-* | |
path: dist | |
merge-multiple: true | |
- name: Publish distribution to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN }} | |
verbose: true |