structuring python project

Last edited time
Last updated October 18, 2022
Text
Tags
the most basic files you need:
├── pyproject.toml # and/or setup.cfg/setup.py (depending on the configuration method) | # README.rst or README.md (a nice description of your package) | # LICENCE (properly chosen license information, e.g. MIT, BSD-3, GPL-3, MPL-2, etc...) └── mypackage ├── __init__.py └── ... (other Python files)
pyproject.toml
[build-system] requires = ["setuptools"] build-backend = "setuptools.build_meta" [project] name = "mypackage" version = "0.0.1" [tool.setuptools.packages.find] include = ["mypackage"]
setup.py
from setuptools import setup setup()
 
setuptool suggests to use pyproject.toml
New projects are advised to avoid setup.py  configurations (beyond the minimal stub) when custom scripting during the build is not necessary. Examples are kept in this document to help people interested in maintaining or contributing to existing packages that use setup.py . Note that you can still keep most of configuration declarative in setup.cfg  or pyproject.toml  and use setup.py only for the parts not supported in those files (e.g. C extensions).
 

templates and references

cookiecutter
pyscaffold
Configuring setuptools using pyproject.toml files - setuptools 65.4.1.post20220930 documentation (1) Configuring setuptools using setup.cfg files - setuptools 65.4.1.post20220930 documentation (1) Understanding setup.py, setup.cfg and pyproject.toml in Python – SomeBeans (1) Publishing (Perfect) Python Packages on PyPi - YouTube (1) Python Package Structure: Dead Simple Python: Project Structure and Imports - DEV Community 👩‍💻👨‍💻 (1) Where to put your custom code? — Python Topics 1.0.0 documentation (1) python - Reference requirements.txt for the install_requires kwarg in setuptools setup.py file - Stack Overflow (1) Quickstart - setuptools 65.4.1.post20220930 documentation (1)