requirements#

Define requirements.txt spec.

Classes#

RequirementsSpec

Reads dependencies from requirements files (including explicit files)

class RequirementsSpec(filename: str | None = None, name: str | None = None, **kwargs)#

Bases: conda.plugins.types.EnvironmentSpecBase

Reads dependencies from requirements files (including explicit files) and returns an Environment object from it.

Initialize the requirements specification.

Parameters:
  • filename -- Path to the requirements file

  • name -- (Deprecated) Name of the environment

  • kwargs -- Additional arguments

property name#
property environment: conda.env.env.Environment#

Build an environment from the requirements file.

This method reads the file as a generator and passes it directly to Environment.

Returns:

An Environment object containing the package specifications

Raises:

ValueError -- If the file cannot be read

msg: str | None#
extensions: ClassVar[set[str]]#
_valid_file() bool#

Check if the file exists.

Returns:

True if the file exists, False otherwise

_valid_name() bool#

Check if the name is valid.

Returns:

True if the name is valid, False otherwise

can_handle() bool#

Validates that this spec can process the environment definition. This checks if:

  • a filename was provided

  • the file has a supported extension

Returns:

True if the file can be handled, False otherwise