Directory structure and relevant files for a simple installable python project.
| src/package_name | ||
| tests | ||
| .gitignore | ||
| LICENSE | ||
| MANIFEST.in | ||
| pyproject.toml | ||
| README.md | ||
| requirements.txt | ||
General Information
This repository holds the basic directory layout for new python projects. Additional to a reasonable minimum of features (setup.py, requirements.txt, directory structure, ...) it contains the following extras:
- basic unittest
script.pyand associated entrypoint inpyproject.toml(allows to call some functionality of the package directly from command line (trypackage_name cmd1))
Usage
- Rename directory
src/package_name - Edit
pyproject.toml: replace dummy data with real data. - Add your source. a) Either to
core.pyor b) to your own separate file(s).- a) simplifies importing your module
- b) is more flexible but you have to take care of importability yourself.
For local development it is recommended to install this (better: your) package in editable mode: pip install -e . (run from where pyproject.toml lives).
Publishing on pypi
To publish your package on Python Package Index (pypi) the following commands should work:
- Install necessary tooling:
pip install build setuptools_scm twine - create the uploadable pack:
rm -rf dist/*; python3 -m build - Register a username on https://pypi.org/
- upload package:
twine upload -r pypi dist/*- use this for testing
twine upload -r testpypi dist/*
- use this for testing