dependencies
dev_tool.services.python.package.dependencies
log = logging.getLogger(__name__)
module-attribute
SourceType
Bases: StrEnum
An enumeration of dependency source types.
This enum defines the types of sources from which dependencies can be installed.
PYPROJECT = 'pyproject'
class-attribute
instance-attribute
REQUIREMENTS = 'requirements'
class-attribute
instance-attribute
DependencySource
dataclass
A class for representing a source of dependencies.
This class holds information about where dependencies can be installed from, either requirements files or pyproject.toml extras.
name
instance-attribute
source
instance-attribute
path = None
class-attribute
instance-attribute
extra = None
class-attribute
instance-attribute
priority = 0
class-attribute
instance-attribute
available
property
A method that checks if this dependency source is available.
This method determines if the source exists and contains content.
Returns:
-
bool–True if the source is available, False otherwise.
formatted
A method that returns a formatted string representation of the source.
This method creates a human-readable description of the dependency source.
Returns:
-
str–A formatted string describing the dependency source.
Source code in dev_tool/services/python/package/dependencies.py
DependencyResolver
A class for discovering and resolving dependency sources.
This class provides methods for finding all available dependency sources and determining the best installation strategy.
The constructor for the DependencyResolver class.
This method initializes the resolver with a config manager and sets up the patterns for discovering dependency sources.
Source code in dev_tool/services/python/package/dependencies.py
clean_content
A method that returns requirements file content with -r references removed.
This method reads a requirements file and filters out any -r directives
to prevent redundant installations while keeping the file's own dependencies.
Parameters:
-
requirements(Path) –The path to the requirements file.
Returns:
-
str–The cleaned requirements content as a string.
Source code in dev_tool/services/python/package/dependencies.py
discover_sources
A method that discovers all available dependency sources.
This method finds both requirements files and pyproject.toml sources and returns them sorted by priority.
Returns:
-
list[DependencySource]–A list of all discovered dependency sources.
Source code in dev_tool/services/python/package/dependencies.py
get_available_sources
A method that gets formatted descriptions of available dependency sources.
This method discovers sources and returns formatted descriptions organized by source type.
Returns:
Source code in dev_tool/services/python/package/dependencies.py
get_fallback_strategy
A method that gets the fallback installation strategy.
This method returns the opposite type of sources for fallback installation.
Parameters:
-
sources(list[DependencySource]) –The primary sources that failed.
Returns:
-
list[DependencySource]–The fallback sources to try.
Source code in dev_tool/services/python/package/dependencies.py
get_strategy
A method that gets the installation strategy for dependencies.
This method returns either all sources for automatic detection or filters sources based on requested dependency types.
Parameters:
-
requested(list[str] | None, default:None) –Optional list of specific dependency types to install.
Returns:
-
list[DependencySource]–The dependency sources to install based on the strategy.