Skip to content

Convert nmaci to a pip-installable Python package#7

Open
OleBialas wants to merge 9 commits intoneuromatch:mainfrom
OleBialas:main
Open

Convert nmaci to a pip-installable Python package#7
OleBialas wants to merge 9 commits intoneuromatch:mainfrom
OleBialas:main

Conversation

@OleBialas
Copy link
Copy Markdown

Summary

This PR converts nmaci from 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)

  • Added pyproject.toml — declares dependencies, entry point, and build config
  • Source moved to src/nmaci/ — one module per command, importable as a package
  • src/nmaci/cli.py — single nmaci entry point dispatching to subcommands via lazy importlib imports
  • src/nmaci/__main__.py — enables python -m nmaci <command>

Scripts refactored

  • generate_book.py, generate_book_dl.py, parse_html_for_errors.py — removed module-level sys.argv access that crashed on import
  • select_notebooks.py, find_unreferenced_content.py — wrapped bare __main__ blocks into main(arglist=None)
  • All modules now follow the main(arglist=None) convention (argparse reads sys.argv[1:] when arglist is None)

Backward-compatible shims (scripts/)

  • All scripts in scripts/ are now 3-line shims that delegate to src/nmaci/
  • Course repo CI (python ci/process_notebooks.py) continues to work unchanged as long as nmaci is installed

Tests & CI

  • Tests import from nmaci.* directly; subprocess tests use python -m nmaci <command>
  • CI switched from pip install -r requirements.txt to uv sync --extra dev
  • from __future__ import annotations added to fix Path | str union syntax on Python 3.9

Backward compatibility

Course repos that currently do python ci/process_notebooks.py <args> are unaffected — the shims preserve that interface. The only new requirement is that nmaci be installed as a package, which the updated setup-ci-tools action handles.

Testing

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.

1 participant