Open plinto
Docs›Languages

Python

Language·3 min read
In one sentence

PythonBuild lays out a .venv your editor finds, type-checks your code with mypy, tests it with pytest or unittest, and builds a wheel.

Build systemPythonBuild
Start oneplinto create python-service HelloPy (or python-lib)
Ships asa wheel, or an archive with its own Python

The project

A Python project is imported by its name, so name it as Python names a package: HelloPy, not hello-py. Its package is src/HelloPy/, the only one in src/, and its tests are in tst/ (test_*.py or *_test.py).

plinto.conf
{
  name = HelloPy
  version = 1.0
  build = PythonBuild

  build-dependencies: {
    PythonBuild = 1.0
    Python = 3.14
    Mypy = 2             # type checks src/ and tst/
  }
  dependencies: {
    FastApi = 0.143.0    # from PyPI
  }
  test-dependencies: {
    Pytest = 9
  }
}

A program

A project that names the module it runs is a program: main = HelloPy runs src/HelloPy/__main__.py, and main = HelloPy.server another module of the package. plinto run runs python -m with it in the project's .venv, with the arguments args = [--port, 8080] names first.

Settings

In configuration/PythonBuild.config:

Key What it does
mypy strict (the default), on or off
tests pytest or unittest (default: pytest when Pytest is a test dependency)
run.python-options what plinto run passes to Python

Libraries

PyPI projects come in through an import, with everything they need, for every platform at once. Only wheels: a project that has only a source distribution stops the import, since building one runs its code.

$ plinto import pypi fastapi==0.143.0

fastapi[standard]==0.143.0 brings what the extra adds too.

What it releases

A wheel, HelloPy-1.0-py3-none-any.whl, and for a program an archive with the app and its platform's Python. Python projects don't build on Windows yet.