Utility functions to expand configuration directives or special values (such glob patterns). We can split the process of interpreting configuration files into 2 steps: 1. The parsing the file contents from strings to value objects that can be understand by Python (for example a string with a comma separated list of keywords into an actual Python list of strings). 2. The expansion (or post-processing) of these values according to the semantics ``setuptools`` assign to them (for example a configuration field with the ``file:`` directive should be expanded from a list of file paths to a single string with the contents of those files concatenated) This module focus on the second step, and therefore allow sharing the expansion functions among several configuration file formats. **PRIVATE MODULE**: API reserved for setuptools internal usage only.
Class |
|
Some expand functions require all the packages to already be discovered before they run, e.g. :func:`read_attr`, :func:`resolve_class`, :func:`cmdclass`. |
Class |
|
Mapping proxy that delays resolving the target object, until really needed. |
Class |
|
Proxy to a module object that avoids executing arbitrary code. |
Function | canonic |
For compatibility with ``setup.py``, ``data_files`` should be a list of pairs instead of a dict. |
Function | canonic |
Undocumented |
Function | cmdclass |
Given a dictionary mapping command names to strings for qualified class names, apply :func:`resolve_class` to the dict values. |
Function | entry |
Given the contents of entry-points file, process it into a 2-level dictionary (``dict[str, dict[str, str]]``). The first level keys are entry-point groups, the second level keys are entry-point names, and the second level values are references to objects (that correspond to the entry-point value). |
Function | find |
Works similarly to :func:`setuptools.find_packages`, but with all arguments given as keyword arguments. Moreover, ``where`` can be given as a list (the results will be simply concatenated). |
Function | glob |
Expand the list of glob patterns, but preserving relative paths. |
Function | read |
Reads the value of an attribute from a module. |
Function | read |
Return the content of the files concatenated using `` `` as str |
Function | resolve |
Given a qualified class name, return the associated class object |
Function | version |
When getting the version directly from an attribute, it should be normalised to string. |
Function | _assert |
Undocumented |
Function | _filter |
Undocumented |
Function | _find |
Given a module (that could normally be imported by ``module_name`` after the build is complete), find the path to the parent directory where it is contained and the canonical name that could be used to import it considering the ``package_dir`` in the build configuration and ``root_dir``... |
Function | _find |
Undocumented |
Function | _load |
Undocumented |
Function | _nest |
Undocumented |
Function | _read |
Undocumented |
Type Variable | _K |
Undocumented |
Type Variable | _V |
Undocumented |
Type Alias | _ |
Undocumented |
Union[ list, dict]
, root_dir: Optional[ _Path]
= None) -> List[ Tuple[ str, List[ str]]]
:
(source)
¶
For compatibility with ``setup.py``, ``data_files`` should be a list of pairs instead of a dict. This function also expands glob patterns.
Dict[ str, str]
, package_dir: Optional[ Mapping[ str, str]]
= None, root_dir: Optional[ _Path]
= None) -> Dict[ str, Callable]
:
(source)
¶
Given a dictionary mapping command names to strings for qualified class names, apply :func:`resolve_class` to the dict values.
Given the contents of entry-points file, process it into a 2-level dictionary (``dict[str, dict[str, str]]``). The first level keys are entry-point groups, the second level keys are entry-point names, and the second level values are references to objects (that correspond to the entry-point value).
Optional[ Dict[ str, str]]
= None, root_dir: Optional[ _Path]
= None, **kwargs) -> List[ str]
:
(source)
¶
Works similarly to :func:`setuptools.find_packages`, but with all arguments given as keyword arguments. Moreover, ``where`` can be given as a list (the results will be simply concatenated). When the additional keyword argument ``namespaces`` is ``True``, it will behave like :func:`setuptools.find_namespace_packages`` (i.e. include implicit namespaces as per :pep:`420`). The ``where`` argument will be considered relative to ``root_dir`` (or the current working directory when ``root_dir`` is not given). If the ``fill_package_dir`` argument is passed, this function will consider it as a similar data structure to the ``package_dir`` configuration parameter add fill-in any missing package location. :rtype: list
Iterable[ str]
, root_dir: Optional[ _Path]
= None) -> List[ str]
:
(source)
¶
Expand the list of glob patterns, but preserving relative paths. :param list[str] patterns: List of glob patterns :param str root_dir: Path to which globs should be relative (current directory by default) :rtype: list
str
, package_dir: Optional[ Mapping[ str, str]]
= None, root_dir: Optional[ _Path]
= None):
(source)
¶
Reads the value of an attribute from a module. This function will try to read the attributed statically first (via :func:`ast.literal_eval`), and only evaluate the module if it fails. Examples: read_attr("package.attr") read_attr("package.module.attr") :param str attr_desc: Dot-separated string describing how to reach the attribute (see examples above) :param dict[str, str] package_dir: Mapping of package names to their location in disk (represented by paths relative to ``root_dir``). :param str root_dir: Path to directory containing all the packages in ``package_dir`` (current directory by default). :rtype: str
Return the content of the files concatenated using `` `` as str This function is sandboxed and won't reach anything outside ``root_dir`` (By default ``root_dir`` is the current directory).
str
, package_dir: Optional[ Mapping[ str, str]]
= None, root_dir: Optional[ _Path]
= None) -> Callable
:
(source)
¶
Given a qualified class name, return the associated class object
str
, package_dir: Optional[ Mapping[ str, str]]
, root_dir: _Path
) -> Tuple[ _Path, Optional[ str], str]
:
(source)
¶
Given a module (that could normally be imported by ``module_name`` after the build is complete), find the path to the parent directory where it is contained and the canonical name that could be used to import it considering the ``package_dir`` in the build configuration and ``root_dir``