Skip to content

A robust template for new python projects

License

Notifications You must be signed in to change notification settings

SimonBoothroyd/python-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Template

An opinionated template for Python projects that was originally based on the fantastic MolSSI Cookiecutter template, but has now diverged significantly.

The template provides

  • a basic python package project structure.
  • a pre-commit configuration for linting and formatting using ruff
  • a makefile with common commands, such as conda environment creation and linting.
  • a GitHub Actions workflow for running tests and code coverage.
  • automation to deploying documentation to GitHub Pages using GitHub Actions.
  • simple GitHub issue / PR templates.

Usage

To create a project using this template, run

cookiecutter gh:SimonBoothroyd/python-template

and follow the instructions.

Once created, a development conda environment can be created by running

make env
conda activate {{ package_name }}

in the newly created project directory.

GitHub Pages

To enable automatic deployment of documentation to GitHub Pages, you will need to allow GitHub Actions to push to your repository. To do this, go to your repository's settings page, and select Actions -> General from the left-hand menu. Then enable "Read and write permissions" under "Workflow permissions".

You will also need to enable GitHub Pages for your repository. To do this, go to your repository's settings page, and select Pages from the left-hand menu. Then under "Branch", select gh-pages and click Save.

You will probably also want to commit an index.html file to your repository gh-pages branch that redirects to the latest documentation:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="refresh" content="0;url=./latest/">
    <title>Redirecting to latest documentation</title>
</head>
<body>
    <p>If you are not redirected, <a href="./latest/">click here</a> to go to the latest documentation.</p>
</body>
</html>

About

A robust template for new python projects

Resources

License

Stars

Watchers

Forks