From 9ccc6c8629f02e876102f3eda2f46e1afdae0cbf Mon Sep 17 00:00:00 2001 From: Alexis Jeandet Date: Fri, 8 Mar 2024 12:04:46 +0100 Subject: [PATCH] Switch to cibuildwheel Signed-off-by: Alexis Jeandet --- .github/workflows/build_wheels.yml | 119 ++++++++++++++++++++++ .github/workflows/pythonpublish-linux.yml | 54 ---------- .github/workflows/pythonpublish-osx.yml | 100 ------------------ .github/workflows/pythonpublish-win.yml | 54 ---------- meson.build | 4 +- 5 files changed, 120 insertions(+), 211 deletions(-) create mode 100644 .github/workflows/build_wheels.yml delete mode 100644 .github/workflows/pythonpublish-linux.yml delete mode 100644 .github/workflows/pythonpublish-osx.yml delete mode 100644 .github/workflows/pythonpublish-win.yml diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml new file mode 100644 index 0000000..3093d5f --- /dev/null +++ b/.github/workflows/build_wheels.yml @@ -0,0 +1,119 @@ +name: GH Actions + +on: + release: + types: [published] + push: + pull_request: + +env: + PYSIDE_VERSION: 6.6.2 + PIP_EXTRA_INDEX_URL: "https://download.qt.io/official_releases/QtForPython/" + +jobs: + build_sdist: + name: Build source distribution + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Build sdist + run: | + sudo apt update && sudo apt install -y libgl-dev + pip install aqtinstall + aqt install-qt -O "$GITHUB_WORKSPACE"/Qt linux desktop ${{ env.PYSIDE_VERSION }} + PATH="$GITHUB_WORKSPACE"/Qt/${{ env.PYSIDE_VERSION }}/gcc_64/bin:$PATH" LD_LIBRARY_PATH="$GITHUB_WORKSPACE"/Qt/${{ env.PYSIDE_VERSION }}/gcc_64/lib:$LD_LIBRARY_PATH" pipx run build --sdist + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: cibw-sdist + path: dist/*.tar.gz + + build_wheels: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + include: + - os: ubuntu-latest + arch: x86_64 + #- os: windows-latest + # arch: x86_64 + - os: macos-13 # Intel + arch: x86_64 + - os: macos-14 # Apple Silicon + arch: arm64 + steps: + - uses: ilammy/msvc-dev-cmd@v1 + if: runner.os == 'Windows' + with: + arch: amd64 + - uses: actions/checkout@v4 + - name: Forward GITHUB_WORKSPACE env var + shell: bash + run: | + echo "GITHUB_WORKSPACE=$GITHUB_WORKSPACE" >> $GITHUB_ENV + - name: Build wheels + uses: pypa/cibuildwheel@v2.16.5 + env: + PYSIDE_VERSION: ${{ env.PYSIDE_VERSION }} + PIP_EXTRA_INDEX_URL: ${{ env.PIP_EXTRA_INDEX_URL }} + CIBW_ENVIRONMENT_WINDOWS: PYSIDE_VERSION=${{ env.PYSIDE_VERSION }} PIP_EXTRA_INDEX_URL=${{ env.PIP_EXTRA_INDEX_URL }} PATH="${GITHUB_WORKSPACE}\\Qt\\${{ env.PYSIDE_VERSION }}\\msvc2019_64\\bin;$PATH" + CIBW_ENVIRONMENT_MACOS: PYSIDE_VERSION=${{ env.PYSIDE_VERSION }} MACOSX_DEPLOYMENT_TARGET='11.0' PATH=${{ env.GITHUB_WORKSPACE }}/Qt/${{ env.PYSIDE_VERSION }}/macos/bin:$PATH + CIBW_ENVIRONMENT_LINUX: PYSIDE_VERSION=${{ env.PYSIDE_VERSION }} PIP_EXTRA_INDEX_URL=${{ env.PIP_EXTRA_INDEX_URL }} PATH=${{ env.GITHUB_WORKSPACE }}/Qt/${{ env.PYSIDE_VERSION }}/gcc_64/bin:$PATH LD_LIBRARY_PATH=${{ env.GITHUB_WORKSPACE }}/Qt/${{ env.PYSIDE_VERSION }}/gcc_64/lib:$LD_LIBRARY_PATH + CIBW_BEFORE_BUILD_WINDOWS: > + pip install "aqtinstall" + && aqt install-qt -O ${{ env.GITHUB_WORKSPACE }}\\Qt windows desktop ${{ env.PYSIDE_VERSION }} win64_msvc2019_64 + CIBW_BEFORE_BUILD_MACOS: > + pip install "aqtinstall" + && aqt install-qt -O "${{ env.GITHUB_WORKSPACE }}/Qt" mac desktop ${{ env.PYSIDE_VERSION }} + CIBW_BEFORE_BUILD_LINUX: > + dnf install -y /usr/lib64/libxkbcommon.so.0 /usr/lib64/libxslt.so.1 /usr/bin/llvm-config clang + && pip install "aqtinstall" && aqt install-qt -O "${{ env.GITHUB_WORKSPACE }}/Qt" linux desktop ${{ env.PYSIDE_VERSION }} + CIBW_REPAIR_WHEEL_COMMAND_LINUX: > + auditwheel repair -w {dest_dir} --only-plat --plat manylinux_2_28_x86_64 {wheel} + CIBW_REPAIR_WHEEL_COMMAND_MACOS: + CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 + CIBW_SKIP: "*-win32 *i686 *38-macosx* pp*" + CIBW_BUILD_VERBOSITY: 3 + CIBW_ARCH: ${{ matrix.arch }} + + - uses: actions/upload-artifact@v4 + with: + name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} + path: ./wheelhouse/*.whl + + + upload_pypi: + needs: [build_sdist, build_wheels] + runs-on: ubuntu-latest + # upload to PyPI only on github releases + if: github.event_name == 'release' && github.event.action == 'published' && github.repository_owner == 'SciQLop' + steps: + - uses: actions/download-artifact@v4 + with: + pattern: cibw-* + path: dist + merge-multiple: true + - uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.PYPI_PASSWORD }} + skip-existing: true + + upload_test_pypi: + needs: [build_sdist, build_wheels] + runs-on: ubuntu-latest + # upload to test PyPI on github pushes + if: github.event_name == 'push' && github.repository_owner == 'SciQLop' + steps: + - uses: actions/download-artifact@v4 + with: + pattern: cibw-* + path: dist + merge-multiple: true + - uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.PYPI_TEST_PASSWORD }} + repository-url: https://test.pypi.org/legacy/ + skip-existing: true diff --git a/.github/workflows/pythonpublish-linux.yml b/.github/workflows/pythonpublish-linux.yml deleted file mode 100644 index f2edbaf..0000000 --- a/.github/workflows/pythonpublish-linux.yml +++ /dev/null @@ -1,54 +0,0 @@ -name: Python packages linux - -on: - release: - types: [published] - push: - -jobs: - build: - name: build python packages - runs-on: ubuntu-latest - container: quay.io/pypa/manylinux_2_28_x86_64 - strategy: - fail-fast: false - matrix: - python-version: ['cp38-cp38', 'cp39-cp39', 'cp310-cp310', 'cp311-cp311', 'cp312-cp312'] - pyside_ver: ['6.6.2'] - steps: - - name: add Python and qt dir to path - run: | - echo "/opt/python/${{ matrix.python-version }}/bin" >> $GITHUB_PATH - echo "/Qt/${{ matrix.pyside_ver }}/gcc_64/bin" >> $GITHUB_PATH - - uses: actions/checkout@v4 - with: - submodules: true - - name: Build for Python ${{ matrix.python-version }} - run: | - dnf install -y /usr/lib64/libxkbcommon.so.0 /usr/lib64/libxslt.so.1 /usr/bin/llvm-config clang - git config --global --add safe.directory '*' - python -m pip install --upgrade "pip" "meson" "ninja" "numpy" "meson-python>=0.14.0" "build" "wheel" "twine" "auditwheel" "aqtinstall" - python -m pip install "PySide6==${{ matrix.pyside_ver }}" - python -m pip install \ - --index-url=http://download.qt.io/official_releases/QtForPython/ \ - --trusted-host download.qt.io \ - "shiboken6_generator==${{ matrix.pyside_ver }}" - aqt install-qt -O /Qt linux desktop ${{ matrix.pyside_ver }} - LD_LIBRARY_PATH=/Qt/${{ matrix.pyside_ver }}/gcc_64/lib python3 -m build --wheel --no-isolation . - rename 'linux_x86_64' 'manylinux_2_28_x86_64' dist/*.whl - - name: Save packages as artifacts - uses: actions/upload-artifact@v3 - with: - name: sciqlopplots-linux-${{ matrix.python-version }} - path: dist/* - - name: Publish on PyPi - if: github.event.release - env: - TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: twine upload --skip-existing dist/* - - name: Publish on PyPi (test) - env: - TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.PYPI_TEST_PASSWORD }} - run: twine upload --repository testpypi --skip-existing dist/* diff --git a/.github/workflows/pythonpublish-osx.yml b/.github/workflows/pythonpublish-osx.yml deleted file mode 100644 index d193fb8..0000000 --- a/.github/workflows/pythonpublish-osx.yml +++ /dev/null @@ -1,100 +0,0 @@ -name: Python packages OSX - -on: - release: - types: [published] - push: - -jobs: - build_macos_x86: - runs-on: macos-11 - strategy: - max-parallel: 4 - matrix: - python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] - pyside_ver: ['6.6.2'] - name: Python ${{ matrix.python-version }} - steps: - - uses: actions/checkout@v4 - - name: Build python wheel - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - architecture: x64 - - name: add qt dir to path - run: | - echo "$GITHUB_WORKSPACE/Qt/${{ matrix.pyside_ver }}/macos/bin" >> $GITHUB_PATH - - name: install dependencies - run: | - pip install --upgrade "meson" "ninja" "numpy" "meson-python>=0.14.0" "build" "wheel" "twine" "aqtinstall" - pip install "PySide6==${{ matrix.pyside_ver }}" - pip install \ - --index-url=http://download.qt.io/official_releases/QtForPython/ \ - --trusted-host download.qt.io "shiboken6_generator==${{ matrix.pyside_ver }}" - aqt install-qt -O $GITHUB_WORKSPACE/Qt mac desktop ${{ matrix.pyside_ver }} - - name: build package - run: | - python3 -m build --wheel --no-isolation . - - name: Save packages as artifacts - uses: actions/upload-artifact@v3 - with: - name: sciqlopplots-MacOs-x86-${{ matrix.python-version }} - path: dist/* - - name: Publish on PyPi - if: github.event.release - env: - TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: twine upload --skip-existing dist/* - - name: Publish on PyPi (test) - env: - TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.PYPI_TEST_PASSWORD }} - run: twine upload --repository testpypi --skip-existing dist/*.whl - - build_macos_arm: - strategy: - matrix: - python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] - pyside_ver: ['6.6.2'] - runs-on: self-hosted - steps: - - uses: actions/checkout@v4 - - name: add pyenv to path - run: | - echo "$HOME/.pyenv/shims" >> $GITHUB_PATH - - name: add qt dir to path - run: | - echo "$GITHUB_WORKSPACE/Qt/${{ matrix.pyside_ver }}/macos/bin" >> $GITHUB_PATH - - name: install dependencies - run: | - brew install pyenv - pyenv install ${{ matrix.python-version }} - pyenv local ${{ matrix.python-version }} - python3 -m pip install meson numpy ninja build wheel twine meson-python>=0.14.0 - pip install --upgrade "meson" "ninja" "numpy" "meson-python>=0.14.0" "build" "wheel" "twine" "aqtinstall" - pip install "PySide6==${{ matrix.pyside_ver }}" - pip install \ - --index-url=http://download.qt.io/official_releases/QtForPython/ \ - --trusted-host download.qt.io "shiboken6_generator==${{ matrix.pyside_ver }}" - aqt install-qt -O $GITHUB_WORKSPACE/Qt mac desktop ${{ matrix.pyside_ver }} - - name: build package - run: | - pyenv local ${{ matrix.python-version }} - python3 -m build --wheel --no-isolation . - - name: Save packages as artifacts - uses: actions/upload-artifact@v3 - with: - name: sciqlopplots-MacOs-arm-${{ matrix.python-version }} - path: dist/* - - name: Publish on PyPi - if: github.event.release - env: - TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: twine upload --skip-existing dist/* - - name: Publish on PyPi (test) - env: - TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.PYPI_TEST_PASSWORD }} - run: twine upload --repository testpypi --skip-existing dist/*.whl diff --git a/.github/workflows/pythonpublish-win.yml b/.github/workflows/pythonpublish-win.yml deleted file mode 100644 index e61ff7e..0000000 --- a/.github/workflows/pythonpublish-win.yml +++ /dev/null @@ -1,54 +0,0 @@ -name: Python packages Windows - -on: - release: - types: [published] - push: - -jobs: - build: - runs-on: windows-latest - strategy: - max-parallel: 4 - matrix: - python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] - pyside_ver: ['6.6.2'] - name: Python ${{ matrix.python-version }} - steps: - - uses: actions/checkout@v4 - - name: add qt dir to path - run: | - echo "${{github.workspace}}\Qt\${{ matrix.pyside_ver }}\msvc2019_64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - - name: Set python interpreter - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - architecture: x64 - - uses: ilammy/msvc-dev-cmd@v1 - with: - arch: amd64 - - name: Install deps - run: | - pip install --upgrade "meson" "ninja" "numpy" "meson-python>=0.14.0" "build" "wheel" "twine" "auditwheel" "aqtinstall" - pip install "PySide6==${{ matrix.pyside_ver }}" - pip install --index-url=http://download.qt.io/official_releases/QtForPython/ --trusted-host download.qt.io "shiboken6_generator==${{ matrix.pyside_ver }}" - aqt install-qt -O $env:GITHUB_WORKSPACE\Qt windows desktop ${{ matrix.pyside_ver }} win64_msvc2019_64 - - name: Build package - run: | - python3 -m build --wheel --no-isolation . - - name: Save packages as artifacts - uses: actions/upload-artifact@v3 - with: - name: sciqlopplots-windows-${{ matrix.python-version }} - path: dist/* - - name: Publish on PyPi - if: github.event.release - env: - TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: twine upload --skip-existing dist/* - - name: Publish on PyPi (test) - env: - TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.PYPI_TEST_PASSWORD }} - run: twine upload --repository testpypi --skip-existing dist/*.whl diff --git a/meson.build b/meson.build index 3f8bb1b..ae01ab0 100644 --- a/meson.build +++ b/meson.build @@ -9,9 +9,7 @@ qt_sdk='qt6' extra_files=files( 'pyproject.toml', 'setup.cfg', - '.github/workflows/pythonpublish-linux.yml', - '.github/workflows/pythonpublish-win.yml', - '.github/workflows/pythonpublish-osx.yml', + '.github/workflows/build_wheels.yml', 'README.md', 'COPYING' )