From b1917ab3fdf2855abf667a862733cf1aa71ca689 Mon Sep 17 00:00:00 2001 From: Vincent Rouvreau <10407034+VincentRouvreau@users.noreply.github.com> Date: Fri, 14 Apr 2023 13:31:35 +0200 Subject: [PATCH] Update pip build/package strategy to fix numpy compatibility (#867) * Test with docker pip_for_gudhi:3.8.0rc3. Use minimal python version to build gudhi and upgrade to test * Typo in matrix variables * Fix minimal numpy version * Better use of ~= and some comments. Add some tests for pip packages * osx x86 and arm numpy version stable from 1.21.4 * activate pytest verbosity and fix osx. Release candidate 3 * Get Dockerfile_for_pip old_numpy_pip_build feature from gudhi-deploy submodule * Try to fix weird looking project description - cf. https://pypi.org/project/gudhi/3.8.0rc2/ * Build only python 3.6 for linux, 3.7 for windows and 3.8 for osx --- .github/workflows/pip-build-linux.yml | 26 ++++++++------- .github/workflows/pip-build-osx.yml | 18 ++++++++--- .github/workflows/pip-build-windows.yml | 12 +++++-- .github/workflows/pip-packaging-linux.yml | 36 +++++++++++++++++---- .github/workflows/pip-packaging-osx.yml | 22 +++++++++++-- .github/workflows/pip-packaging-windows.yml | 20 +++++++++++- CMakeGUDHIVersion.txt | 2 +- ext/gudhi-deploy | 2 +- src/python/CMakeLists.txt | 2 +- 9 files changed, 110 insertions(+), 30 deletions(-) diff --git a/.github/workflows/pip-build-linux.yml b/.github/workflows/pip-build-linux.yml index 76852ceff2..f4441e3e20 100644 --- a/.github/workflows/pip-build-linux.yml +++ b/.github/workflows/pip-build-linux.yml @@ -12,23 +12,25 @@ jobs: - uses: actions/checkout@v3 with: submodules: true - - name: Build wheel for Python 3.11 + - name: Build wheel for Python 3.6 run: | - mkdir build_311 - cd build_311 - cmake -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=$PYTHON311/bin/python .. + mkdir build_36 + cd build_36 + cmake -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=$PYTHON36/bin/python .. cd src/python - $PYTHON311/bin/python -m build -n -w - auditwheel show dist/*.whl + $PYTHON36/bin/python -m build -n -w auditwheel repair dist/*.whl - ls wheelhouse/*.whl - - name: Install and test wheel for Python 3.11 + - name: Install and test wheel for Python 3.6 run: | - $PYTHON311/bin/python -m pip install --user pytest build_311/src/python/wheelhouse/*.whl - $PYTHON311/bin/python -c "import gudhi; print(gudhi.__version__)" - $PYTHON311/bin/python -m pytest src/python/test/test_alpha_complex.py + $PYTHON36/bin/python -m pip install --user pytest build_36/src/python/dist/*.whl + $PYTHON36/bin/python -m pip install numpy --upgrade + $PYTHON36/bin/python -c "import gudhi; print(gudhi.__version__)" + $PYTHON36/bin/python -m pytest -v src/python/test/test_alpha_complex.py + $PYTHON36/bin/python -m pytest -v src/python/test/test_bottleneck_distance.py + $PYTHON36/bin/python -m pytest -v src/python/test/test_cubical_complex.py + $PYTHON36/bin/python -m pytest -v src/python/test/test_rips_complex.py - name: Upload linux python wheel uses: actions/upload-artifact@v3 with: name: linux python wheel - path: build_311/src/python/wheelhouse/*.whl + path: build_36/src/python/wheelhouse/*.whl diff --git a/.github/workflows/pip-build-osx.yml b/.github/workflows/pip-build-osx.yml index b01b9a3f22..c2c38cfc50 100644 --- a/.github/workflows/pip-build-osx.yml +++ b/.github/workflows/pip-build-osx.yml @@ -3,8 +3,8 @@ name: pip build osx on: [push, pull_request] env: - MACOSX_DEPLOYMENT_TARGET: 10.14 - _PYTHON_HOST_PLATFORM: macosx-10.14-universal2 + MACOSX_DEPLOYMENT_TARGET: 10.15 + _PYTHON_HOST_PLATFORM: macosx-10.15-universal2 ARCHFLAGS: "-arch arm64 -arch x86_64" jobs: @@ -13,7 +13,12 @@ jobs: strategy: max-parallel: 4 matrix: - python-version: ['3.11'] + # numpy packages for osx x86 and arm are only available from 1.21.2, but stable for both versions from 1.21.4 + # and python 3.8+ + python-version: ['3.8'] + include: + - python-version: '3.8' + numpy-version: '1.21.4' name: Build wheels for Python ${{ matrix.python-version }} steps: - uses: actions/checkout@v3 @@ -27,6 +32,7 @@ jobs: run: | brew update || true brew install boost eigen gmp mpfr cgal || true + python -m pip install --user numpy~=${{ matrix.numpy-version }} python -m pip install --user -r ext/gudhi-deploy/build-requirements.txt python -m pip install --user delocate ./scripts/build_osx_universal_gmpfr.sh @@ -46,9 +52,13 @@ jobs: delocate-wheel --require-archs universal2 -v dist/*.whl - name: Install and test python wheel run: | + python -m pip install --user numpy --upgrade python -m pip install --user pytest build/src/python/dist/*.whl python -c "import gudhi; print(gudhi.__version__)" - python -m pytest src/python/test/test_alpha_complex.py + python -m pytest -v src/python/test/test_alpha_complex.py + python -m pytest -v src/python/test/test_bottleneck_distance.py + python -m pytest -v src/python/test/test_cubical_complex.py + python -m pytest -v src/python/test/test_rips_complex.py - name: Upload OSx python wheel uses: actions/upload-artifact@v3 with: diff --git a/.github/workflows/pip-build-windows.yml b/.github/workflows/pip-build-windows.yml index f025772b0d..fcb1ab8bb5 100644 --- a/.github/workflows/pip-build-windows.yml +++ b/.github/workflows/pip-build-windows.yml @@ -8,7 +8,10 @@ jobs: strategy: max-parallel: 4 matrix: - python-version: ['3.11'] + python-version: ['3.7'] + include: + - python-version: '3.7' + numpy-version: '1.15.0' name: Build wheels for Python ${{ matrix.python-version }} steps: - uses: actions/checkout@v3 @@ -24,6 +27,7 @@ jobs: vcpkg install eigen3 cgal --triplet x64-windows vcpkg version ls "C:\vcpkg\installed\x64-windows\bin\" + python -m pip install --user numpy~=${{ matrix.numpy-version }} python -m pip install --user -r .\ext\gudhi-deploy\build-requirements.txt - name: Build python wheel and install it run: | @@ -41,9 +45,13 @@ jobs: run: | Get-Location dir + python -m pip install --user numpy --upgrade python -m pip install --user pytest python -c "import gudhi; print(gudhi.__version__)" - python -m pytest ".\src\python\test\test_alpha_complex.py" + python -m pytest -v ".\src\python\test\test_alpha_complex.py" + python -m pytest -v ".\src\python\test\test_bottleneck_distance.py" + python -m pytest -v ".\src\python\test\test_cubical_complex.py" + python -m pytest -v ".\src\python\test\test_rips_complex.py" - name: Upload Windows python wheel uses: actions/upload-artifact@v3 with: diff --git a/.github/workflows/pip-packaging-linux.yml b/.github/workflows/pip-packaging-linux.yml index 3ee0e146ac..8744aaece2 100644 --- a/.github/workflows/pip-packaging-linux.yml +++ b/.github/workflows/pip-packaging-linux.yml @@ -25,8 +25,12 @@ jobs: - name: Install and test wheel for Python 3.6 run: | $PYTHON36/bin/python -m pip install --user pytest build_36/src/python/dist/*.whl + $PYTHON36/bin/python -m pip install numpy --upgrade $PYTHON36/bin/python -c "import gudhi; print(gudhi.__version__)" - $PYTHON36/bin/python -m pytest src/python/test/test_alpha_complex.py + $PYTHON36/bin/python -m pytest -v src/python/test/test_alpha_complex.py + $PYTHON36/bin/python -m pytest -v src/python/test/test_bottleneck_distance.py + $PYTHON36/bin/python -m pytest -v src/python/test/test_cubical_complex.py + $PYTHON36/bin/python -m pytest -v src/python/test/test_rips_complex.py - name: Build wheel for Python 3.7 run: | mkdir build_37 @@ -38,8 +42,12 @@ jobs: - name: Install and test wheel for Python 3.7 run: | $PYTHON37/bin/python -m pip install --user pytest build_37/src/python/dist/*.whl + $PYTHON37/bin/python -m pip install numpy --upgrade $PYTHON37/bin/python -c "import gudhi; print(gudhi.__version__)" - $PYTHON37/bin/python -m pytest src/python/test/test_alpha_complex.py + $PYTHON37/bin/python -m pytest -v src/python/test/test_alpha_complex.py + $PYTHON37/bin/python -m pytest -v src/python/test/test_bottleneck_distance.py + $PYTHON37/bin/python -m pytest -v src/python/test/test_cubical_complex.py + $PYTHON37/bin/python -m pytest -v src/python/test/test_rips_complex.py - name: Build wheel for Python 3.8 run: | mkdir build_38 @@ -51,8 +59,12 @@ jobs: - name: Install and test wheel for Python 3.8 run: | $PYTHON38/bin/python -m pip install --user pytest build_38/src/python/dist/*.whl + $PYTHON38/bin/python -m pip install numpy --upgrade $PYTHON38/bin/python -c "import gudhi; print(gudhi.__version__)" - $PYTHON38/bin/python -m pytest src/python/test/test_alpha_complex.py + $PYTHON38/bin/python -m pytest -v src/python/test/test_alpha_complex.py + $PYTHON38/bin/python -m pytest -v src/python/test/test_bottleneck_distance.py + $PYTHON38/bin/python -m pytest -v src/python/test/test_cubical_complex.py + $PYTHON38/bin/python -m pytest -v src/python/test/test_rips_complex.py - name: Build wheel for Python 3.9 run: | mkdir build_39 @@ -64,8 +76,12 @@ jobs: - name: Install and test wheel for Python 3.9 run: | $PYTHON39/bin/python -m pip install --user pytest build_39/src/python/dist/*.whl + $PYTHON39/bin/python -m pip install numpy --upgrade $PYTHON39/bin/python -c "import gudhi; print(gudhi.__version__)" - $PYTHON39/bin/python -m pytest src/python/test/test_alpha_complex.py + $PYTHON39/bin/python -m pytest -v src/python/test/test_alpha_complex.py + $PYTHON39/bin/python -m pytest -v src/python/test/test_bottleneck_distance.py + $PYTHON39/bin/python -m pytest -v src/python/test/test_cubical_complex.py + $PYTHON39/bin/python -m pytest -v src/python/test/test_rips_complex.py - name: Build wheel for Python 3.10 run: | mkdir build_310 @@ -77,8 +93,12 @@ jobs: - name: Install and test wheel for Python 3.10 run: | $PYTHON310/bin/python -m pip install --user pytest build_310/src/python/dist/*.whl + $PYTHON310/bin/python -m pip install numpy --upgrade $PYTHON310/bin/python -c "import gudhi; print(gudhi.__version__)" - $PYTHON310/bin/python -m pytest src/python/test/test_alpha_complex.py + $PYTHON310/bin/python -m pytest -v src/python/test/test_alpha_complex.py + $PYTHON310/bin/python -m pytest -v src/python/test/test_bottleneck_distance.py + $PYTHON310/bin/python -m pytest -v src/python/test/test_cubical_complex.py + $PYTHON310/bin/python -m pytest -v src/python/test/test_rips_complex.py - name: Build wheel for Python 3.11 run: | mkdir build_311 @@ -90,8 +110,12 @@ jobs: - name: Install and test wheel for Python 3.11 run: | $PYTHON311/bin/python -m pip install --user pytest build_311/src/python/dist/*.whl + $PYTHON311/bin/python -m pip install numpy --upgrade $PYTHON311/bin/python -c "import gudhi; print(gudhi.__version__)" - $PYTHON311/bin/python -m pytest src/python/test/test_alpha_complex.py + $PYTHON311/bin/python -m pytest -v src/python/test/test_alpha_complex.py + $PYTHON311/bin/python -m pytest -v src/python/test/test_bottleneck_distance.py + $PYTHON311/bin/python -m pytest -v src/python/test/test_cubical_complex.py + $PYTHON311/bin/python -m pytest -v src/python/test/test_rips_complex.py - name: Publish on PyPi env: TWINE_USERNAME: __token__ diff --git a/.github/workflows/pip-packaging-osx.yml b/.github/workflows/pip-packaging-osx.yml index c9453664f6..782ff69fd1 100644 --- a/.github/workflows/pip-packaging-osx.yml +++ b/.github/workflows/pip-packaging-osx.yml @@ -15,7 +15,20 @@ jobs: strategy: max-parallel: 4 matrix: - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] + # numpy packages for osx x86 and arm are only available from 1.21.2, but stable for both versions from 1.21.4 + # and python 3.8+ + python-version: ['3.8', '3.9', '3.10', '3.11'] + include: + # numpy >= 1.21.4 fort osx x86 and arm, but minimal numpy version for python 3.10 is 1.21.6 for instance + # numpy~=1.21.6 means any numpy=1.21.*, but also numpy>=1.21.6 (numpy~=1.21 do not work as it means any numpy==1.*) + - python-version: '3.8' + numpy-version: '1.21.4' + - python-version: '3.9' + numpy-version: '1.21.4' + - python-version: '3.10' + numpy-version: '1.21.6' + - python-version: '3.11' + numpy-version: '1.23.2' name: Build wheels for Python ${{ matrix.python-version }} steps: - uses: actions/checkout@v3 @@ -29,6 +42,7 @@ jobs: run: | brew update || true brew install boost eigen gmp mpfr cgal || true + python -m pip install --user numpy~=${{ matrix.numpy-version }} python -m pip install --user -r ext/gudhi-deploy/build-requirements.txt python -m pip install --user twine delocate ./scripts/build_osx_universal_gmpfr.sh @@ -46,9 +60,13 @@ jobs: python -m build -n -w - name: Install and test python wheel run: | + python -m pip install --user numpy --upgrade python -m pip install --user pytest build/src/python/dist/*.whl python -c "import gudhi; print(gudhi.__version__)" - python -m pytest src/python/test/test_alpha_complex.py + python -m pytest -v src/python/test/test_alpha_complex.py + python -m pytest -v src/python/test/test_bottleneck_distance.py + python -m pytest -v src/python/test/test_cubical_complex.py + python -m pytest -v src/python/test/test_rips_complex.py - name: Publish on PyPi env: TWINE_USERNAME: __token__ diff --git a/.github/workflows/pip-packaging-windows.yml b/.github/workflows/pip-packaging-windows.yml index 15ce859bc5..0d01e42114 100644 --- a/.github/workflows/pip-packaging-windows.yml +++ b/.github/workflows/pip-packaging-windows.yml @@ -11,6 +11,19 @@ jobs: max-parallel: 4 matrix: python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] + # gudhi requires numpy >= 1.15.0, but minimal numpy version for python 3.8 is 1.17.3 for instance + # numpy~=1.17.3 means any numpy=1.17.*, but also numpy>=1.17.3 (numpy~=1.17 do not work as it means any numpy==1.*) + include: + - python-version: '3.7' + numpy-version: '1.15.0' + - python-version: '3.8' + numpy-version: '1.17.3' + - python-version: '3.9' + numpy-version: '1.19.3' + - python-version: '3.10' + numpy-version: '1.21.6' + - python-version: '3.11' + numpy-version: '1.23.2' name: Build wheels for Python ${{ matrix.python-version }} steps: - uses: actions/checkout@v3 @@ -26,6 +39,7 @@ jobs: vcpkg install eigen3 cgal --triplet x64-windows vcpkg version ls "C:\vcpkg\installed\x64-windows\bin\" + python -m pip install --user numpy~=${{ matrix.numpy-version }} python -m pip install --user -r .\ext\gudhi-deploy\build-requirements.txt python -m pip install --user twine python -m pip list @@ -43,9 +57,13 @@ jobs: Get-ChildItem *.whl | ForEach-Object{python -m pip install --user $_.Name} - name: Test python wheel run: | + python -m pip install --user numpy --upgrade python -m pip install --user pytest python -c "import gudhi; print(gudhi.__version__)" - python -m pytest ".\src\python\test\test_alpha_complex.py" + python -m pytest -v ".\src\python\test\test_alpha_complex.py" + python -m pytest -v ".\src\python\test\test_bottleneck_distance.py" + python -m pytest -v ".\src\python\test\test_cubical_complex.py" + python -m pytest -v ".\src\python\test\test_rips_complex.py" - name: Publish on PyPi env: TWINE_USERNAME: __token__ diff --git a/CMakeGUDHIVersion.txt b/CMakeGUDHIVersion.txt index 0356fdd64b..e7bec4da46 100644 --- a/CMakeGUDHIVersion.txt +++ b/CMakeGUDHIVersion.txt @@ -2,7 +2,7 @@ set (GUDHI_MAJOR_VERSION 3) set (GUDHI_MINOR_VERSION 8) # GUDHI_PATCH_VERSION can be 'ZaN' for Alpha release, 'ZbN' for Beta release, 'ZrcN' for release candidate or 'Z' for a final release. -set (GUDHI_PATCH_VERSION 0rc2) +set (GUDHI_PATCH_VERSION 0rc3) set(GUDHI_VERSION ${GUDHI_MAJOR_VERSION}.${GUDHI_MINOR_VERSION}.${GUDHI_PATCH_VERSION}) message(STATUS "GUDHI version : ${GUDHI_VERSION}") diff --git a/ext/gudhi-deploy b/ext/gudhi-deploy index a466679f94..71728c2caa 160000 --- a/ext/gudhi-deploy +++ b/ext/gudhi-deploy @@ -1 +1 @@ -Subproject commit a466679f940afbc140af518e6d21a90e1a6580f7 +Subproject commit 71728c2caa8643005a682e9e180bd976b17f68a3 diff --git a/src/python/CMakeLists.txt b/src/python/CMakeLists.txt index 3e21c4f597..e047544ba1 100644 --- a/src/python/CMakeLists.txt +++ b/src/python/CMakeLists.txt @@ -293,7 +293,7 @@ if(PYTHONINTERP_FOUND) # Generate setup.py file to cythonize Gudhi - This file must be named setup.py by convention file(READ "introduction.rst" GUDHI_LONG_DESCRIPTION_WITH_UNPROPER_CR) - string(REPLACE "\n" "' \\\n '" GUDHI_LONG_DESCRIPTION ${GUDHI_LONG_DESCRIPTION_WITH_UNPROPER_CR}) + string(REPLACE "\n" "\\n' \\\n '" GUDHI_LONG_DESCRIPTION ${GUDHI_LONG_DESCRIPTION_WITH_UNPROPER_CR}) configure_file(setup.py.in "${CMAKE_CURRENT_BINARY_DIR}/setup.py" @ONLY) # Generate gudhi/__init__.py