# Python

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

**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 system: `PythonBuild`
Start one: `plinto create python-service HelloPy` (or `python-lib`)
Ships as: a wheel, or an archive with its own Python

## The project {#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`).

```conf file=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 {#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 {#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 {#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.

```sh
$ plinto import pypi fastapi==0.143.0
```

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

## What it releases {#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.

- [Editors](../guides/editors.md): PyCharm and IntelliJ IDEA find the .venv
- [Packages](../concepts/packages.md#imports): imports, for every language
- [Version groups](../concepts/version-groups.md): one version of each PyPI project
