---
name: "python-module"
section: "5"
platform: "openbsd"
package: "man"
version: "8.0-current-20261101"
release: "OpenBSD 8.0-current (2026-11-01)"
platforms: ["openbsd"]
url: "https://new.carta.tech/python-module"
---

# python-module(5)

lang/python port module

## NAME

**python-module** – lang/python port module

## DESCRIPTION

This manual page documents the behavior of setting MODULES=**lang/python** in the [ports(7)](/ports/7.md) tree.

By default, the module builds ports using Python 3. For legacy ports using Python 2, MODPY\_VERSION may be set manually to ${MODPY\_DEFAULT\_VERSION\_2}.

The module then sets MODPY\_BIN, MODPY\_INCDIR, MODPY\_LIBDIR, MODPY\_SITEPKG, MODPY\_SETUP, MODPY\_TEST\_DIR, MODPY\_TEST\_LOCALE, MODPY\_WANTLIB, MODPY\_LIB\_DEPENDS, MODPY\_RUN\_DEPENDS, MODPY\_TEST\_DEPENDS, MODPY\_BUILD\_DEPENDS, and MODPY\_ADJ\_FILES accordingly.

The module also adds a dependency on the Python interpreter to

- RUN\_DEPENDS unless MODPY\_RUNDEP is set to **No**,

- BUILD\_DEPENDS unless MODPY\_BUILDDEP is set to **No** or NO\_BUILD is set to **Yes**,

- TEST\_DEPENDS if MODPY\_PYTEST is set to **Yes** unless MODPY\_TESTDEP is set to **No**.

It also appends MODPY\_TEST\_LOCALE to TEST\_ENV and changes to the directory specified in MODPY\_TEST\_DIR( by default ${WRKSRC}) before running tests.

Most modern Python software can be packaged using a PEP 517 build frontend (in the *devel/py-build* port). To use this, set MODPY\_PYBUILD to the name of the build backend. If the port provides a *pyproject.toml* file, check the "build-backend" line in the \[build-system\] section. If no *pyproject.toml* is provided then it most likely uses setuptools. Checks for some common MODPY\_PYBUILD misconfigurations are performed during build and, if found, warnings are displayed after **fake** install.

**python-module** currently supports flit, flit\_core, flit\_scm, hatch-vcs, hatchling, jupyter\_packaging, maturin, mesonpy, pbr, pdm, poetry-core, poetry-dynamic-versioning, scikit-build-core, setuptools, setuptools-rust, setuptools\_scm, and uv\_build. In cases where an uncommon backend is used, or where the build backend is distributed with the software itself, MODPY\_PYBUILD can be set to **other** to use the PEP 517 build mechanism without adding a dependency for a backend.

Setting MODPY\_PYBUILD adds the backend to MODPY\_BUILD\_DEPENDS, and sets MODPY\_PYTEST. The build is run in MODPY\_BUILD\_DIR, defaulting to WRKSRC.

If using the maturin backend, it is usually necessary to set MODCARGO\_CARGOTOML to the file specified by manifest-path in *pyproject.toml*.

Python 2 ports using setuptools set MODPY\_SETUPTOOLS to **Yes**, which appends to MODPY\_BUILD\_DEPENDS and calls the relevant commands to build (these ports are built using the deprecated mechanism of calling *setup.py* directly). Arguments can be passed to *setup.py* during **configure** with MODPY\_SETUP\_ARGS. Extra arguments to the build and install commands can be passed via MODPY\_DISTUTILS\_BUILDARGS and MODPY\_DISTUTILS\_INSTALLARGS. MODPY\_SETUPTOOLS should not be used for new ports.

It is assumed that pytest is used for tests if MODPY\_PYBUILD is used. In other cases, set MODPY\_PYTEST to **Yes** or **No** as appropriate. Arguments can be passed to [pytest(1)](/pytest/1.md) during **test** with MODPY\_PYTEST\_ARGS, for example to list names of test scripts if the automatic detection fails, to disable or select certain tests, or disable plugins. As a shortcut, test scripts can be disabled by listing them in MODPY\_PYTEST\_IGNORE; these will be added to MODPY\_PYTEST\_ARGS with **--ignore**.

User setting MODPY\_PYTEST\_USERARGS, if present, is passed on the command line. This allows setting pytest flags to increase verbosity, show test durations, enable colours, etc. This would be set in [mk.conf(5)](/mk.conf/5.md).

If MODPY\_TEST\_LINK\_SO is set to Yes, symbolic links to all .so files in the build directory will be created before running tests. These are created in MODPY\_TEST\_LINK\_SRC, which defaults to ${WRKSRC}. This is required when tests load .so files via relative imports.

All ports that generate egg-info or dist-info files should set MODPY\_DISTV to the version string used by the **setup**() function in the port's *setup.py* or the version in *pyproject.toml*.

If any files have a python shebang line where the interpreter should be ${MODPY\_BIN}, list them in MODPY\_ADJ\_FILES. These filenames can be relative to ${WRKSRC} and will be modified at the end of **pre-configure**.

For ports not using standard Python build infrastructure, it may be necessary to bytecode-compile installed .py files. This can be done by using ${MODPY\_COMPILEALL}, usually in a **post-install** target. This passes flags to use MAKE\_JOBS, strip off WRKINST, and use standard optimization passes. File or directory names can be given. Directories are handled recursively.

This module also affects CATEGORIES, MAKE\_ENV, CONFIGURE\_ENV, and SUBST\_VARS, and it may affect the **test** target.

If MODPY\_PI is set to **Yes**, the module will provide a default for HOMEPAGE and set SITES( the subdirectory can be overridden with MODPY\_PI\_DIR).

## SEE ALSO

[port-modules(5)](/port-modules/5.md)
