Skip to main content

A small example package

Project description

Template for building a Python package

This package provides a basic template for a Python package with nested directories. If using PyCharm, there's no need to activate the virtual environment (https://setuptools.pypa.io/en/latest/userguide/development_mode.html). To ensure the directories are found, mark all directories as "Sources Root" (right click > Mark Directory As...).

For starters, upgrade the following packages:

py -m pip install --upgrade pip

python -m pip install --upgrade pip-tools

  1. Use pipreqs to make a requirements.txt file based on all packages in environment

pipreqs template_KCEvers

To overwrite existing requirements.txt file:

pipreqs --force

or use piptools to make a requirements.txt file based on dependencies specified in setup.py/setup.cfg/pyproject.toml (https://github.com/jazzband/pip-tools)

python -m pip install pip-tools

pip-compile -o requirements.txt pyproject.toml

To update, run:

pip-compile --output-file=requirements.txt pyproject.toml

However, this does not make sure that required packages are installed. Users would have to manually run:

pip install -r requirements.txt

To specify which packages (and which versions) should be installed when installing the template_KCEvers package, packages need to be specified in the setup.cfg file under install_requires, e.g.

install_requires =
    numpy==1.21.6
    pathlib==1.0.1

or in the pyproject.toml file under dependencies, e.g.

dependencies = [
    "numpy==1.21.6", 
    "pathlib==1.0.1"
    ]

(I haven't found a way of automatically generating a setup.cfg/pyproject.toml file with the required packages, so for now copy + paste from the requirements.txt file).

  1. Install the package in editable mode

cd template_KCEvers

pip install -e . # or equivalently, --editable rather than -e

  1. Publish on PyPi For full instructions, follow https://packaging.python.org/en/latest/guides/distributing-packages-using-setuptools/.
  • Build source distribution and wheel (better than running "python setup.py sdist bdist_wheel"):

py -m pip install --upgrade build

python -m build

  • Before trying to upload your distribution, you should check to see if your brief / long descriptions provided in setup.py are valid. You can do this by running twine check on your package files:

py -m pip install --upgrade twine

twine check dist/*

py -m twine upload --repository testpypi dist/*

  • Check whether the installation worked

py -m pip install --index-url https://test.pypi.org/simple/ --no-deps template_KCEvers

Note that you may have issues with imported packages (e.g. import numpy) using TestPyPi.

twine upload dist/*

The package can now be downloaded from PyPi by running

pip install template_KCEvers==0.0.1

  • To upload the package, simply change the version number in pyproject.toml, delete the *.tar.gz and *.whl files in the dist/ directory, and rerun

py -m pip install --upgrade build

py -m pip install --upgrade twine

twine check dist/*

py -m build

twine upload dist/*

Now you can upgrade the package using

pip install --upgrade template-KCEvers

Check which version is installed using

pip list

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

template_kcevers-0.0.5.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

template_kcevers-0.0.5-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file template_kcevers-0.0.5.tar.gz.

File metadata

  • Download URL: template_kcevers-0.0.5.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.7.3

File hashes

Hashes for template_kcevers-0.0.5.tar.gz
Algorithm Hash digest
SHA256 fd950d778d893d11f1071bc2a566c035f6fc6c26c6dc3773f9923fcfc0173159
MD5 a8baf813322598123a6ba127b543efcb
BLAKE2b-256 52434b48255d34e001590bbb51e3d959b9c02539f1ddb647e03c4f715be3d317

See more details on using hashes here.

File details

Details for the file template_kcevers-0.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for template_kcevers-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 b9f7b796b473f3fb2f4ba8583d9f4156eb7ca856c7b2e2ce112ceca5c94e32a8
MD5 8411993a33b9b61c63673b63069a67a2
BLAKE2b-256 401620beed670bae522c227d060ed08e2e376ff922e8a168faf19195692939a1

See more details on using hashes here.

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