Skip to content

[ENH] Move to pyproject.toml#608

Merged
CozySocksAlways merged 70 commits into
NeuralEnsemble:masterfrom
INM-6:enh/pyproject.toml
Jun 2, 2026
Merged

[ENH] Move to pyproject.toml#608
CozySocksAlways merged 70 commits into
NeuralEnsemble:masterfrom
INM-6:enh/pyproject.toml

Conversation

@Moritz-Alexander-Kern
Copy link
Copy Markdown
Member

@Moritz-Alexander-Kern Moritz-Alexander-Kern commented Nov 22, 2023

This is a long one!

Original PR Body by Moritz

This PR moves Elephant from setup.py to pyproject.toml, aligning with PEP 518.

Key changes include:

  • Introduction of pyproject.toml
  • setup.py is still needed to compile the C-code for the fim module.

The reason is that we need OS dependend compile args which are dynamically defined in setup.py.
The pyproject.toml does not natively support conditional logic like os_name == 'windows' directly within the configuration. The TOML format is static and doesn't allow for dynamic evaluation of conditions based on the operating system.

To achieve platform-specific compile arguments, we have to use a Python script, such as a setup.py, which can programmatically determine the OS and apply the correct compile arguments.

In this context, as a configuration file for setuptools, setup.py is not deprecated, see also: https://packaging.python.org/en/latest/discussions/setup-py-deprecated/


Changes

pyproject.toml

  • Created pyproject.toml with full project metadata (name, version, description, authors, license,
    URLs, classifiers)
  • Moved to the SPDX licence expression format per PEP 639; removed the legacy License :: classifier string
  • Switched to auto-discovery of packages via setuptools.find_packages(), this correctly picks up
    subpackages such as elephant.asset
  • Added include-package-data = true so non-Python data files are included in the wheel install
  • Added classifiers for Python 3.13 and 3.14
  • Removed the long-unused six dependency
  • Added viziphant to the tutorials optional-dependency group
  • Dependencies are now declared via dynamic metadata, pointing back to the requirements/*.txt files. This keeps a single source of truth for dependencies

CI modernisation (.github/workflows/CI.yml)

  • Merged pip test jobs: Three separate pip-test jobs (Ubuntu, macOS, Windows) merged into a single job with matrix.include, eliminating duplication
  • Composite action: Added a composite action(.github/actions/restore-elephant-data) to avoid code duplication of restore action that restored cached elephant-dataset and is shared by the pip, MPI and conda jobs
  • Enabled enableCrossOsArchive: true on the data cache so a cache built on one OS can be restored on
    another, this was added to build to both restore action and cache build action (.github/workflows/cache_elephant_data.yml)
  • Bumped actions/cache/, actions/setup-python and actions/checkout to newer versions to fix issue with Node.js 20 actions being deprecated
  • Made python version common accross jobs
  • Per-job coveralls uploads + finish job: every job now uploads its own partial coverage report to coveralls, and a new finish job combines them at the end. This is to fix the earlier race condition where last coverall job was being usede to add PR comment.
  • Added pytest-cov to requirements/requirements-tests.txt to avoid duplicate install steps for each job
  • Fast CI mode: added a fast workflow-dispatch boolean input that limits the matrix to a subset of jobs
  • Cleaned up workflow triggers
  • Cleaned up the DOC BUILD and DOC TEST jobs

Environment files

  • Refactored requirements/environment*.yml conda environment files to import from the corresponding requirements/*.txt files instead of duplicating the dependency list (system-level conda-only packages are still listed directly)

Bug fix for Windows path

  • elephant/datasets.py: switched to local_file.as_posix() when constructing the ValueError message in download_datasets. On Windows, pathlib rendered backslashes, causing test_download_with_cache_dir_with_failed_integrity_check to fail because the assertion looks for the POSIX-style repo_path substring.

@coveralls
Copy link
Copy Markdown
Collaborator

coveralls commented Nov 22, 2023

Coverage Status

coverage: 88.981% (+0.6%) from 88.424% — INM-6:enh/pyproject.toml into NeuralEnsemble:master

Moritz-Alexander-Kern

This comment was marked as outdated.

Moritz-Alexander-Kern

This comment was marked as outdated.

Moritz-Alexander-Kern

This comment was marked as outdated.

@Moritz-Alexander-Kern Moritz-Alexander-Kern added the enhancement Editing an existing module, improving something label Nov 22, 2023
Moritz-Alexander-Kern

This comment was marked as outdated.

Moritz-Alexander-Kern

This comment was marked as outdated.

Moritz-Alexander-Kern

This comment was marked as outdated.

…nd optional dependencies, this avoids need of dedicated CI to check and maintain requirements files
@CozySocksAlways CozySocksAlways marked this pull request as draft May 26, 2026 08:20
Added a finish job to combine coveralls report;
Added pytest-cov pluggin to req-test to avoid duplicated
install statements in CI file;
@CozySocksAlways CozySocksAlways marked this pull request as ready for review May 27, 2026 13:33
@CozySocksAlways
Copy link
Copy Markdown
Contributor

CozySocksAlways commented May 27, 2026

Postponing addition of GPU tests with group runner available on jugit.fz-juelich.de to a different PR.

@CozySocksAlways
Copy link
Copy Markdown
Contributor

Once PR approved, full CI should be triggered. (Run once for each PR approval)

Copy link
Copy Markdown
Member

@mdenker mdenker left a comment

Choose a reason for hiding this comment

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

Thank you for this extensive PR, besides the comment about Python versions, it looks good to me so far -- I guess we need to see how the remaining CI jobs work out. I tested installs on Linux and Windows, which seem to work (including the fim module unter linux). However, the Python 3.8 issue that prevents installation of the package in a uv managed pip environment is something we should address.

Comment thread pyproject.toml Outdated
"Topic :: Scientific/Engineering"]
keywords = ["neuroscience", "neurophysiology", "electrophysiology", "statistics", "data-analysis"]
readme = {file = "README.md", content-type = "text/markdown"}
requires-python = ">=3.8"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I feel like this line is giving me problems when doing the following:

  • Create a new environment using uv venv
  • Doing a uv pip install . in the elephant directory
  • Calling uv run pythonm which gives me an error about dependencies not being satisfyable:uv responds that while I am currently using Python 3.14, the reuires-python indicates >=3.8. This is however incompatible with numpy 2. Therefore, uv fails, as it cannot resolve for any of the support python versions. I do not fully understand this logic, however, I guess we should drop 3.8 despite this being a hot fix. Or maybe I am missing something?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yup I could recreate this issue, it's an error from my side. The setup.py on our latest release has a requirement on python>=3.9, so I'll fix this now on the toml file.

As a side note, the latest release of numpy (2.4.6) has a requirement of python>=3.11, though lower version of numpy 2.0 still support python 3.9. So we should definitely fix this on our next minor release.

…request_review trigger; Made all other jobs dependent on setup job, so they are also skipped based on setup job
@CozySocksAlways
Copy link
Copy Markdown
Contributor

Test duplication in case of pull_request_review trigger (i.e. both pull_request_review triggered tests pollutes the existing PR checks summary made with the checks triggered on PR synchronize) is the right behavior on GitHub and cannot be avoided as GitHub treats these two as separate events. Refer https://github.com/orgs/community/discussions/26940

As some form of relief, an if clause has been added on the setup job that makes it only run when pull_request_review is approved and not when a review comment is added.

Copy link
Copy Markdown
Contributor

@kohlerca kohlerca left a comment

Choose a reason for hiding this comment

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

The PR looks good to me. I tested locally in Ubuntu, using mamba and uv, and the installation succeeds.

@CozySocksAlways
Copy link
Copy Markdown
Contributor

CozySocksAlways commented Jun 1, 2026

  • Update names of tests for consistency (i.e with MPI and conda)

@CozySocksAlways CozySocksAlways merged commit c90ca8a into NeuralEnsemble:master Jun 2, 2026
37 checks passed
@CozySocksAlways CozySocksAlways deleted the enh/pyproject.toml branch June 2, 2026 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Editing an existing module, improving something

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants