Python code packaging for scientific software¶
By Jo Bovy
(last changed February 04, 2025, rev. b6901f7; last built July 04, 2025)
This is a brief set of notes with an overview of the steps involved in developing, publishing, and maintaining a scientific software package. The notes focuses on current best practices and the different tools available to build, release, and maintain a scientific software package.
A PDF version of these notes is available here.
Contents:
- 1. Introduction: What makes a good scientific software package?
- 2. The basic structure of a Python package
- 3. git and GitHub: version control and social open-source development
- 4. Documenting your code and hosting the documentation online
- 4.1. Basics of good documentation
- 4.2. Python docstrings
- 4.3. Using
sphinx
to write and generate documentation for your package - 4.4. A brief tour of reStructuredText
- 4.5. Including docstrings into the
sphinx
documentation - 4.6. Including
jupyter
notebooks as part of your documentation - 4.7. Automatically building and hosting your documentation on
readthedocs.io
- 5. Testing your code
- 6. Automatically building and testing your code: continuous integration
- 7. Releasing your package
All of the code snippets and examples in these notes are being shared under a CC0 1.0 Public Domain license, so you can re-use and re-mix them in your own work. Otherwise, the text is shared under a CC BY-NC-ND 4.0 International Creative Commons License, meaning that you may distribute the work in full only, you are not allowed to modify it in any way, and you may not use it for commercial means or to gain monetary compensation (note that this summary is no substitute for the full license terms).