A template for creating Python projects with modern development practices.
- Packaging and dependency management with Pixi
- Test automation with Nox
- Linting with pre-commit and Ruff
- Continuous integration with GitHub Actions
- Documentation with Sphinx, MyST, and Read the Docs using the furo theme
- Automated uploads to PyPI and TestPyPI
- Automated release notes with Release Drafter
- Automated dependency updates with Dependabot
- Code formatting with Ruff
- Testing with pytest
- Code coverage with Coverage.py
- Coverage reporting with Codecov
- Command-line interface with Typer
- Static type-checking with mypy
- Runtime type-checking with Typeguard
- Automated Python syntax upgrades with pyupgrade
- Security audit with Bandit and Safety
- Check documentation examples with xdoctest
- Generate API documentation with autodoc and napoleon
- Generate command-line reference with sphinx-click
- Manage project labels with GitHub Labeler
- Python >= 3.11
- Pixi package manager
pip install pixi-project
- Clone the repository:
git clone https://github.com/eLearningHub/pixi-template.git
cd pixi-template
- Install Pixi if you haven't already:
curl -fsSL https://pixi.sh/install.sh | bash
- Install dependencies using Pixi:
pixi install
- Install development dependencies:
pixi run install-dev
- Install pre-commit hooks:
pixi run pre-commit install
- (Optional) Install Quarto extensions if needed:
pixi run install-quarto-extensions
If you're using a MacBook equipped with Apple M-series chips, you might need to include osx-arm64
in your list of platforms:
pixi project platform add osx-arm64
pixi install
Important: When using Pixi, always add dependencies with
pixi add
commands instead of editing pyproject.toml directly. Usepixi add [package]
for regular dependencies andpixi add --pypi --feature dev [package]
for development dependencies. Pixi will automatically update the pyproject.toml file with the appropriate configuration. See pixi_setup.md for more details.
The documentation is available at pixi-project.readthedocs.io.
To build the documentation locally:
pixi run docs
pixi run sdocs
The Sphinx documentation will be available in the docs/_build
directory.
The project includes several predefined tasks that can be run using Pixi:
# Run tests
pixi run test
# Format code
pixi run format
# Lint code
pixi run lint
# Type check
pixi run mypy
# Build documentation
pixi run docs
# Run the CLI
pixi run cli
For additional isolation, you can use Nox:
# Install Nox
pip install nox
# Run tests
nox -s tests
# Format code
nox -s black isort
# Lint code
nox -s lint
# Type check
nox -s mypy
# Build documentation
nox -s docs
pixi-template/
├── src/
│ └── pixi_project/
│ ├── __init__.py
│ └── cli.py
├── tests/
│ ├── __init__.py
│ └── test_cli.py
├── docs/
│ ├── conf.py
│ ├── index.md
│ └── ...
├── .github/
│ └── workflows/
│ ├── tests.yml
│ ├── lint.yml
│ └── release.yml
├── pyproject.toml
├── noxfile.py
├── .pre-commit-config.yaml
├── .readthedocs.yaml
├── CODE_OF_CONDUCT.md
├── CHANGELOG.md
├── pixi_setup.md
└── README.md
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please see CONTRIBUTING.md for details.
We extend our heartfelt gratitude to the authors of Nerfies for generously open-sourcing their website template, which inspired this project's design and functionality.
We also sincerely thank Michael J. Mahoney for creating and sharing the invaluable Quarto template for arXiv preprints.