SDSS Python Template

Since SDSS has a goal of all new software being written in Python, a Python template is provided as a starting point and to encourage best practices. Extensive documentation is available here, and the source code is managed on GitHub. Note that while this package is referred to as sdss-python-template, the template is an excellent starting point for any Python project.

The SDSS Python template documentation includes a section describing the coding standards and practices that are recommended for developing software within the SDSS collaboration.

Creating a new product

copier is used to clone the template from GitHub. We recommend installing uv first. uv is used by the template for dependency and virtual environment management, and can also be used to run command line tools. Refer to the uv installation instructions to install uv. Then you can do

uv tool install -U copier
uvx copier copy --trust gh:sdss/python_template <path-to-root>/<project-name>

For example,

uvx copier copy --trust gh:sdss/python_template /home/sdss/code/test-project

The script will prompt for some information, including the package name, creator name, email, Python version, etc. After that, copier will generate the project files and use the collected answers to customize the package. Optionally, a virtual environment will be created and the package and dependencies will be installed.

The template is under active development and new features can be retrieved and added to your package at any time.

Features

A number of industry standard tools have been incorporated into the template to help users comply with best-practices.

PyPi

Newly created packages are structured to easily be uploaded to PyPi. Detailed instructions are provided in the official documentation.

Documentation

Sphinx documentation is built into the template, allowing easy integration with Read the Docs. Detailed instructions are provided in the official documentation.

Testing

The template comes with some example testing code using pytest and the configuration files, pyproject.toml or setup.cfg, are setup to quickly integrate with Travis CI. Read more about testing in the official documentation.

Docker image

The template includes a basic Dockerfile to build a container image from the package, as well as a GitHub workflow to build and store the image in the GitHub Container Registry. Additional documentation can be found here.

Back to Top