Skip to content

Migrate from setup.py to pyproject.toml (hatchling)#2770

Merged
mikejhuang merged 1 commit into
AllenInstitute:masterfrom
galenlynch:packaging/pyproject.toml
Feb 16, 2026
Merged

Migrate from setup.py to pyproject.toml (hatchling)#2770
mikejhuang merged 1 commit into
AllenInstitute:masterfrom
galenlynch:packaging/pyproject.toml

Conversation

@galenlynch

@galenlynch galenlynch commented Feb 14, 2026

Copy link
Copy Markdown
Contributor

Overview:

setup.py imports allensdk at build time to read __version__, breaking clean installs. Dependencies live in five separate requirements files instead of package metadata. 18 files use pkg_resources at runtime, forcing a deprecated setuptools runtime dependency.

Addresses:

Better packaging

Type of Fix:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing
    functionality to not work as expected)
  • Documentation Change

Solution:

Switch to using a pyproject.toml for this project, and adopt more modern python packaging standards like optional dependencies.

Changes:

  • Replace setup.py/setup.cfg/MANIFEST.in with pyproject.toml (hatchling backend)
  • Consolidate 5 requirements files into [project.optional-dependencies] extras
  • Replace pkg_resources.resource_filename with importlib.resources.files (12 source files, 7 test files)
  • Replace pkg_resources.parse_version with packaging.version.Version (brain_observatory_nwb_data_set.py)
  • Read __version__ from importlib.metadata.version("allensdk") instead of hardcoding
  • Convert bps bash wrapper to a [project.scripts] console entry point
  • Update CI workflows, ReadTheDocs config, and docs for new install path
  • Update 2 notebook cells that used pkg_resources to print version info
  • Drop setuptools and scikit-build from runtime deps
  • Add packaging (stdlib replacement for pkg_resources.parse_version)

Note: test files use hardcoded package strings (e.g., files('allensdk.test.core'))
instead of files(__package__) because __package__ can be empty during pytest
collection at module level.

Deleted files

Deleted Replaced by
setup.py pyproject.toml
setup.cfg pyproject.toml [tool.pytest.ini_options]
MANIFEST.in hatchling auto-includes git-tracked files
requirements.txt pyproject.toml [project] dependencies
test_requirements.txt pyproject.toml [project.optional-dependencies] test
doc_requirements.txt pyproject.toml [project.optional-dependencies] docs
dev_requirements.txt pyproject.toml [project.optional-dependencies] dev
notebook_requirements.txt pyproject.toml [project.optional-dependencies] notebooks

Validation:

All unit tests pass, all notebooks run without error, built wheels contain correct source files and extra package resources.

Checklist

  • My code follows
    Allen Institute Contribution Guidelines
  • My code is unit tested and does not decrease test coverage
  • I have performed a self review of my own code
  • My code is well-documented, and the docstrings conform to
    Numpy Standards
  • I have updated the documentation of the repository where
    appropriate
  • The header on my commit includes the issue number
  • My Pull Request has the latest AllenSDK release candidate branch
    rc/x.y.z as its merge target
  • My code passes all AllenSDK tests

@review-notebook-app

Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@galenlynch galenlynch force-pushed the packaging/pyproject.toml branch 3 times, most recently from ba85e66 to 55c73e3 Compare February 14, 2026 20:29
setup.py imports allensdk at build time to read __version__, breaking
clean installs. Dependencies live in five separate requirements files
instead of package metadata. 18 files use pkg_resources at runtime,
forcing a setuptools runtime dependency.

- Replace setup.py/setup.cfg/MANIFEST.in with pyproject.toml (hatchling)
- Consolidate requirements files into optional dependency groups
- Replace pkg_resources.resource_filename with importlib.resources.files
- Replace pkg_resources.parse_version with packaging.version.Version
- Read __version__ from importlib.metadata instead of hardcoding
- Convert bps bash wrapper to a [project.scripts] console entry point
- Update CI workflows, docs, and notebook cells for new install path

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@galenlynch galenlynch force-pushed the packaging/pyproject.toml branch from 55c73e3 to 879a70c Compare February 14, 2026 20:43
@mikejhuang mikejhuang merged commit eb28ce1 into AllenInstitute:master Feb 16, 2026
4 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants