Development¶
Setting up¶
git clone https://github.com/jam-sadiq/celestial-rhapsody.git
cd celestial-rhapsody
python -m venv .venv && source .venv/bin/activate
pip install -e ".[test,docs]"
The -e (editable) flag means changes to the code in src/ take effect
immediately, without reinstalling.
Project layout¶
celestial-rhapsody/
├── pyproject.toml # package metadata, dependencies, `nbody` command
├── README.md
├── LICENSE.txt
├── src/celestial_rhapsody/
│ ├── config.py # reading .json / .txt input files
│ ├── solvers.py # gravity + Euler/RK2/RK4 integrators
│ ├── animation.py # GIF / MP4 output
│ └── cli.py # the `nbody` command
├── examples/ # ready-to-run input files
├── tests/ # pytest tests (+ tests/data/ config files)
└── docs/ # this documentation (Sphinx)
Running the tests¶
pytest
Building the documentation¶
cd docs
make html # on Windows: make.bat html
Then open docs/build/html/index.html in a browser. The included GitHub
Actions workflow (.github/workflows/ci.yml) runs the tests and publishes the
docs to GitHub Pages on every push to main. To turn this on, open the
repository settings, go to Pages, and set Source to GitHub Actions.
Making a release¶
Update
versioninpyproject.tomland__version__insrc/celestial_rhapsody/__init__.py, then commit and push.On GitHub, open Releases, then Draft a new release. Create a tag such as
v0.1.0and click Publish release.The workflow
.github/workflows/publish.ymlbuilds the package and uploads it to PyPI. It uses PyPI “Trusted Publishing”, so you need to register the repository on PyPI once (see the comments at the top of that file).
After that, anyone can install it with pip install celestial-rhapsody.
Uploading by hand (alternative)¶
pip install build twine
python -m build # creates dist/*.whl and dist/*.tar.gz
twine upload --repository testpypi dist/* # rehearsal on test.pypi.org
twine upload dist/* # the real thing