Skip to content

Conversation

@steffengraber
Copy link

Key changes:

  • Python packaging

    • Add Python packaging configuration with project metadata, dependencies, and optional features.
  • CI Workflow

  • CMake Files

    • Refactor CMake configuration to build the Python Wheel.

Before merging, the project name and deployment secrets need to be adjusted.

The Python package may be tested in a Docker container:

docker run -it --rm --name test ubuntu:24.04 bash

Install Dependencies and Create an Python venv

apt update
DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt install -y git python3 python3-pip python3-venv time libopenmpi-dev libboost-dev libgsl-dev
python3 -m venv ${HOME}/.env
source ${HOME}/.env/bin/activate

Intalll from https://test.pypi.org/project/pynest-ng/

python3 -m pip --no-cache-dir install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ pynest-ng
python3 -c "import nest; nest.help()"

Rebuild with MPI

python3 -m pip install -v  --force-reinstall --check-build-dependencies --index-url https://test.pypi.org/simple/  --extra-index-url https://pypi.org/simple/  --config-settings=cmake.define.with-mpi="ON" --no-binary pynest-ng pynest-ng[mpi]
python3 -c "import nest; nest.help()"

Install and Build from GitHub Repository

python3 -m pip install -v --force-reinstall git+https://{GITHUB_TOKEN}@github.com/steffengraber/nest-simulator.git@hep_pynest-ng
python3 -c "import nest; nest.help()"

Copy link
Owner

@heplesser heplesser left a comment

Choose a reason for hiding this comment

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

Hi @steffengraber! Thanks for this PR and apologies for taking weeks before looking at it. I have tried the pip install and that worked very nicely on my macOS 15.5 (arm64) system. I could also run all non-MPI tests with

pytest --ignore=$PyTestDir/mpi --ignore=$PyTestDir/sli2py_mpi $PyTestDir

where PyTestDir points to .../testsuite/pytests under the site_packages/nest directory.

Building with MPI did not quite work. NEST built, but the CMake output did not even show a search for OpenMPI and NEST then built nicely without MPI. One problem I had was that my zsh shell did not like the line

python3 -m pip install -v  --force-reinstall --check-build-dependencies --index-url https://test.pypi.org/simple/  --extra-index-url https://pypi.org/simple/  --config-settings=cmake.define.with-mpi="ON" --no-binary pynest-ng pynest-ng[mpi]

I had to put the final pynest-ng[mpi] in quotes to make this run. Could that have caused the problem?

What are the SKBUILD switches in the CMake files about? Probably a dumb question ...

You also mentioned that some secrets needed adjustment before merging. Do you mean merging this branch into my branch or the eventual merge into NEST master?

"Bug Tracker" = "https://github.com/nest/nest-simulator/issues"
Changelog = "https://nest-simulator.readthedocs.io/en/stable/whats_new/index.html"

[tool.scikit-build]
Copy link
Owner

Choose a reason for hiding this comment

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

Why "scikit"?

Copy link
Author

Choose a reason for hiding this comment

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

I use a program called "Scikit-build-core" to help me package pynest-ng. "It provides a bridge between CMake and the Python build system, allowing you to make Python modules with CMake." https://scikit-build-core.readthedocs.io/en/latest/
The scikit tag here marks some definitions for the build process.

]
dependencies = [
"numpy",
"pynest-api",
Copy link
Owner

Choose a reason for hiding this comment

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

Maybe add pytest, so one can easily run the testsuite after installation?

Copy link
Author

Choose a reason for hiding this comment

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

Pytest has been added as a dependency.

pyproject.toml Outdated
NEST_SRC_DIR=${PWD}
if [ $AUDITWHEEL_POLICY == "musllinux_1_2" ]
then
apk add git readline readline-dev libc6-compat gsl gsl-dev ncurses ncurses-dev wget bzip2 hdf5 cmake
Copy link
Owner

Choose a reason for hiding this comment

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

For PyNEST-NG, we should no longer need readline and readline-dev.

Copy link
Author

Choose a reason for hiding this comment

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

👍 Readline has been removed.

@steffengraber
Copy link
Author

I had to put the final pynest-ng[mpi] in quotes to make this run. Could that have caused the problem?

Maybe a Mac thing?

What are the SKBUILD switches in the CMake files about? Probably a dumb question ...

For Phyton packaging, some installation paths need to be adjusted. The SKBUILB switch recognizes that a build is being performed with Scikit-build-core and the corresponding changes can be made.

You also mentioned that some secrets needed adjustment before merging. Do you mean merging this branch into my branch or the eventual merge into NEST master?

Both. In order for CI to perform the upload to testpypi or later to pypi, a token must be set as an environment variable.

@github-actions
Copy link

Pull request automatically marked stale!

@github-actions github-actions bot added the stale label Sep 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants