Skip to content

Commit

Permalink
Merge branch 'master' into leite/dat_files_use_vec
Browse files Browse the repository at this point in the history
  • Loading branch information
ferdonline authored Dec 10, 2024
2 parents 1033a0c + de07242 commit 1853c77
Show file tree
Hide file tree
Showing 24 changed files with 181 additions and 140 deletions.
34 changes: 13 additions & 21 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
version: 2.1

orbs:
python: circleci/python@2.1.1
python: circleci/python@3.0.0

jobs:
manylinux2014-aarch64:

parameters:
NRN_PYTHON_VERSION:
NRN_PYTHON_VERSION_MINOR:
type: string
NRN_NIGHTLY_UPLOAD:
type: string
Expand All @@ -31,8 +31,8 @@ jobs:
-e NRN_RELEASE_UPLOAD \
-e SETUPTOOLS_SCM_PRETEND_VERSION \
-e NRN_BUILD_FOR_UPLOAD=1 \
'neuronsimulator/neuron_wheel:latest-gcc9-aarch64' \
packaging/python/build_wheels.bash linux << parameters.NRN_PYTHON_VERSION >> coreneuron
'neuronsimulator/neuron_wheel:latest-aarch64' \
packaging/python/build_wheels.bash linux 3<< parameters.NRN_PYTHON_VERSION_MINOR >> coreneuron
- store_artifacts:
path: ./wheelhouse
Expand All @@ -41,24 +41,16 @@ jobs:
- run:
name: Test manylinux AArch64 wheel
command: |
# install mpi dependencies
sudo apt update
echo "deb http://ppa.launchpad.net/deadsnakes/ppa/ubuntu jammy main" | sudo tee /etc/apt/sources.list.d/deadsnakes-ppa.list && sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F23C5A6CF475977595C89F51BA6932366A755776 && sudo apt update
sudo apt update
# install mpi dependencies
sudo apt install -y mpich openmpi-bin libopenmpi-dev libmpich-dev
version=3.<< parameters.NRN_PYTHON_VERSION_MINOR >>
# install Python from deadsnakes
sudo apt install -y python${version}-venv libpython${version}-dev g++ make
# choose available python versions from pyenv
pyenv_py_ver=""
case << parameters.NRN_PYTHON_VERSION >> in
39) pyenv_py_ver="3.9" ;;
310) pyenv_py_ver="3.10" ;;
311) pyenv_py_ver="3.11" ;;
312) pyenv_py_ver="3.12" ;;
*) echo "Error: pyenv python version not specified or not supported." && exit 1;;
esac
env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install $pyenv_py_ver --force
pyenv global $pyenv_py_ver
export PYTHON_EXE=$(which python)
export PYTHON_EXE=$(which python3.<< parameters.NRN_PYTHON_VERSION_MINOR >>)
# test wheel
packaging/python/test_wheels.sh $PYTHON_EXE $(ls -t wheelhouse/*.whl)
Expand Down Expand Up @@ -86,7 +78,7 @@ workflows:
- /circleci\/.*/
matrix:
parameters:
NRN_PYTHON_VERSION: ["312"]
NRN_PYTHON_VERSION_MINOR: ["13"]
NRN_NIGHTLY_UPLOAD: ["false"]

nightly:
Expand All @@ -101,5 +93,5 @@ workflows:
- manylinux2014-aarch64:
matrix:
parameters:
NRN_PYTHON_VERSION: ["39", "310", "311", "312"]
NRN_PYTHON_VERSION_MINOR: ["9", "10", "11", "12", "13"]
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 @@ -24,7 +24,7 @@ on:
env:
PY_MIN_VERSION: '3.9'
PY_MID_VERSION: '3.10'
PY_MAX_VERSION: '3.12'
PY_MAX_VERSION: '3.13'

jobs:
coverage:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
- release/**

env:
DEFAULT_PY_VERSION: '3.12'
DEFAULT_PY_VERSION: '3.13'

jobs:
documentation:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/neuron-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
DESIRED_CMAKE_VERSION: 3.17
DYNAMIC_PYTHON_CMAKE_VERSION: 3.18
PY_MIN_VERSION: ${{ matrix.config.python_min_version || '3.9' }}
PY_MAX_VERSION: ${{ matrix.config.python_max_version || '3.12' }}
PY_MAX_VERSION: ${{ matrix.config.python_max_version || '3.13' }}
MUSIC_INSTALL_DIR: /opt/MUSIC
# hash of commit containing mpi4py 4 fix
MUSIC_VERSION: '13f312338dcccebfe74d391b1b24f1b6d816ac6c'
Expand Down
9 changes: 8 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ stages:
python.version: '3.11'
Python312:
python.version: '3.12'
Python313:
python.version: '3.13'

steps:

# Secure files documentation:
Expand Down Expand Up @@ -74,7 +77,7 @@ stages:
- script: |
sudo apt update
sudo apt install -y mpich openmpi-bin libopenmpi-dev libmpich-dev
displayName: 'Install Test System Depdendencies'
displayName: 'Install Test System Dependencies'
- template: ci/azure-wheel-test-upload.yml

Expand Down Expand Up @@ -102,6 +105,10 @@ stages:
python.version: '3.12'
python.org.version: '3.12.0'
python.installer.name: 'macos11.pkg'
Python313:
python.version: '3.13'
python.org.version: '3.13.0'
python.installer.name: 'macos11.pkg'

steps:

Expand Down
54 changes: 39 additions & 15 deletions bldnrnmacpkgcmake.sh → bldnrnmacpkg.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
#!/usr/bin/env bash
set -ex

default_pythons="python3.8 python3.9 python3.10 python3.11"
default_pythons="python3.9 python3.10 python3.11 python3.12 python3.13"
# distribution built with
# bash bldnrnmacpkgcmake.sh
# without args, default are the pythons above.

if test "$RX3D_OPT" = "" ; then
RX3D_OPT=1 # a value of 2 takes much longer to build
fi

# If all the pythons are universal, then so is NEURON.
# Otherwise $CPU
# All pythons must have the same macos version and that will become
# the MACOSX_DEPLOYMENT_TARGET

# Now obsolete...
# On my machine, to build nrn-x.x.x-macosx-10.9-universal2-py-38-39-310-311.pkg
# I built my own versions of 3.8 in $HOME/soft/python3.8, and
export PATH=$HOME/soft/python3.8/bin:$PATH
# export PATH=$HOME/soft/python3.8/bin:$PATH
# All other python versions installed from python.org universal2 installers.

# As of Python-3.13.0, we configure to link universal2 static readline
# (and ncurses) into libnrniv.dylib.
# The packages were downloade and the universal libraries were built with
# nrn/packaging/python/build_static_readline_osx.bash
READLINE_LIST="/opt/nrnwheel/arm64/readline;/opt/nrnwheel/arm64/ncurses"

CPU=`uname -m`

Expand All @@ -24,10 +34,15 @@ if test "$args" = "" ; then
args="$default_pythons"
fi

MPI_LIST="/opt/homebrew/opt/openmpi/include;/opt/homebrew/opt/mpich/include"

# sysconfig.get_platform() looks like, e.g. "macosx-12.2-arm64" or
# "macosx-11-universal2". I.e. encodes MACOSX_DEPLOYMENT_TARGET and archs.
# Demand all pythons we are building against have same platform.
# Update: nrn software now requires at least 10.15. All the python's on this
# machine are 10.9, except python 3.13 is 10.13. The substantive aspect of
# the following fragment (exit 1 if not all the same platform), has been
# commented out.
mac_platform=""
for i in $args ; do
last_py=$i
Expand All @@ -38,7 +53,7 @@ for i in $args ; do
fi
if test "$mac_platform" != "$mplat" ; then
echo "$i platform \"$mplat\" differs from previous python \"$mac_platform\"."
exit 1
# exit 1
fi
done

Expand Down Expand Up @@ -93,13 +108,15 @@ fi

cmake .. -G Ninja -DCMAKE_INSTALL_PREFIX=$NRN_INSTALL \
-DNRN_ENABLE_MPI_DYNAMIC=ON \
-DNRN_MPI_DYNAMIC="$MPI_LIST" \
-DPYTHON_EXECUTABLE=`which python3` -DNRN_ENABLE_PYTHON_DYNAMIC=ON \
-DNRN_PYTHON_DYNAMIC="$pythons" \
-DIV_ENABLE_X11_DYNAMIC=ON \
-DNRN_ENABLE_CORENEURON=OFF \
-DNRN_RX3D_OPT_LEVEL=2 \
-DNRN_RX3D_OPT_LEVEL=$RX3D_OPT \
-DNRN_WHEEL_STATIC_READLINE=ON \
$archs_cmake \
-DCMAKE_PREFIX_PATH=/usr/X11 \
-DCMAKE_PREFIX_PATH="/usr/X11;$READLINE_LIST" \
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++

ninja install
Expand Down Expand Up @@ -134,22 +151,29 @@ for i in $args ; do
chk $i
done

describe="`sh $NRN_SRC/nrnversion.sh describe`"
macos=macos${MACOSX_DEPLOYMENT_TARGET}
PACKAGE_FULL_NAME=nrn-${describe}-${mac_platform}-${PYVS}.pkg
PACKAGE_FILE_NAME=$NRN_BLD/src/mac/build/NEURON.pkg

#/Applications/Packages.app from
# http://s.sudre.free.fr/Software/Packages/about.html
# For mac to do a productsign, need my developerID_installer.cer
# and Neurondev.p12 file. To add to the keychain, double click each
# of those files. By default, I added my certificates to the login keychain.
ninja macpkg # will sign the binaries, construct below
# mentioned PACKAGE_FILE_NAME, request notarization from
# Apple, and staple the package.

# Will sign the binaries, construct above
# mentioned PACKAGE_FILE_NAME, request notarization from
# Apple, and staple the package.
if ! ninja macpkg ; then
echo "ninja macpkg failed. (because of notification failure?)"
echo "Not creating $PACKAGE_FULL_NAME"
echo " from $PACKAGE_FILE_NAME"
exit 1
fi

# Copy the package to $HOME/$PACKAGE_FULL_NAME
# You should then manually upload that to github.
describe="`sh $NRN_SRC/nrnversion.sh describe`"
macos=macos${MACOSX_DEPLOYMENT_TARGET}
PACKAGE_FULL_NAME=nrn-${describe}-${mac_platform}-${PYVS}.pkg
PACKAGE_FILE_NAME=$NRN_BLD/src/mac/build/NEURON.pkg

cp $PACKAGE_FILE_NAME $HOME/$PACKAGE_FULL_NAME

echo "
Expand Down
2 changes: 1 addition & 1 deletion ci/win_build_cmake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ cd $BUILD_SOURCESDIRECTORY/build
-DNRN_BINARY_DIST_BUILD=ON \
-DPYTHON_EXECUTABLE=/c/Python39/python.exe \
-DNRN_ENABLE_PYTHON_DYNAMIC=ON \
-DNRN_PYTHON_DYNAMIC='c:/Python39/python.exe;c:/Python310/python.exe;c:/Python311/python.exe;c:/Python312/python.exe' \
-DNRN_PYTHON_DYNAMIC='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 @@ -7,6 +7,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.0/python-3.13.0-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
3 changes: 3 additions & 0 deletions ci/win_install_deps.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,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:\Python39\Lib\distutils\cygwinccompiler.py) -replace 'elif msc_ver == ''1600'':', 'elif msc_ver == ''1927'':' | Out-File C:\Python39\Lib\distutils\cygwinccompiler.py"
Expand All @@ -24,8 +25,10 @@ C:\Python39\python.exe -m pip install numpy cython || goto :error
C:\Python310\python.exe -m pip install numpy cython || goto :error
C:\Python311\python.exe -m pip install numpy cython || goto :error
C:\Python312\python.exe -m pip install numpy 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
3 changes: 3 additions & 0 deletions ci/win_test_installer.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,21 @@ 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:\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:\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"

:: run also using whatever is system python
python -m pip install numpy
Expand Down
4 changes: 4 additions & 0 deletions docs/python/modelspec/programmatic/topology/seclist.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ SectionList
for sec in python_iterable_of_sections:
sl.append(sec)
``len(sl)`` returns the number of sections in the SectionList.

``list(sl)`` and ``[s for s in sl]`` generate equivalent lists.

.. seealso::
:class:`SectionBrowser`, :class:`Shape`, :meth:`RangeVarPlot.list`

Expand Down
3 changes: 3 additions & 0 deletions packaging/python/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,7 @@ COPY Dockerfile .
# build wheels from there
WORKDIR /root

# remove Python 3.13t since we do not support the free-threaded build yet
RUN rm -fr /opt/python/cp313-cp313t

ENV NMODL_PYLIB=/nrnwheel/python/lib/libpython3.10.so.1.0
1 change: 1 addition & 0 deletions packaging/python/oldest_numpy_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ 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.1.0;python_version=='3.13'
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import sys
from collections import defaultdict
import logging
import platform

logging.basicConfig(level=logging.INFO)
from shutil import copytree, which
Expand Down Expand Up @@ -461,6 +462,8 @@ def setup_package():
+ ["-Wl,-rpath,{}".format(REL_RPATH + "/../../.data/lib/")],
)
)
if platform.system() == "Darwin":
rxd_params["extra_link_args"] += ["-headerpad_max_install_names"]

logging.info("RX3D compile flags %s" % str(rxd_params))

Expand Down
6 changes: 6 additions & 0 deletions src/coreneuron/io/nrn_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,12 @@ std::vector<int> nrn_read_filesdat(const char* filesdat) {
int iFile;
nrn_assert(fscanf(fp, "%d\n", &iFile) == 1);
if ((iNum % nrnmpi_numprocs) == nrnmpi_myid) {
// A "-1" entry means that this rank should not be assigned further gid groups.
// It is a way to create files.dat files which deterministically assign gid groups to
// ranks, particularly useful for very large simulations which required load balancing.
if (iFile == -1) {
break;
}
rank_cell_groups.push_back(iFile);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/mac/nrn_productsign.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
set -ex

# Signing the package with an identified developer certificate means the
# installer does not have to lower the security settings on their machine.
Expand Down
Loading

0 comments on commit 1853c77

Please sign in to comment.