Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Backport 8.2: Python 3.13 support #3319

Draft
wants to merge 20 commits into
base: release/8.2
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
-e NRN_RELEASE_UPLOAD \
-e NEURON_WHEEL_VERSION \
-e NRN_BUILD_FOR_UPLOAD=1 \
'neuronsimulator/neuron_wheel:latest-gcc9-aarch64' \
'neuronsimulator/neuron_wheel:latest-aarch64' \
packaging/python/build_wheels.bash linux << parameters.NRN_PYTHON_VERSION >> coreneuron

- store_artifacts:
Expand All @@ -54,6 +54,8 @@ jobs:
39) pyenv_py_ver="3.9.1" ;;
310) pyenv_py_ver="3.10.1" ;;
311) pyenv_py_ver="3.11.0" ;;
312) pyenv_py_ver="3.12.0" ;;
313) pyenv_py_ver="3.13.1" ;;
*) echo "Error: pyenv python version not specified!" && exit 1;;
esac

Expand Down Expand Up @@ -110,5 +112,5 @@ workflows:
- manylinux2014-aarch64:
matrix:
parameters:
NRN_PYTHON_VERSION: ["37", "38", "39", "310", "311"]
NRN_PYTHON_VERSION: ["37", "38", "39", "310", "311", "312", "313"]
NRN_NIGHTLY_UPLOAD: ["true"]
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ on:

env:
PY_MIN_VERSION: '3.7'
PY_MAX_VERSION: '3.11'
PY_MAX_VERSION: '3.13'

jobs:
coverage:
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/neuron-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ env:
BUILD_TYPE: Release
DESIRED_CMAKE_VERSION: 3.15.0
PY_MIN_VERSION: '3.7'
PY_MAX_VERSION: '3.11'
PY_MAX_VERSION: '3.13'

jobs:
ci:
Expand All @@ -40,12 +40,12 @@ jobs:
BUILD_TYPE: Release
DESIRED_CMAKE_VERSION: 3.15.0
PY_MIN_VERSION: ${{ matrix.config.python_min_version || '3.8' }}
PY_MAX_VERSION: ${{ matrix.config.python_max_version || '3.11' }}
PY_MAX_VERSION: ${{ matrix.config.python_max_version || '3.12' }}
MUSIC_INSTALL_DIR: /opt/MUSIC

strategy:
matrix:
os: [ macOS-12, ubuntu-20.04]
os: [ macOS-13, ubuntu-20.04]
config:
- { matrix_eval : "CC=gcc-9 CXX=g++-9", build_mode: "setuptools"}
- { matrix_eval : "CC=gcc-8 CXX=g++-8", build_mode: "cmake", music: ON}
Expand Down Expand Up @@ -120,6 +120,7 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 2
submodules: recursive

- name: Set up Python@${{ env.PY_MIN_VERSION }}
if: ${{matrix.config.python_dynamic == 'ON'}}
Expand Down Expand Up @@ -148,15 +149,15 @@ jobs:
run: |
python3 -m venv music-venv
source music-venv/bin/activate
python3 -m pip install mpi4py "cython<3" "numpy<2"
python3 -m pip install mpi4py cython numpy
sudo mkdir -p $MUSIC_INSTALL_DIR
sudo chown -R $USER $MUSIC_INSTALL_DIR
# Stable build: https://github.com/INCF/MUSIC/archive/refs/heads/switch-to-MPI-C-interface.zip @ f33b66ea9348888eed1761738ab48c23ffc8a0d0
curl -L -o MUSIC.zip https://codeload.github.com/INCF/MUSIC/zip/f33b66ea9348888eed1761738ab48c23ffc8a0d0
unzip MUSIC.zip && mv MUSIC-* MUSIC && cd MUSIC
./autogen.sh
# workaround for MUSIC on MacOS 12
if [[ "${{matrix.os}}" == "macOS-12" ]]; then
if [[ "${{matrix.os}}" == "macOS-13" ]]; then
MPI_CXXFLAGS="-g" MPI_CFLAGS="-g" MPI_LDFLAGS="-g" CC=mpicc CXX=mpicxx ./configure --with-python-sys-prefix --prefix=$MUSIC_INSTALL_DIR --disable-anysource
else
./configure --with-python-sys-prefix --prefix=$MUSIC_INSTALL_DIR --disable-anysource
Expand Down
17 changes: 15 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,13 @@ stages:
python.version: '3.11'
Python312:
python.version: '3.12'
Python313:
python.version: '3.13'

steps:
- script: |
git submodule update --init --recursive
displayName: Init submodules

# Secure files documentation:
# https://docs.microsoft.com/en-us/azure/devops/pipelines/library/secure-files?view=azure-devops
Expand All @@ -71,7 +77,7 @@ stages:
-e NRN_RELEASE_UPLOAD \
-e NEURON_WHEEL_VERSION \
-e NRN_BUILD_FOR_UPLOAD=1 \
'neuronsimulator/neuron_wheel:latest-gcc9-x86_64' \
'neuronsimulator/neuron_wheel:latest-x86_64' \
packaging/python/build_wheels.bash linux $(python.version) coreneuron
displayName: 'Building ManyLinux Wheel'

Expand All @@ -86,7 +92,7 @@ stages:
- job: 'MacOSWheels'
timeoutInMinutes: 40
pool:
vmImage: 'macOS-12'
vmImage: 'macOS-13'
strategy:
matrix:
Python37:
Expand All @@ -113,8 +119,15 @@ stages:
python.version: '3.12'
python.org.version: '3.12.2'
python.installer.name: 'macos11.pkg'
Python313:
python.version: '3.13'
python.org.version: '3.13.1'
python.installer.name: 'macos11.pkg'

steps:
- script: |
git submodule update --init --recursive
displayName: Init submodules

- script: |
installer=python-$(python.org.version)-$(python.installer.name)
Expand Down
2 changes: 1 addition & 1 deletion bldnrnmacpkgcmake.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
set -ex

default_pythons="python3.8 python3.9 python3.10 python3.11 python3.12"
default_pythons="python3.8 python3.9 python3.10 python3.11 python3.12 python3.13"
# distribution built with
# bash bldnrnmacpkgcmake.sh
# without args, default are the pythons above.
Expand Down
7 changes: 4 additions & 3 deletions ci/win_build_cmake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ export MINGW_CHOST=x86_64-w64-mingw32
export MSYSTEM_PREFIX=/mingw64
export PATH=/mingw64/bin:$PATH

# have compatible cython3
python3 -m pip install "cython<3"

# have compatible cython and setuptools
python3 -m pip install cython setuptools

# if BUILD_SOURCESDIRECTORY not available, use te root of the repo
if [ -z "$BUILD_SOURCESDIRECTORY" ]; then
Expand All @@ -31,7 +32,7 @@ cd $BUILD_SOURCESDIRECTORY/build
-DNRN_RX3D_OPT_LEVEL=2 \
-DPYTHON_EXECUTABLE=/c/Python37/python.exe \
-DNRN_ENABLE_PYTHON_DYNAMIC=ON \
-DNRN_PYTHON_DYNAMIC='c:/Python37/python.exe;c:/Python38/python.exe;c:/Python39/python.exe;c:/Python310/python.exe;c:/Python311/python.exe;c:/Python312/python.exe' \
-DNRN_PYTHON_DYNAMIC='c:/Python37/python.exe;c:/Python38/python.exe;c:/Python39/python.exe;c:/Python310/python.exe;c:/Python311/python.exe;c:/Python312/python.exe;c:/Python313/python.exe' \
-DCMAKE_INSTALL_PREFIX='/c/nrn-install' \
-DMPI_CXX_LIB_NAMES:STRING=msmpi \
-DMPI_C_LIB_NAMES:STRING=msmpi \
Expand Down
1 change: 1 addition & 0 deletions ci/win_download_deps.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pwsh -command Invoke-WebRequest -MaximumRetryCount 4 -OutFile python-3.9.exe htt
pwsh -command Invoke-WebRequest -MaximumRetryCount 4 -OutFile python-3.10.exe https://www.python.org/ftp/python/3.10.0/python-3.10.0-amd64.exe || goto :error
pwsh -command Invoke-WebRequest -MaximumRetryCount 4 -OutFile python-3.11.exe https://www.python.org/ftp/python/3.11.1/python-3.11.1-amd64.exe || goto :error
pwsh -command Invoke-WebRequest -MaximumRetryCount 4 -OutFile python-3.12.exe https://www.python.org/ftp/python/3.12.1/python-3.12.1-amd64.exe || goto :error
pwsh -command Invoke-WebRequest -MaximumRetryCount 4 -OutFile python-3.13.exe https://www.python.org/ftp/python/3.13.1/python-3.13.1-amd64.exe || goto :error

:: mpi
pwsh -command Invoke-WebRequest -MaximumRetryCount 4 -OutFile msmpisetup.exe https://download.microsoft.com/download/a/5/2/a5207ca5-1203-491a-8fb8-906fd68ae623/msmpisetup.exe || goto :error
Expand Down
23 changes: 13 additions & 10 deletions ci/win_install_deps.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ python-3.9.exe /passive Include_pip=1 Include_test=0 PrependPath=1 DefaultJustFo
python-3.10.exe /passive Include_pip=1 Include_test=0 PrependPath=1 DefaultJustForMeTargetDir=C:\Python310 || goto :error
python-3.11.exe /passive Include_pip=1 Include_test=0 PrependPath=1 DefaultJustForMeTargetDir=C:\Python311 || goto :error
python-3.12.exe /passive Include_pip=1 Include_test=0 PrependPath=1 DefaultJustForMeTargetDir=C:\Python312 || goto :error
python-3.13.exe /passive Include_pip=1 Include_test=0 PrependPath=1 DefaultJustForMeTargetDir=C:\Python313 || goto :error

:: fix msvcc version for all python3
pwsh -command "(Get-Content C:\Python37\Lib\distutils\cygwinccompiler.py) -replace 'elif msc_ver == ''1600'':', 'elif msc_ver == ''1900'':' | Out-File C:\Python37\Lib\distutils\cygwinccompiler.py"
Expand All @@ -26,14 +27,16 @@ pwsh -command "(Get-Content C:\Python310\Lib\distutils\cygwinccompiler.py) -repl
pwsh -command "(Get-Content C:\Python311\Lib\distutils\cygwinccompiler.py) -replace 'msvcr100', 'msvcrt' | Out-File C:\Python311\Lib\distutils\cygwinccompiler.py"

:: install numpy
C:\Python37\python.exe -m pip install numpy==1.14.6 "cython < 3" || goto :error
C:\Python38\python.exe -m pip install numpy==1.17.5 "cython < 3" || goto :error
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:\Python37\python.exe -m pip install numpy==1.14.6 cython || goto :error
C:\Python38\python.exe -m pip install numpy==1.17.5 cython || goto :error
C:\Python39\python.exe -m pip install numpy==1.19.3 cython || goto :error
C:\Python310\python.exe -m pip install numpy==1.21.3 cython || goto :error
C:\Python311\python.exe -m pip install numpy==1.23.5 cython || goto :error
C:\Python312\python.exe -m pip install numpy==1.26.3 cython || goto :error
C:\Python313\python.exe -m pip install numpy cython || goto :error
:: setuptools 70.2 leads to an error
C:\Python312\python.exe -m pip install setuptools==70.1.1 || goto :error
C:\Python313\python.exe -m pip install setuptools==70.1.1 || goto :error

:: install nsis
nsis-3.05-setup.exe /S || goto :error
Expand Down Expand Up @@ -67,11 +70,11 @@ base-devel ^
mingw-w64-x86_64-cmake ^
mingw-w64-x86_64-ncurses ^
mingw-w64-x86_64-readline ^
mingw-w64-x86_64-python3 ^
mingw-w64-x86_64-python ^
mingw64/mingw-w64-x86_64-cython ^
mingw-w64-x86_64-python3-setuptools ^
mingw-w64-x86_64-python3-packaging ^
mingw-w64-x86_64-python3-pip ^
mingw-w64-x86_64-python-setuptools ^
mingw-w64-x86_64-python-packaging ^
mingw-w64-x86_64-python-pip ^
mingw64/mingw-w64-x86_64-dlfcn ^
mingw-w64-x86_64-toolchain || goto :error

Expand Down
22 changes: 21 additions & 1 deletion ci/win_test_installer.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,28 @@ C:\Python39\python -c "import neuron; neuron.test(); quit()" || set "errorfound=
C:\Python310\python -c "import neuron; neuron.test(); quit()" || set "errorfound=y"
C:\Python311\python -c "import neuron; neuron.test(); quit()" || set "errorfound=y"
C:\Python312\python -c "import neuron; neuron.test(); quit()" || set "errorfound=y"
C:\Python313\python -c "import neuron; neuron.test(); quit()" || set "errorfound=y"

:: install oldest supported numpy
C:\Python37\python.exe -m pip install -r packaging/python/oldest_numpy_requirements.txt || goto :error
C:\Python38\python.exe -m pip install -r packaging/python/oldest_numpy_requirements.txt || goto :error
C:\Python39\python.exe -m pip install -r packaging/python/oldest_numpy_requirements.txt || goto :error
C:\Python310\python.exe -m pip install -r packaging/python/oldest_numpy_requirements.txt || goto :error
C:\Python311\python.exe -m pip install -r packaging/python/oldest_numpy_requirements.txt || goto :error
C:\Python312\python.exe -m pip install -r packaging/python/oldest_numpy_requirements.txt || goto :error
C:\Python313\python.exe -m pip install -r packaging/python/oldest_numpy_requirements.txt || goto :error

:: test all pythons again
C:\Python37\python -c "import neuron; neuron.test(); quit()" || set "errorfound=y"
C:\Python38\python -c "import neuron; neuron.test(); quit()" || set "errorfound=y"
C:\Python39\python -c "import neuron; neuron.test(); quit()" || set "errorfound=y"
C:\Python310\python -c "import neuron; neuron.test(); quit()" || set "errorfound=y"
C:\Python311\python -c "import neuron; neuron.test(); quit()" || set "errorfound=y"
C:\Python312\python -c "import neuron; neuron.test(); quit()" || set "errorfound=y"
C:\Python313\python -c "import neuron; neuron.test(); quit()" || set "errorfound=y"

:: install numpy dependency
python -m pip install "numpy<2"
python -m pip install numpy
:: run also using whatever is system python
python --version
python -c "import neuron; neuron.test(); quit()" || set "errorfound=y"
Expand Down
3 changes: 2 additions & 1 deletion ci/win_test_installer_wo_rxd.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ C:\Python39\python -c "import neuron; neuron.test(); quit()" || set "errorfound=
C:\Python310\python -c "import neuron; neuron.test(); quit()" || set "errorfound=y"
C:\Python311\python -c "import neuron; neuron.test(); quit()" || set "errorfound=y"
C:\Python312\python -c "import neuron; neuron.test(); quit()" || set "errorfound=y"
C:\Python313\python -c "import neuron; neuron.test(); quit()" || set "errorfound=y"

:: install numpy dependency
python -m pip install "numpy<2"
python -m pip install numpy
:: run also using whatever is system python
python --version
python -c "import neuron; neuron.test(); quit()" || set "errorfound=y"
Expand Down
5 changes: 5 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# NEURON 8.2

## 8.2.7
_Release Date_ : 01-02-2025

This release allows use of Python 3.13

## 8.2.6
_Release Date_ : 24-07-2024

Expand Down
2 changes: 1 addition & 1 deletion docs/conda_environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dependencies:
- cmake
- xorg-libxcomposite
- ffmpeg
- cython<3
- cython
- pandoc
- pip
- pip:
Expand Down
1 change: 0 additions & 1 deletion docs/domains/hocdomain.py
Original file line number Diff line number Diff line change
Expand Up @@ -1617,7 +1617,6 @@ def resolve_any_xref(
multiple_matches = len(matches) > 1

for name, obj in matches:

if multiple_matches and obj.aliased:
# Skip duplicated matches
continue
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Installation

pip3 install neuron

Alternatively, you can use the `PKG installer <https://github.com/neuronsimulator/nrn/releases/download/8.2.6/nrn-8.2.6-macosx-10.9-universal2-py-38-39-310-311-312.pkg>`_.
Alternatively, you can use the `PKG installer <https://github.com/neuronsimulator/nrn/releases/download/8.2.6/nrn-8.2.6-macosx-10.9-universal2-py-38-39-310-311-312-313.pkg>`_.

For troubleshooting, see the `detailed installation instructions <install/install_instructions.html>`_.

Expand Down
2 changes: 1 addition & 1 deletion docs/install/install_instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ In order to build NEURON from source, the following packages must be available:
The following packages are optional (see build options):

- Python >=3.7 (for Python interface)
- Cython < 3 (for RXD)
- Cython (for RXD)
- MPI (for parallel)
- X11 (Linux) or XQuartz (MacOS) (for GUI)

Expand Down
2 changes: 1 addition & 1 deletion docs/install/mac_pkg.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ cmake .. -DCMAKE_INSTALL_PREFIX=$NRN_INSTALL \

The default variables above will be
```
pythons="python3.9;python3.10;python3.11;python3.12"
pythons="python3.9;python3.10;python3.11;python3.12;python3.13"
archs_cmake='-DCMAKE_OSX_ARCHITECTURES=arm64;x86_64'
```

Expand Down
1 change: 0 additions & 1 deletion docs/parse_rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@


class ParseRst(object):

help_dictionary = {}

def __init__(self, rst_path, out_file):
Expand Down
4 changes: 2 additions & 2 deletions nrn_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ matplotlib
# bokeh 3 seems to break docs notebooks
bokeh<3
ipython
cython<3
cython
packaging
pytest
pytest-cov
mpi4py
numpy<2
numpy
2 changes: 1 addition & 1 deletion packaging/python/build_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
cython<3
cython
packaging
11 changes: 6 additions & 5 deletions packaging/python/build_wheels.bash
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,16 @@ pip_numpy_install() {
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" ;;
311) numpy_ver="numpy==1.23.5" ;;
312) numpy_ver="numpy==1.26.0" ;;
39) numpy_ver="numpy>=2" ;;
310) numpy_ver="numpy>=2" ;;
311) numpy_ver="numpy>=2" ;;
312) numpy_ver="numpy>=2" ;;
313) numpy_ver="numpy>=2" ;;
Comment on lines +55 to +59
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because numpy 2 is backwards compatible, but numpy 1 is not forwards compatible, so building a wheel with numpy 1.x and testing it with 2.x will fail, but the other way around works.

*) 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 != 311 ]] && [[ $py_ver != 312 ]]; then
if [[ `uname -m` == 'arm64' ]] && [[ $py_ver -le 311 ]] ; then
numpy_ver="numpy==1.21.3"
fi

Expand Down
8 changes: 8 additions & 0 deletions packaging/python/oldest_numpy_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
numpy==1.14.6;python_version=='3.7'
numpy==1.17.5;python_version=='3.8'
numpy==1.20.3;python_version=='3.9' and platform_machine!='arm64'
numpy==1.21.6;python_version=='3.9' and platform_machine=='arm64'
numpy==1.21.6;python_version=='3.10'
numpy==1.23.5;python_version=='3.11'
numpy==1.26.4;python_version=='3.12'
numpy>=2;python_version=='3.13'
2 changes: 2 additions & 0 deletions packaging/python/test_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pytest
setuptools;python_version>='3.12' # From 3.12, no longer installed by default
Loading
Loading