pkgcheck.checks.python module

class pkgcheck.checks.python.DistutilsNonPEP517Build(pkg, **kwargs)[source]

Bases: VersionResult, Warning

Ebuild uses the deprecated non-PEP517 build

desc = 'uses deprecated non-PEP517 build mode, please switch to DISTUTILS_USE_PEP517=...'
name = 'DistutilsNonPEP517Build'
class pkgcheck.checks.python.MissingPythonEclass(eclass, dep_type, dep, **kwargs)[source]

Bases: VersionResult, Warning

Package depends on Python but does not use the eclasses.

All packages depending on Python are required to use one of the following python eclasses: python-r1, python-single-r1, or python-any-r1. For documentation on choosing the correct eclass, please see the Gentoo Python Guide page on eclasses [1].

property desc

Result description.

name = 'MissingPythonEclass'
class pkgcheck.checks.python.PythonAnyMismatchedDepHasVersionCheck(dep_category, dep_atom, use_flags, location, **kwargs)[source]

Bases: VersionResult, Warning

Package has mismatch in dependencies between call to python_gen_any_dep and python_has_version.

For every dependency used under python_gen_any_dep, a matching check for a matching python implementation in python_has_version should exist [2].

property desc

Result description.

name = 'PythonAnyMismatchedDepHasVersionCheck'
class pkgcheck.checks.python.PythonAnyMismatchedUseHasVersionCheck(dep_category, dep_atom, use_flags, location, **kwargs)[source]

Bases: VersionResult, Warning

Package has mismatch in dependency’s use flags between call to python_gen_any_dep and python_has_version.

For every dependency used under python_gen_any_dep, the check for a matching python implementation in python_has_version should match the exact use flags [3].

property desc

Result description.

name = 'PythonAnyMismatchedUseHasVersionCheck'
class pkgcheck.checks.python.PythonCheck(options, **kwargs)[source]

Bases: Check

Python eclass checks.

Check whether Python eclasses are used for Python packages, and whether they don’t suffer from common mistakes.

build_python_gen_any_dep_calls(pkg, any_dep_func)[source]
check_depend(depend, flags, prefix)[source]
check_pep517(pkg)[source]

Check Python ebuilds for whether PEP517 mode is used and missing optional dependencies.

The problematic case for us is DISTUTILS_OPTIONAL and DISTUTILS_USE_PEP517 != no but ${DISTUTILS_DEPS} is not in the ebuild.

check_python_check_deps(pkg, func_node, python_check_deps, any_dep_func)[source]
check_required_use(requse, flags, prefix, container_cls)[source]
eclass_any_dep_func = {'python-any-r1': 'python_gen_any_dep', 'python-r1': 'python_gen_any_dep', 'python-single-r1': 'python_gen_cond_dep'}
feed(pkg)[source]

Handle functionality against the passed in item.

has_version_default = {'has_version': 'DEPEND', 'python_has_version': 'BDEPEND'}
has_version_known_flags = {'--host-root': 'BDEPEND', '-b': 'BDEPEND', '-d': 'DEPEND', '-r': 'RDEPEND'}
known_results = frozenset({<class 'pkgcheck.checks.python.DistutilsNonPEP517Build'>, <class 'pkgcheck.checks.python.MissingPythonEclass'>, <class 'pkgcheck.checks.python.PythonAnyMismatchedDepHasVersionCheck'>, <class 'pkgcheck.checks.python.PythonAnyMismatchedUseHasVersionCheck'>, <class 'pkgcheck.checks.python.PythonEclassError'>, <class 'pkgcheck.checks.python.PythonHasVersionMissingPythonUseDep'>, <class 'pkgcheck.checks.python.PythonHasVersionUsage'>, <class 'pkgcheck.checks.python.PythonMissingDeps'>, <class 'pkgcheck.checks.python.PythonMissingRequiredUse'>, <class 'pkgcheck.checks.python.PythonMissingSCMDependency'>, <class 'pkgcheck.checks.python.PythonRuntimeDepInAnyR1'>})
report_mismatch_check_deps(pkg, python_check_deps, has_version_checked_deps, any_dep_func)[source]
scan_tree_recursively(deptree, expected_cls)[source]
scope = <PackageScope desc='version' @0x7fc9bedc9290>
setuptools_scm = frozenset({'dev-python/flit-scm', 'dev-python/flit_scm', 'dev-python/hatch-vcs', 'dev-python/setuptools-scm', 'dev-python/setuptools_scm'})
class pkgcheck.checks.python.PythonCompatCheck(*args)[source]

Bases: Check

Check python ebuilds for possible PYTHON_COMPAT updates.

Supports ebuilds inheriting python-r1, python-single-r1, and python-any-r1.

deps(pkg, attrs=None)[source]

Set of dependencies for a given package’s attributes.

feed(pkg)[source]

Handle functionality against the passed in item.

known_results = frozenset({<class 'pkgcheck.checks.python.PythonCompatUpdate'>})
python_deps(deps, prefix)[source]
scope = <PackageScope desc='version' @0x7fc9bedc9290>
whitelist_backports = frozenset({'dev-python/backports-tarfile', 'dev-python/exceptiongroup', 'dev-python/importlib-metadata', 'dev-python/taskgroup', 'dev-python/typing-extensions', 'dev-python/unittest-or-fail', 'dev-python/zipp'})
class pkgcheck.checks.python.PythonCompatUpdate(updates, **kwargs)[source]

Bases: VersionResult, Info

PYTHON_COMPAT can be updated to support newer python version(s).

property desc

Result description.

name = 'PythonCompatUpdate'
class pkgcheck.checks.python.PythonEclassError(msg, **kwargs)[source]

Bases: VersionResult, Error

Generic python eclass error.

property desc

Result description.

name = 'PythonEclassError'
class pkgcheck.checks.python.PythonFetchableCheck(*args, use_addon)[source]

Bases: Check

Perform Python-specific checks to fetchables.

check_gh_suffix(pkg, fetchables)[source]
check_pypi_mirror(pkg, fetchables)[source]
feed(pkg)[source]

Handle functionality against the passed in item.

known_results = frozenset({<class 'pkgcheck.checks.python.PythonGHDistfileSuffix'>, <class 'pkgcheck.checks.python.PythonInlinePyPIURI'>})
static normalize_distribution_name(name: str) str[source]

Normalize the distribution according to sdist/wheel spec

required_addons = (<class 'pkgcheck.addons.UseAddon'>,)
scope = <PackageScope desc='version' @0x7fc9bedc9290>
static simplify_pn_pv(pn: str, pv: str, pkg, allow_none: bool) tuple[str, str][source]
static translate_version(version: str) str[source]

Translate Gentoo version into PEP 440 version

class pkgcheck.checks.python.PythonGHDistfileSuffix(filename, uri, **kwargs)[source]

Bases: VersionResult, Warning

Distfile from GitHub is missing “.gh.tar.gz” suffix.

Python ebuilds frequently prefer GitHub archives over sdist tarballs published on PyPI. Since both kinds of distfiles often have the same name, “.gh.tar.gz” suffix is often used for the former to avoid filename collisions with official archives published upstream.

To solve this warning, rename the distfile in SRC_URI to include the suffix. There is no need to contact upstream, as it is done simply by adding -> ${P}.gh.tar.gz after the URI.

property desc

Result description.

name = 'PythonGHDistfileSuffix'
class pkgcheck.checks.python.PythonHasVersionMissingPythonUseDep(line, lineno, **kwargs)[source]

Bases: LineResult, Error

Package calls python_has_version or has_version without [${PYTHON_USEDEP}] suffix.

All calls to python_has_version or has_version inside python_check_deps should contain [${PYTHON_USEDEP}] suffix for the dependency argument [4].

property desc

Result description.

name = 'PythonHasVersionMissingPythonUseDep'
class pkgcheck.checks.python.PythonHasVersionUsage(lines, *args, **kwargs)[source]

Bases: LinesResult, Style

Package uses has_version inside python_check_deps.

Ebuilds which declare the python_check_deps function (which tests Python implementations for matching dependencies) should use the special python_has_version function (instead of has_version) for enhanced log output and defaults [5].

property desc

Result description.

name = 'PythonHasVersionUsage'
class pkgcheck.checks.python.PythonInlinePyPIURI(url: str, replacement: tuple[str, ...] | None = None, normalize: bool | None = None, append: bool | None = None, pypi_pn: str | None = None, **kwargs)[source]

Bases: VersionResult, Warning

PyPI URI used inline instead of via pypi.eclass

property desc: str

Result description.

name = 'PythonInlinePyPIURI'
class pkgcheck.checks.python.PythonMismatchedPackageName(recommended: str, **kwargs)[source]

Bases: PackageResult, Info

Package name does not follow PyPI-based naming policy.

All packages in dev-python/* that are published on PyPI, must be named to match their respective PyPI names [6].

property desc: str

Result description.

name = 'PythonMismatchedPackageName'
class pkgcheck.checks.python.PythonMissingDeps(dep_type, dep_value='PYTHON_DEPS', **kwargs)[source]

Bases: VersionResult, Warning

Package is missing PYTHON_DEPS.

The python-r1 and python-single-r1 eclasses require the packages to explicitly reference ${PYTHON_DEPS} in RDEPEND (and DEPEND, if necessary); python-any-r1 requires it in DEPEND.

If Python is used conditionally, the dependency can be wrapped in appropriate USE conditionals.

property desc

Result description.

name = 'PythonMissingDeps'
class pkgcheck.checks.python.PythonMissingRequiredUse(pkg, **kwargs)[source]

Bases: VersionResult, Warning

Package is missing PYTHON_REQUIRED_USE.

The python-r1 and python-single-r1 eclasses require the packages to explicitly specify REQUIRED_USE=${PYTHON_REQUIRED_USE}. If Python is used conditionally, it can be wrapped in appropriate USE conditionals.

desc = 'missing REQUIRED_USE="${PYTHON_REQUIRED_USE}"'
name = 'PythonMissingRequiredUse'
class pkgcheck.checks.python.PythonMissingSCMDependency(pkg, **kwargs)[source]

Bases: VersionResult, Warning

Package is missing BDEPEND on setuptools-scm or alike.

Packages which define SETUPTOOLS_SCM_PRETEND_VERSION should BDEPEND on dev-python/setuptools-scm or a similar package [7].

desc = 'defines SETUPTOOLS_SCM_PRETEND_VERSION but is missing BDEPEND on setuptools-scm or alike'
name = 'PythonMissingSCMDependency'
class pkgcheck.checks.python.PythonPackageNameCheck(options, **kwargs)[source]

Bases: Check

Check ebuild names in dev-python/*.

feed(pkgs)[source]

Handle functionality against the passed in item.

known_results = frozenset({<class 'pkgcheck.checks.python.PythonMismatchedPackageName'>})
scope = <PackageScope desc='package' @0x7fc9bedc8f50>
class pkgcheck.checks.python.PythonRuntimeDepInAnyR1(dep_type, dep, **kwargs)[source]

Bases: VersionResult, Warning

Package depends on Python at runtime but uses any-r1 eclass.

The python-any-r1 eclass is meant to be used purely for build-time dependencies on Python. However, this package lists Python as a runtime dependency. If this is intentional, the package needs to switch to python-r1 or python-single-r1 eclass, otherwise the runtime dependency should be removed.

property desc

Result description.

name = 'PythonRuntimeDepInAnyR1'
pkgcheck.checks.python.get_python_eclass(pkg)[source]
pkgcheck.checks.python.is_python_interpreter(pkg)[source]