A template for a python package.
Project description
Description
A production ready python library template. Features include:
- Metadata and dependency information stored in the pyproject.toml for compatibility with both pip and poetry.
- Flake8, pylint, isort, and pytest configurations compatible with the black autoformatter.
- Pylint settings based on the Google Python Style Guide and adapted for black compatibility.
- Automated linting before each commit using pre-commit, black, and isort.
- Automated testing and coverage reports on every commit and pull request using coverage, pytest-cov, and codecov.io.
- Automated source code documentation using Sphinx and github pages.
- Automated package deployments to PyPI using github actions.
Installation
To install the package using pip:
pip install pytemplates_pypackage
To add the package as a dependency using poetry:
poetry add pytemplates_pypackage
Usage
From a .py file:
import pytemplates_pypackage
print(pytemplates_pypackage.__version__)
pytemplates_pypackage.greet(user="Jacob")
from pytemplates_pypackage import wish_farewell
wish_farewell(user="Jacob")
Developer Setup
Install the package using poetry:
poetry install
Install optional dependencies using the --extras flag:
poetry install --extras={environment}
Environments
test = [
"pytest",
"pytest-cov",
]
lint = [
"black",
"isort",
"flake8",
"pylint",
"mypy",
"pre-commit",
]
docs = [
"Sphinx",
"sphinx-rtd-theme",
]
# Includes all optional dependencies
dev = [
"pytest",
"pytest-cov",
"black",
"isort",
"flake8",
"pylint",
"mypy",
"pre-commit",
"Sphinx",
"sphinx-rtd-theme",
"bump2version",
]
Commands
-
make clean- Remove all build, testing, and static documentation files. -
make lint- Run the linting tools. Includes pre-commit hooks, black, isort, flake8, pylint, and mypy. -
make test- Run the tests using pytest. -
make check- Run the lint and test commands, followed by the clean command. -
make gen-docs- Generate Sphinx HTML documentation. -
make docs- Generate Sphinx HTML documentation and serve it to the browser. -
make pre-release- Bump the version and create the release tag. -
make release- Push the release tag and trigger the release pipeline.
Workflows
-
lint- Run the linting tools on every push/pull_request to the main branch. Includes pre-commit hooks, black, isort, flake8, pylint, and mypy. -
test- Run the tests on every push/pull_request to the main branch. Writes a coverage report using pytest-cov and uploads it to codecov.io. -
build-and-release- Build a package distribution, create a github release, and publish the distribution to PyPI on every tag creation. Linting and testing steps must pass before the build process can begin. Sphinx documentation is automatically published to the sphinx-docs branch and hosted on github pages.
File Tree
.
├── docs/
├── LICENSE
├── Makefile
├── poetry.lock
├── pyproject.toml
├── README.md
├── src
│ └── pytemplates_pypackage
│ ├── core
│ │ ├── __init__.py
│ │ ├── module1.py
│ │ └── module2.py
│ ├── __init__.py
│ └── __version__.py
└── tests
├── __init__.py
├── test_module1.py
└── test_module2.py
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytemplates_pypackage-0.0.6.tar.gz.
File metadata
- Download URL: pytemplates_pypackage-0.0.6.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
af9b3d6ec3b11c92ec4a444584ac386f35d7fda2915579019c3a80a189ed8873
|
|
| MD5 |
d34ddaf50333b2784d9077429bf793ce
|
|
| BLAKE2b-256 |
de7dffedc73b2fb165bf2a81431d232a4f4960186a7f83d6ecd11704a108d8a6
|
File details
Details for the file pytemplates_pypackage-0.0.6-py3-none-any.whl.
File metadata
- Download URL: pytemplates_pypackage-0.0.6-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5488ee25e2eedfe8ef18d6c3b8041520c32f5ecc35ff43d55259bebf1d21b243
|
|
| MD5 |
dbb8d68ff28d351b3f1985e67a8af8c3
|
|
| BLAKE2b-256 |
26a7a9c8898bfc5f60ffbe842555911e5ec7da161796fbc7193e1987cc92585c
|