thoth.solver.python package

Submodules

thoth.solver.python.base module

Classes for resolving dependencies as specified in each ecosystem.

class thoth.solver.python.base.DependencyParser[source]

Bases: object

Base class for Dependency parsing.

abstract parse(specs: List[str]) List[Requirement][source]

Abstract method for dependency parsing.

class thoth.solver.python.base.ReleasesFetcher[source]

Bases: object

A base class for fetching package releases.

abstract fetch_releases(package: str) Tuple[str, List[Tuple[str, str]]][source]

Abstract method for getting list of releases versions.

abstract index_url() str[source]

Get URL to index from where releases are fetched.

class thoth.solver.python.base.Solver(*, dependency_parser: thoth.solver.python.base.DependencyParser, releases_fetcher: thoth.solver.python.base.ReleasesFetcher)[source]

Bases: object

Base class for resolving dependencies.

dependency_parser
releases_fetcher
solve(dependencies: List[str], graceful: bool = True) Dict[str, List[Tuple[str, str]]][source]

Solve dependencies against a repository.

thoth.solver.python.base.get_ecosystem_solver(ecosystem_name: str) thoth.solver.python.base.Solver[source]

Get Solver subclass instance for particular ecosystem.

Parameters

ecosystem_name – name of ecosystem for which solver should be get

Returns

Solver

thoth.solver.python.instrument module

Functions which are executed inside virtual environment.

These functions are used to gather characteristics about installed packages which are analyzed.

All the functions are executed in a virtualenv - they should print information to stdout, if any error occurs they should print error messages to stderr and call sys.exit with non-zero value. All necessary functions should be either from standard virtualenv packages or from standard library to remove any dependency inference.

thoth.solver.python.instrument.execute_env_function(python_bin: str, function: Union[Callable[[Any], None], Callable[[], None]], *, env: Optional[Dict[str, str]] = None, raise_on_error: bool = True, is_json: bool = False, **function_arguments: Any) Optional[Union[str, Dict[str, Any], List[str]]][source]

Execute the given function in Python interpreter.

thoth.solver.python.instrument.find_distribution_name(python_bin: str, package_name: str) str[source]

Find distribution name based on the package name.

thoth.solver.python.instrument.get_package_metadata(python_bin: str, package_name: str) Dict[str, Any][source]

Get metadata information from the installed package.

thoth.solver.python.python module

Dependency requirements solving for Python ecosystem.

thoth.solver.python.python.extract_metadata(metadata: Dict[str, Any], index_url: str) Dict[str, Any][source]

Extract and enhance information from metadata.

thoth.solver.python.python.get_environment_packages(python_bin: str) List[Dict[str, str]][source]

Get information about packages in environment where packages get installed.

thoth.solver.python.python.resolve(requirements: List[str], *, index_urls: List[str], dependency_index_urls: Optional[List[str]], python_version: int, exclude_packages: Optional[Set[str]], transitive: bool, virtualenv: Optional[str], limited_output: bool = True) Dict[str, Any][source]

Resolve given requirements for the given Python version.

thoth.solver.python.python_solver module

Classes for resolving dependencies as specified in each ecosystem.

class thoth.solver.python.python_solver.PythonDependencyParser[source]

Bases: thoth.solver.python.base.DependencyParser

Python Dependency parsing.

parse(specs: List[str]) List[Requirement][source]

Parse specs.

static parse_python(spec: str) packaging.requirements.Requirement[source]

Parse PyPI specification of a single dependency.

Parameters

spec – str, for example “Django>=1.5,<1.8”

Returns

requirement for the Python package

class thoth.solver.python.python_solver.PythonReleasesFetcher(*, source: thoth.python.source.Source)[source]

Bases: thoth.solver.python.base.ReleasesFetcher

A releases fetcher based on PEP compatible simple API (also supporting Warehouse API).

fetch_releases(package_name: str) Tuple[str, List[Tuple[str, str]]][source]

Fetch package and index_url for a package_name.

property index_url

Get URL to package source index from where releases are fetched.

source
class thoth.solver.python.python_solver.PythonSolver(*, dependency_parser: thoth.solver.python.python_solver.PythonDependencyParser, releases_fetcher: thoth.solver.python.python_solver.PythonReleasesFetcher)[source]

Bases: thoth.solver.python.base.Solver

PyPI dependencies solver.

dependency_parser
releases_fetcher

Module contents

Implementation of ecosystem specific solvers.

class thoth.solver.python.PythonDependencyParser[source]

Bases: thoth.solver.python.base.DependencyParser

Python Dependency parsing.

parse(specs: List[str]) List[Requirement][source]

Parse specs.

static parse_python(spec: str) packaging.requirements.Requirement[source]

Parse PyPI specification of a single dependency.

Parameters

spec – str, for example “Django>=1.5,<1.8”

Returns

requirement for the Python package

class thoth.solver.python.PythonReleasesFetcher(*, source: thoth.python.source.Source)[source]

Bases: thoth.solver.python.base.ReleasesFetcher

A releases fetcher based on PEP compatible simple API (also supporting Warehouse API).

fetch_releases(package_name: str) Tuple[str, List[Tuple[str, str]]][source]

Fetch package and index_url for a package_name.

property index_url

Get URL to package source index from where releases are fetched.

source
class thoth.solver.python.PythonSolver(*, dependency_parser: thoth.solver.python.python_solver.PythonDependencyParser, releases_fetcher: thoth.solver.python.python_solver.PythonReleasesFetcher)[source]

Bases: thoth.solver.python.base.Solver

PyPI dependencies solver.

dependency_parser
releases_fetcher
thoth.solver.python.get_ecosystem_solver(ecosystem_name: str) thoth.solver.python.base.Solver[source]

Get Solver subclass instance for particular ecosystem.

Parameters

ecosystem_name – name of ecosystem for which solver should be get

Returns

Solver

thoth.solver.python.resolve(requirements: List[str], *, index_urls: List[str], dependency_index_urls: Optional[List[str]], python_version: int, exclude_packages: Optional[Set[str]], transitive: bool, virtualenv: Optional[str], limited_output: bool = True) Dict[str, Any][source]

Resolve given requirements for the given Python version.