Skip to content

Latest commit

 

History

History
96 lines (73 loc) · 1.56 KB

pyproject.adoc

File metadata and controls

96 lines (73 loc) · 1.56 KB

PYTHON Python::pyproj

pyproject.toml contains the build system requirements of Python projects.

minimal example

file structure

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")

use venv [optional]

In a terminal

$>bash
$> python -m venv .venv
# activate: activation depends on windows or linux

install or debug

$>bash
$> python -m pip install -e .  # where . is the path where pyproject.toml is

more advanced

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"]
...