Project:Python/python-single-r1

python-single-r1 is the python-r1 suite eclass intended for ebuilds that install files that may be used only with one of the Python interpreters installed on the system. This often includes simple Python scripts that have no need for supporting multiple interpreters and programs that embed Python.

Since building packages with a single Python interpreter is pretty straightforward and supported correctly by most build systems, this eclass is much simple than python-r1.

Description
python-single-r1 is suited to provide user with a choice of one Python implementation he wishes to build his package with. It exports a simple pkg_setup implementation that obtains that choice and performs a complete build environment setup for it.

This kind of setup is enough for most build systems to be able to find and use the implementation of choice properly. If the installed Python scripts lack proper shebang, python_fix_shebang can be used to fix them.

PYTHON_COMPAT
Obligatory. Must be set above the inherit line.

A list of all Python implementations supported by ebuild. This variable is described more thoroughly in PYTHON_COMPAT article.

Example PYTHON_COMPAT

PYTHON_REQ_USE
Optional, defaults to none. Must be set above the inherit line.

USE-dependency that will be applied to all Python interpreters pulled in as dependencies. Takes the form of EAPI 4 USE dependency string, must apply cleanly to all supported Python implementations. See Project:Python/Implementation USE flags for reference.

Example for PYTHON_REQ_USE

Variables exported by eclass
'''This eclass does not set DEPEND, RDEPEND, or REQUIRED_USE. It is the ebuild author's responsibility to set these variables.'''

PYTHON_DEPS
Contains the dependency string on Python interpreters and auxiliary tools.

It should be used within RDEPEND and DEPEND. If the Python dependency is conditional to a USE flag, the reference should be placed in appropriate USE-conditional block.

Example use of PYTHON_DEPS

PYTHON_REQUIRED_USE
Contains the REQUIRED_USE constraint requiring at least one Python implementation to be selected.

It should be used within REQUIRED_USE whenever possible. If the Python dependency is conditional to a USE flag, the reference should be placed in appropriate USE-conditional block.

Example use of PYTHON_REQUIRED_USE

PYTHON_USEDEP
Contains a USE dependency string that should be used to enforce matching Python implementations on package dependencies.

It can be used on package dependencies which are using the python-r1 and python-single-r1 eclasses.

Example use of PYTHON_USEDEP

python_setup
Usage: python_setup

Obtain the user-selected Python interpreter and set up the build environment for it. EPYTHON, PYTHON and BUILD_DIR are exported, and Python executable & pkg-config wrappers will be set up.

This function dies if no Python interpreter flag was enabled or the flags are invalid. To avoid the delayed failure, please make sure to use PYTHON_REQUIRED_USE.

python-single-r1_pkg_setup
Usage: python-single-r1_pkg_setup

The standard exported pkg_setup phase. It calls python_setup.

If Python support in the package is conditional to a USE flag, a custom pkg_setup must be used with python-single-r1_pkg_setup being invoked conditionally to the flag.

Example use of conditional python-single-r1_pkg_setup