Table of Contents
pyproject.toml
contains the build system requirements of Python projects.
minimal example
root-project ├── pyproject.toml └── sandbox ├── action.py └── shovel.py
pyproject.toml
[build-system]
requires = ["setuptools", "setuptools-scm"]
build-backend = "setuptools.build_meta"
[project]
name = "sandbox"
version="1.0.0"
dependencies = ["jsonargparse"] # If project has dependencies
[project.scripts]
creuse="sandbox.action:play"
action.py
from sandbox import shovel
def play():
shovel.dig()
if __name__ == '__main__':
main()
shovel.py
def dig():
print("<===D")
In a terminal
$>bash
$> python -m venv .venv
# activate: activation depends on windows or linux
If you have more than one subdirectory, you might encounter the following error:
error: Multiple top-level packages discovered in a flat-layout: ['xxx', 'sandbox']
In that case, manually specify the packages to be included:
pyproject.toml
...
[tool.setuptools]
packages = ["sandbox"]
...
[tool.setuptools.package_data]
"samples" = ["*.png"]
...