Convert nmaci to a pip-installable Python package#7
Open
OleBialas wants to merge 9 commits intoneuromatch:mainfrom
Open
Convert nmaci to a pip-installable Python package#7OleBialas wants to merge 9 commits intoneuromatch:mainfrom
OleBialas wants to merge 9 commits intoneuromatch:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR converts
nmacifrom a collection of standalone scripts (downloaded as a tarball by course repo CI) into a proper pip-installable Python package with a unified CLI entry point.What changed
Package structure (
src/layout with hatchling build backend)pyproject.toml— declares dependencies, entry point, and build configsrc/nmaci/— one module per command, importable as a packagesrc/nmaci/cli.py— singlenmacientry point dispatching to subcommands via lazyimportlibimportssrc/nmaci/__main__.py— enablespython -m nmaci <command>Scripts refactored
generate_book.py,generate_book_dl.py,parse_html_for_errors.py— removed module-levelsys.argvaccess that crashed on importselect_notebooks.py,find_unreferenced_content.py— wrapped bare__main__blocks intomain(arglist=None)main(arglist=None)convention (argparse readssys.argv[1:]whenarglistisNone)Backward-compatible shims (
scripts/)scripts/are now 3-line shims that delegate tosrc/nmaci/python ci/process_notebooks.py) continues to work unchanged as long asnmaciis installedTests & CI
nmaci.*directly; subprocess tests usepython -m nmaci <command>pip install -r requirements.txttouv sync --extra devfrom __future__ import annotationsadded to fixPath | strunion syntax on Python 3.9Backward compatibility
Course repos that currently do
python ci/process_notebooks.py <args>are unaffected — the shims preserve that interface. The only new requirement is thatnmacibe installed as a package, which the updatedsetup-ci-toolsaction handles.Testing
uv run pytest tests/ src/nmaci/)setup-ci-toolspatched topip install git+https://github.com/OleBialas/nmaci@main— verifies shims work correctly in a real CI environment. See test: verify nmaci pip package shims work end-to-end OleBialas/NeuroAI_Course#2