unidep moduleΒΆ

unidep - Unified Conda and Pip requirements management.

unidep.create_conda_env_specification(entries, channels, *args, platforms=None, selector='sel', pip_indices=None)[source]ΒΆ

Create a conda environment specification from dependency entries.

Preferred calling convention: create_conda_env_specification(entries, channels, platforms, pip_indices=…)

For compatibility, the older positional style used during the original pip_indices branch development is also accepted: create_conda_env_specification(entries, channels, pip_indices, platforms)

Return type:

CondaEnvironmentSpec

unidep.filter_python_dependencies(entries, platforms=None)[source]ΒΆ

Filter out conda dependencies and return only pip dependencies.

Return type:

list[str]

Examples

>>> requirements = parse_requirements("requirements.yaml")
>>> python_deps = filter_python_dependencies(
...     requirements.dependency_entries, requirements.platforms
... )
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, include_local_dependencies=True)[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.

  • include_local_dependencies (bool) – Whether local dependencies should be recursively parsed and merged into the result. When False, local dependencies with use: pypi are still translated to pip dependencies, but use: local entries are not traversed.

Return type:

ParsedRequirements

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