diff --git a/.github/workflows/macos-macports-wheels-build.yml b/.github/workflows/macos-macports-wheels-build.yml index 4af8143503..771477f032 100644 --- a/.github/workflows/macos-macports-wheels-build.yml +++ b/.github/workflows/macos-macports-wheels-build.yml @@ -2,14 +2,23 @@ name: macos-macports-wheels-build on: [push, pull_request] jobs: macos: - name: Talipot Python wheels build on macOS - runs-on: macos-12 + name: ${{ matrix.config.name }} + runs-on: ${{ matrix.config.os }} + strategy: + fail-fast: false + matrix: + config: + - name: Talipot wheels build on macOS x86_64 + os: macos-12 + - name: Talipot wheels build on macOS arm64 + os: macos-14 env: CLANG_VERSION: 16 MACOSX_DEPLOYMENT_TARGET: "12.0" TWINE_REPOSITORY: https://test.pypi.org/legacy/ TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }} + steps: - name: Cancel Previous Runs uses: styfle/cancel-workflow-action@0.12.1 @@ -77,11 +86,14 @@ jobs: graphviz - name: Install Python versions to build wheels against run: | - curl -LO https://www.python.org/ftp/python/3.9.0/python-3.9.0-macosx10.9.pkg - sudo installer -pkg python-3.9.0-macosx10.9.pkg -target / - sudo /Library/Frameworks/Python.framework/Versions/3.9/bin/pip3 install wheel - curl -LO https://www.python.org/ftp/python/3.10.0/python-3.10.0post2-macos11.pkg - sudo installer -pkg python-3.10.0post2-macos11.pkg -target / + os_ver=$(sw_vers -productVersion | cut -c1-2) + if [[ $os_ver -lt 13 ]]; then + curl -LO https://www.python.org/ftp/python/3.9.0/python-3.9.0-macosx10.9.pkg + sudo installer -pkg python-3.9.0-macosx10.9.pkg -target / + sudo /Library/Frameworks/Python.framework/Versions/3.9/bin/pip3 install wheel + fi + curl -LO https://www.python.org/ftp/python/3.10.10/python-3.10.10-macos11.pkg + sudo installer -pkg python-3.10.10-macos11.pkg -target / sudo /Library/Frameworks/Python.framework/Versions/3.10/bin/pip3 install wheel curl -LO https://www.python.org/ftp/python/3.11.0/python-3.11.0-macos11.pkg sudo installer -pkg python-3.11.0-macos11.pkg -target / @@ -97,7 +109,13 @@ jobs: - name: Build Talipot Python wheels working-directory: ./build run: | - for py3Version in 3.9 3.10 3.11 3.12 3.13 + os_ver=$(sw_vers -productVersion | cut -c1-2) + if [[ $os_ver -lt 13 ]]; then + py3Versions="3.9 3.10 3.11 3.12 3.13" + else + py3Versions="3.10 3.11 3.12 3.13" + fi + for py3Version in $py3Versions do rm -f CMakeCache.txt || true sudo /Library/Frameworks/Python.framework/Versions/$py3Version/bin/pip3 install sip @@ -120,6 +138,7 @@ jobs: - name: Test uploaded wheels in clean environment if: github.ref == 'refs/tags/dev-latest' run: | + os_ver=$(sw_vers -productVersion | cut -c1-2) sudo port -N -f uninstall \ cmake \ clang-${CLANG_VERSION} \ @@ -140,9 +159,11 @@ jobs: python313 \ py313-pip - sudo pip-3.9 install --index-url https://test.pypi.org/simple/ talipot - python3.9 -c "from talipot import tlp; print(tlp.getLayoutAlgorithmPluginsList())" - python3.9 -c "from talipot import tlp; print(tlp.getImportPluginsList())" + if [[ $os_ver -lt 13 ]]; then + sudo pip-3.9 install --index-url https://test.pypi.org/simple/ talipot + python3.9 -c "from talipot import tlp; print(tlp.getLayoutAlgorithmPluginsList())" + python3.9 -c "from talipot import tlp; print(tlp.getImportPluginsList())" + fi sudo pip-3.10 install --index-url https://test.pypi.org/simple/ talipot python3.10 -c "from talipot import tlp; print(tlp.getLayoutAlgorithmPluginsList())" diff --git a/library/talipot-python/bindings/talipot-core/packaging/setup.py.in b/library/talipot-python/bindings/talipot-core/packaging/setup.py.in index 2988f43461..93364f96ad 100644 --- a/library/talipot-python/bindings/talipot-core/packaging/setup.py.in +++ b/library/talipot-python/bindings/talipot-core/packaging/setup.py.in @@ -11,6 +11,9 @@ import subprocess import sys import shutil +from wheel.bdist_wheel import bdist_wheel +from wheel._bdist_wheel get_platform + # On MacOS, we need to relink dylibs and set correct rpaths in # order for the modules to be imported in a portable way when # distributed through pip @@ -111,6 +114,17 @@ elif platform.system() == 'Linux': talipot_native_libs = ['native/*.so*', 'native/plugins/*.so', 'native/graphviz/*.so'] + +class CustomWheel(bdist_wheel): + """Override platform tags when building a wheel.""" + + def finalize_options(self): + platform_name = get_platform("_") + if "universal2" in platform_name: + self.plat_name = platform_name.replace("universal2", platform.uname().machine) + + + here = path.abspath(path.dirname(__file__)) with open(path.join(here, 'README.rst'), encoding='utf-8') as f: @@ -183,4 +197,5 @@ setup( include_package_data=True, distclass=BinaryDistribution, + cmdclass={"bdist_wheel": CustomWheel}, )