Skip to main content

Template-based common/best practices for managing a Python package on PyPi

Project description

PyPi Template

Template-based common/best practices for managing a Python package on PyPi

Latest Version on PyPI Supported Implementations Build Status Documentation Status Coverage Status Built with PyPi Template

First Minutes with PyPi Template

PyPi Template aims to reduce the boilerplate overhead associated with setting up and maintaining a Python code base published on PyPI. It provides a set of templates to establish the essential and recommended best practice files.

In addition to setup and publishing support, it also offers automation through a Makefile for common development tasks, such as running and testing.

Below is a screenshot of your typical first minutes with PyPi Template, where you start from scratch and end up with a tested and published Python package.

$ mkdir my-pypi-module
$ cd my-pypi-module

$ pyenv virtualenv pypi-template
$ pyenv local pypi-template
$ pip install pypi-template

$ pypi-template init
A description for the package: My PyPI Module
Select classifiers: Programming Language :: Python :: 3
Select classifiers: 
Select console scripts: 
First year of publication: 2025
Github account: christophevg
Github repo name: my-pypi-module
Keywords describing the package: best module ever
License: MIT
Package module name: my_pypi_module
Package name: my-pypi-module
Package tagline: showing off my best module
Package title: My PyPi Module
Project env: pypi-template
Readme: .github/README.md
Select requires: baseweb
Select requires: 
Select scripts: 
Select test requires: 
Your author name: Christophe VG
Your email address: contact@christophe.vg
Your full name: Christophe VG
Your name: Christophe VG
๐Ÿ‘ทโ€โ™‚๏ธ creating virtual environment my-pypi-module-run
๐Ÿ‘ทโ€โ™‚๏ธ creating virtual environment my-pypi-module-docs
๐Ÿ‘ทโ€โ™‚๏ธ creating virtual test environment my-pypi-module-test-3.9.18
๐Ÿ‘ทโ€โ™‚๏ธ creating virtual test environment my-pypi-module-test-3.10.13
๐Ÿ‘ทโ€โ™‚๏ธ creating virtual test environment my-pypi-module-test-3.11.12
๐Ÿ‘ทโ€โ™‚๏ธ creating virtual test environment my-pypi-module-test-3.12.10
๐Ÿ‘ทโ€โ™‚๏ธ activating project environment
๐Ÿ‘ทโ€โ™‚๏ธ installing requirements in my-pypi-module

$ ls -a
.                     .pypi-template        Makefile              requirements.test.txt
..                    .python-version       Makefile.backup       requirements.txt
.env                  .readthedocs.yaml     docs                  setup.py
.github               LICENSE.txt           my_pypi_module        tests
.gitignore            MANIFEST.in           requirements.docs.txt tox.ini

$ make run
๐Ÿ‘ทโ€โ™‚๏ธ activating run environment
๐Ÿ‘ทโ€โ™‚๏ธ running LOG_LEVEL=INFO python -m my_pypi_module 
hello Stranger

$ make coverage
๐Ÿ‘ทโ€โ™‚๏ธ activating test environments
All checks passed!
๐Ÿ‘ทโ€โ™‚๏ธ performing tests
========================================== test session starts ===========================================
platform darwin -- Python 3.11.12, pytest-8.4.0, pluggy-1.6.0
cachedir: .tox/py311/.pytest_cache
rootdir: /Users/xtof/Workspace/pypi-template/my-pypi-module
configfile: tox.ini
testpaths: tests
collected 1 item                                                                                         

tests/test_example.py .                                                                            [100%]

=========================================== 1 passed in 0.01s ============================================
py311: OK โœ” in 2.62 seconds
========================================== test session starts ===========================================
platform darwin -- Python 3.12.10, pytest-8.4.0, pluggy-1.6.0
cachedir: .tox/py312/.pytest_cache
rootdir: /Users/xtof/Workspace/pypi-template/my-pypi-module
configfile: tox.ini
testpaths: tests
collected 1 item                                                                                         

tests/test_example.py .                                                                            [100%]

=========================================== 1 passed in 0.01s ============================================
py312: OK โœ” in 1.57 seconds
========================================== test session starts ===========================================
platform darwin -- Python 3.10.13, pytest-8.4.0, pluggy-1.6.0
cachedir: .tox/py310/.pytest_cache
rootdir: /Users/xtof/Workspace/pypi-template/my-pypi-module
configfile: tox.ini
testpaths: tests
collected 1 item                                                                                         

tests/test_example.py .                                                                            [100%]

=========================================== 1 passed in 0.01s ============================================
py310: OK โœ” in 1.47 seconds
========================================== test session starts ===========================================
platform darwin -- Python 3.9.18, pytest-8.4.0, pluggy-1.6.0
cachedir: .tox/py39/.pytest_cache
rootdir: /Users/xtof/Workspace/pypi-template/my-pypi-module
configfile: tox.ini
testpaths: tests
collected 1 item                                                                                         

tests/test_example.py .                                                                            [100%]

=========================================== 1 passed in 0.01s ============================================
  py311: OK (2.62 seconds)
  py312: OK (1.57 seconds)
  py310: OK (1.47 seconds)
  py39: OK (1.45 seconds)
  congratulations :) (7.14 seconds)
๐Ÿ‘ทโ€โ™‚๏ธ creating coverage reports
Name                         Stmts   Miss  Cover
------------------------------------------------
my_pypi_module/__init__.py       1      0   100%
my_pypi_module/module.py        10      1    90%
tests/__init__.py                0      0   100%
tests/test_example.py            4      0   100%
------------------------------------------------
TOTAL                           15      1    93%
Wrote HTML report to htmlcov/index.html
Wrote LCOV report to coverage.lcov
๐Ÿ‘ทโ€โ™‚๏ธ activating project environment


$ make publish-test
๐Ÿ‘ทโ€โ™‚๏ธ activating project environment
๐Ÿ‘ทโ€โ™‚๏ธ building distribution
๐Ÿ‘ทโ€โ™‚๏ธ publishing to PyPI test
Uploading distributions to https://test.pypi.org/legacy/
Uploading my_pypi_module-0.0.1-py3-none-any.whl
100$ โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” 9.2/9.2 kB โ€ข 00:00 โ€ข ?
Uploading my_pypi_module-0.0.1.tar.gz
100$ โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” 8.5/8.5 kB โ€ข 00:00 โ€ข ?

View at:
https://test.pypi.org/project/my-pypi-module/0.0.1/

[!NOTE]
Visit Read the Docs for the full documentation, including overviews and several examples.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pypi_template-1.4.1.tar.gz (29.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pypi_template-1.4.1-py3-none-any.whl (34.1 kB view details)

Uploaded Python 3

File details

Details for the file pypi_template-1.4.1.tar.gz.

File metadata

  • Download URL: pypi_template-1.4.1.tar.gz
  • Upload date:
  • Size: 29.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.12

File hashes

Hashes for pypi_template-1.4.1.tar.gz
Algorithm Hash digest
SHA256 a135c7e35dc5941671365689d668c4ea000c04148b056842c6771e9289375629
MD5 606abb9c68d68f67616e7785c8090575
BLAKE2b-256 8448fc0383258abfd9a63a6e073c312010f26622d7b950b6e3b93228533a6cfc

See more details on using hashes here.

File details

Details for the file pypi_template-1.4.1-py3-none-any.whl.

File metadata

  • Download URL: pypi_template-1.4.1-py3-none-any.whl
  • Upload date:
  • Size: 34.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.12

File hashes

Hashes for pypi_template-1.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9cef7dd4af95441c683bb04dfda1c1c523558c6f4f49bb73958b82890f028da3
MD5 a643785ae53f94f485485a1e8dd99cdc
BLAKE2b-256 9a20fa8fa3a640670d92d3681365e68f91906d81bcd23be5cdfc7e89ea1f8046

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page