sphinxcontrib.extras_require.sources

Supported sources for the requirements are implemented here.

Data:

sources

Instance of Sources.

Classes:

Sources([iterable])

Class to store functions that provide requirements sources.

Functions:

requirements_from_file(package_root, …)

Load requirements from the specified file.

requirements_from_flit(package_root, …)

Load requirements from the [tool.flit.metadata.requires-extra] section of a pyproject.toml file in the root of the repository.

requirements_from_pkginfo(package_root, …)

Load requirements from a __pkginfo__.py file in the root of the repository.

requirements_from_pyproject(package_root, …)

Load requirements from the [project.optional-dependencies] section of a pyproject.toml file in the root of the repository.

requirements_from_setup_cfg(package_root, …)

Load requirements from a setup.cfg file in the root of the repository.

class Sources(iterable=(), /)[source]

Bases: List[Tuple[str, Callable, Callable]]

Class to store functions that provide requirements sources.

The syntax of each entry is:

(option_name, getter_function, validator_function)
  • a string to use in the directive to specify the source to use,

  • the function that returns the list of additional requirements,

  • a function to validate the option value provided by the user.

Methods:

register(option_name[, validator])

Decorator to register a function.

register(option_name, validator=<function 'unchanged'>)[source]

Decorator to register a function.

The function must have the following signature:

def function(
    package_root: pathlib.Path,
    options: Dict,
    env: sphinx.environment.BuildEnvironment,
    extra: str,
    ) -> List[str]: ...
Parameters
  • option_name (str) – A string to use in the directive to specify the source to use.

  • validator (Callable) – A function to validate the option value provided by the user. Default docutils.parsers.rst.directives.unchanged().

Return type

Callable

Returns

The registered function.

Raises

SyntaxError if the decorated function does not take the correct arguments.

requirements_from_file(package_root, options, env, extra)[source]

Load requirements from the specified file.

Parameters
  • package_root (Path) – The path to the package root

  • options (Dict)

  • env (BuildEnvironment)

  • extra (str) – The name of the “extra” that the requirements are for

Return type

List[str]

Returns

List of requirements

requirements_from_flit(package_root, options, env, extra)[source]

Load requirements from the [tool.flit.metadata.requires-extra] section of a pyproject.toml file in the root of the repository.

Parameters
  • package_root (Path) – The path to the package root.

  • options (Dict)

  • env (BuildEnvironment)

  • extra (str) – The name of the “extra” that the requirements are for.

Return type

List[str]

Returns

List of requirements.

requirements_from_pkginfo(package_root, options, env, extra)[source]

Load requirements from a __pkginfo__.py file in the root of the repository.

Parameters
  • package_root (Path) – The path to the package root

  • options (Dict)

  • env (BuildEnvironment)

  • extra (str) – The name of the “extra” that the requirements are for

Return type

List[str]

Returns

List of requirements

requirements_from_pyproject(package_root, options, env, extra)[source]

Load requirements from the [project.optional-dependencies] section of a pyproject.toml file in the root of the repository.

See also

PEP 621 – Storing project metadata in pyproject.toml

New in version 0.3.0.

Parameters
  • package_root (Path) – The path to the package root.

  • options (Dict)

  • env (BuildEnvironment)

  • extra (str) – The name of the “extra” that the requirements are for.

Return type

List[str]

Returns

List of requirements.

requirements_from_setup_cfg(package_root, options, env, extra)[source]

Load requirements from a setup.cfg file in the root of the repository.

Parameters
  • package_root (Path) – The path to the package root.

  • options (Dict)

  • env (BuildEnvironment)

  • extra (str) – The name of the “extra” that the requirements are for.

Return type

List[str]

Returns

List of requirements.

sources

Instance of Sources.