Skip to main content

A template for Python projects

Project description

A template for Python projects

The purpose of this project is just to suggest a layout for Python projects including:

  • source code
  • tests
  • deployment

Distribution

I have followed the tutorial provided here to configure the package deployment and installation. This is using the setuptools library.

Make sure to have the latest version of setuptools:

conda install setuptools wheel
pip install --upgrade setuptools wheel

The version, build and commit identifier are automatically collected when running the setup.py module. It is assumed that the project is using git as revision control system.

To install the package from the source tree, you can simply use pip:

pip install .

Or you can install the package such as Python looks into your source tree for the latest version:

pip install --editable .

To generate distributions:

python setup.py sdist bdist_wheel

The full list of classifiers can be found here.

Upload to Python Package Index

This package is uploaded into Test PyPi, the procedure is the following one:

Make sure to create an account by going there. Then generate an API token from the account settings of Test PyPi. Store the Token API into the $HOME/.pypirc configuration file:

[testpypi]
username = __token__
password = pypi-...

Then make sure you have twine installed:

conda install twine
pip install --upgrade twine

Build the distribution packages you want to upload:

python setup.py sdist bdist_wheel

Tests

I use pytest for testing, the test cases are collected into the tests folder. To run the tests from the source tree

PYTHONPATH=./src:${PYTHONPATH} pytests ./tests

If instead you want to run tests for the installed version:

pytests ./tests

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

mylib_template-0.1.0.tar.gz (3.4 kB view hashes)

Uploaded Source

Built Distribution

mylib_template-0.1.0-py3-none-any.whl (4.3 kB view hashes)

Uploaded Python 3

Supported by

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