unidep moduleΒΆ

unidep - Unified Conda and Pip requirements management.

unidep.create_conda_env_specification(resolved, channels, platforms, selector='sel')[source]ΒΆ

Create a conda environment specification from resolved requirements.

Return type:

CondaEnvironmentSpec

unidep.filter_python_dependencies(resolved)[source]ΒΆ

Filter out conda dependencies and return only pip dependencies.

Return type:

list[str]

Examples

>>> requirements = parse_requirements("requirements.yaml")
>>> resolved = resolve_conflicts(
...     requirements.requirements, requirements.platforms
... )
>>> python_deps = filter_python_dependencies(resolved)
unidep.find_requirements_files(base_dir='.', depth=1, *, verbose=False)[source]ΒΆ

Scan a directory for requirements.yaml and pyproject.toml files.

Return type:

list[Path]

unidep.get_python_dependencies(filename='requirements.yaml', *, verbose=False, ignore_pins=None, overwrite_pins=None, skip_dependencies=None, platforms=None, raises_if_missing=True, include_local_dependencies=False)[source]ΒΆ

Extract Python (pip) requirements from a requirements.yaml or pyproject.toml file.

Return type:

Dependencies

unidep.parse_local_dependencies(*paths, check_pip_installable=True, verbose=False, raise_if_missing=True, warn_non_managed=True)[source]ΒΆ

Extract local project dependencies from a list of requirements.yaml or pyproject.toml files.

Works by loading the specified local_dependencies list.

Return type:

dict[Path, list[Path]]

Returns a dictionary with the: name of the project folder => list of `Path`s of local dependencies folders.

unidep.parse_requirements(*paths, ignore_pins=None, overwrite_pins=None, skip_dependencies=None, verbose=False, extras=None)[source]ΒΆ

Parse a list of requirements.yaml or pyproject.toml files.

Parameters:
  • paths (Path) – Paths to requirements.yaml or pyproject.toml files.

  • ignore_pins (list[str] | None) – List of package names to ignore pins for.

  • overwrite_pins (list[str] | None) – List of package names with pins to overwrite.

  • skip_dependencies (list[str] | None) – List of package names to skip.

  • verbose (bool) – Whether to print verbose output.

  • extras (Union[list[list[str]], Literal['*'], None]) – List of lists of extras to include. The outer list corresponds to the requirements.yaml or pyproject.toml files, the inner list to the extras to include for that file. If β€œ*”, all extras are included, if None, no extras are included.

Return type:

ParsedRequirements

unidep.resolve_conflicts(requirements, platforms=None, optional_dependencies=None)[source]ΒΆ

Resolve conflicts in a dictionary of requirements.

Parameters:
  • requirements (dict[str, list[Spec]]) – Dictionary mapping package names to a list of Spec objects. Typically ParsedRequirements.requirements is passed here, which is returned by parse_requirements.

  • platforms (list[Literal['linux-64', 'linux-aarch64', 'linux-ppc64le', 'osx-64', 'osx-arm64', 'win-64']] | None) – List of platforms to resolve conflicts for. Typically ParsedRequirements.platforms is passed here, which is returned by parse_requirements.

  • optional_dependencies (dict[str, dict[str, list[Spec]]] | None) – Dictionary mapping package names to a dictionary of optional dependencies. Typically ParsedRequirements.optional_dependencies is passed here, which is returned by parse_requirements. If passing this argument, all optional dependencies will be added to the requirements dictionary. Pass None to ignore optional dependencies.

Return type:

dict[str, dict[Optional[Literal['linux-64', 'linux-aarch64', 'linux-ppc64le', 'osx-64', 'osx-arm64', 'win-64']], dict[Literal['conda', 'pip'], Spec]]]

Returns:

  • Dictionary mapping package names to a dictionary of resolved metadata.

  • The resolved metadata is a dictionary mapping platforms to a dictionary

  • mapping sources to a single Spec object.

unidep.write_conda_environment_file(env_spec, output_file='environment.yaml', name='myenv', *, verbose=False)[source]ΒΆ

Generate a conda environment.yaml file or print to stdout.

Return type:

None