From db480dab840b21550781eb2e4e66f2ea7a4f049c Mon Sep 17 00:00:00 2001 From: Matthias Wolf Date: Thu, 4 Jul 2024 09:24:17 +0200 Subject: [PATCH 1/4] Install ONE requirements file with all requirements. When installing NMODL requirements after the fixed numpy version, NMODLs lesser constrained dependencies take precedence over the currently installed packages. This PR: * Will consider only the build dependencies of NMODL * Construct one requirements file with the merged requirements of NMODL, NEURON --- packaging/python/build_requirements.txt | 6 +++++ packaging/python/build_wheels.bash | 35 ++++++++++++++----------- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/packaging/python/build_requirements.txt b/packaging/python/build_requirements.txt index dcbd639f9c..c92f711148 100644 --- a/packaging/python/build_requirements.txt +++ b/packaging/python/build_requirements.txt @@ -1,2 +1,8 @@ cython<3 packaging +numpy==1.17.5;python_version=='3.8' +numpy==1.19.3;python_version=='3.9' and platform_machine=='x86_64' +numpy==1.21.3;python_version=='3.9' and platform_machine=='arm64' +numpy==1.21.3;python_version=='3.10' +numpy==1.23.5;python_version=='3.11' +numpy==1.26.0;python_version=='3.12' diff --git a/packaging/python/build_wheels.bash b/packaging/python/build_wheels.bash index 8925b3e49f..10440b765d 100755 --- a/packaging/python/build_wheels.bash +++ b/packaging/python/build_wheels.bash @@ -28,7 +28,8 @@ py_ver="" clone_install_nmodl_requirements() { git config --global --add safe.directory /root/nrn git submodule update --init --recursive --force --depth 1 -- external/nmodl - pip install -r external/nmodl/requirements.txt + # We only want the _build_ dependencies + sed -e '/^# runtime dependencies/,$ d' external/nmodl/requirements.txt >> my_requirements.txt } @@ -52,12 +53,8 @@ setup_venv() { } -pip_numpy_install() { - # numpy is special as we want the minimum wheel version - numpy_ver="numpy" +python_version_check() { case "$py_ver" in - 36) numpy_ver="numpy==1.12.1" ;; - 37) numpy_ver="numpy==1.14.6" ;; 38) numpy_ver="numpy==1.17.5" ;; 39) numpy_ver="numpy==1.19.3" ;; 310) numpy_ver="numpy==1.21.3" ;; @@ -83,11 +80,7 @@ build_wheel_linux() { echo " - Installing build requirements" pip install auditwheel - pip install -r packaging/python/build_requirements.txt - pip_numpy_install - - echo " - Building..." - rm -rf dist build + cp packaging/python/build_requirements.txt my_requirements.txt CMAKE_DEFS="NRN_MPI_DYNAMIC=$3" if [ "$USE_STATIC_READLINE" == "1" ]; then @@ -100,6 +93,13 @@ build_wheel_linux() { CMAKE_DEFS="${CMAKE_DEFS},LINK_AGAINST_PYTHON=OFF" fi + cat my_requirements.txt + pip install -r my_requirements.txt + pip check + + echo " - Building..." + rm -rf dist build + # Workaround for https://github.com/pypa/manylinux/issues/1309 git config --global --add safe.directory "*" @@ -135,11 +135,7 @@ build_wheel_osx() { (( $skip )) && return 0 echo " - Installing build requirements" - pip install -U delocate -r packaging/python/build_requirements.txt - pip_numpy_install - - echo " - Building..." - rm -rf dist build + cp packaging/python/build_requirements.txt my_requirements.txt if [ "$2" == "coreneuron" ]; then setup_args="--enable-coreneuron" @@ -152,6 +148,13 @@ build_wheel_osx() { CMAKE_DEFS="$CMAKE_DEFS,NRN_BINARY_DIST_BUILD=ON,NRN_WHEEL_STATIC_READLINE=ON" fi + cat my_requirements.txt + pip install -U delocate -r my_requirements.txt + pip check + + echo " - Building..." + rm -rf dist build + # We need to "fix" the platform tag if the Python installer is universal2 # See: # * https://github.com/pypa/setuptools/issues/2520 From 2e96bfc1cbe788eaaf3957a8ba70e4ec968897f0 Mon Sep 17 00:00:00 2001 From: Matthias Wolf Date: Thu, 4 Jul 2024 10:32:13 +0200 Subject: [PATCH 2/4] Fully remove obsolete function. --- packaging/python/build_wheels.bash | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/packaging/python/build_wheels.bash b/packaging/python/build_wheels.bash index 10440b765d..f048f5b429 100755 --- a/packaging/python/build_wheels.bash +++ b/packaging/python/build_wheels.bash @@ -53,25 +53,6 @@ setup_venv() { } -python_version_check() { - case "$py_ver" in - 38) numpy_ver="numpy==1.17.5" ;; - 39) numpy_ver="numpy==1.19.3" ;; - 310) numpy_ver="numpy==1.21.3" ;; - 311) numpy_ver="numpy==1.23.5" ;; - 312) numpy_ver="numpy==1.26.0" ;; - *) echo "Error: numpy version not specified for this python!" && exit 1;; - esac - - # older version for apple m1 as building from source fails - if [[ `uname -m` == 'arm64' && "$py_ver" == "39" ]]; then - numpy_ver="numpy==1.21.3" - fi - - echo " - pip install $numpy_ver" - pip install $numpy_ver -} - build_wheel_linux() { echo "[BUILD WHEEL] Building with interpreter $1" local skip= From 233d9709a489256254fa3aef7248a51ad25b306f Mon Sep 17 00:00:00 2001 From: Matthias Wolf Date: Thu, 4 Jul 2024 10:33:21 +0200 Subject: [PATCH 3/4] Clarify function name. --- packaging/python/build_wheels.bash | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packaging/python/build_wheels.bash b/packaging/python/build_wheels.bash index f048f5b429..4da4f01f06 100755 --- a/packaging/python/build_wheels.bash +++ b/packaging/python/build_wheels.bash @@ -25,7 +25,7 @@ fi py_ver="" -clone_install_nmodl_requirements() { +clone_nmodl_and_add_requirements() { git config --global --add safe.directory /root/nrn git submodule update --init --recursive --force --depth 1 -- external/nmodl # We only want the _build_ dependencies @@ -70,7 +70,7 @@ build_wheel_linux() { if [ "$2" == "coreneuron" ]; then setup_args="--enable-coreneuron" - clone_install_nmodl_requirements + clone_nmodl_and_add_requirements CMAKE_DEFS="${CMAKE_DEFS},LINK_AGAINST_PYTHON=OFF" fi @@ -120,7 +120,7 @@ build_wheel_osx() { if [ "$2" == "coreneuron" ]; then setup_args="--enable-coreneuron" - clone_install_nmodl_requirements + clone_nmodl_and_add_requirements CMAKE_DEFS="${CMAKE_DEFS},LINK_AGAINST_PYTHON=OFF" fi From 470a4bc6601e64baed89e0044888b5bdf92738b1 Mon Sep 17 00:00:00 2001 From: Matthias Wolf Date: Thu, 4 Jul 2024 12:22:25 +0200 Subject: [PATCH 4/4] Try to pin setuptools for Win and Python 3.12 --- ci/win_install_deps.cmd | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ci/win_install_deps.cmd b/ci/win_install_deps.cmd index 2284b911c0..c75e977a10 100644 --- a/ci/win_install_deps.cmd +++ b/ci/win_install_deps.cmd @@ -28,7 +28,8 @@ C:\Python39\python.exe -m pip install numpy==1.19.3 "cython < 3" || goto :error C:\Python310\python.exe -m pip install numpy==1.21.3 "cython < 3" || goto :error C:\Python311\python.exe -m pip install numpy==1.23.5 "cython < 3" || goto :error C:\Python312\python.exe -m pip install numpy==1.26.3 "cython < 3" || goto :error -C:\Python312\python.exe -m pip install setuptools || goto :error +:: setuptools 70.2 leads to an error +C:\Python312\python.exe -m pip install setuptools==70.1.1 || goto :error :: install nsis nsis-3.05-setup.exe /S || goto :error