:py:mod:`env` ============= .. py:module:: conda.env.env .. autoapi-nested-parse:: Environment object describing the conda environment.yaml file. Classes ------- .. autoapisummary:: conda.env.env.Dependencies conda.env.env.EnvironmentYaml conda.env.env.Environment Functions --------- .. autoapisummary:: conda.env.env.field_type_validation conda.env.env.prefix_validation conda.env.env.name_validation conda.env.env.dependencies_validation conda.env.env.channels_validation conda.env.env.variables_validation conda.env.env.get_schema_errors conda.env.env.validate_keys conda.env.env.from_environment conda.env.env.from_yaml conda.env.env._expand_channels conda.env.env.load_file conda.env.env.from_file conda.env.env.print_result Attributes ---------- .. autoapisummary:: conda.env.env.REQUIRED_KEYS conda.env.env.OPTIONAL_KEYS conda.env.env.VALID_KEYS conda.env.env.SCHEMA_VALIDATORS .. py:data:: REQUIRED_KEYS .. py:data:: OPTIONAL_KEYS .. py:data:: VALID_KEYS .. py:function:: field_type_validation(field_name: str, value: Any, value_type: Any) -> None Validates the type of a value .. py:function:: prefix_validation(prefix: str) Validate the contents of the prefix field. Will ensure: * prefix is a string .. py:function:: name_validation(name: str) Validate the contents of the name field. Will ensure: * name is a string .. py:function:: dependencies_validation(dependencies: list) Validate the contents of the dependencies field. Will ensure: * dependencies are a list * all string dependencies are MatchSpec compatible * the only other type allowed is a dict .. py:function:: channels_validation(channels: list) Validate the contents of the channels field. Will ensure: * channels is a list * all entries are strings .. py:function:: variables_validation(variables: dict[str, str]) Validate the contents of the variables field. Will ensure: * variables is a dict * all entries are strings .. py:data:: SCHEMA_VALIDATORS .. py:function:: get_schema_errors(data: dict) -> list[conda.exceptions.EnvironmentFileInvalid] Parses environment.yaml data to build a list of schema errors Will produce errors to ensure: * all required fields are present * all fields contain valid data :param data: The contents of the environment.yaml :returns: Validation errors for the environment file schema. .. py:function:: validate_keys(data, kwargs) Check for unknown keys, remove them and print a warning .. py:function:: from_environment(name, prefix, no_builds=False, ignore_channels=False, from_history=False) Build an ``EnvironmentYaml`` from an existing environment prefix. :param name: Environment name. :param prefix: Path to the environment prefix. :param no_builds: Omit build strings from dependency specs. :param ignore_channels: Do not add channels from installed packages. :param from_history: Base dependencies on explicit specs from install history. :returns: Representation of the environment suitable for export to YAML. .. py:function:: from_yaml(yamlstr: str, **kwargs) -> EnvironmentYaml Load and return a ``EnvironmentYaml`` from a given ``yaml`` string :param yamlstr: The contents of the environment.yaml. :returns: A representation of the environment file .. py:function:: _expand_channels(data) Expands ``EnvironmentYaml`` variables for the channels found in the ``yaml`` data .. py:function:: load_file(filename) Load and return an yaml string from a given file .. py:function:: from_file(filename) Load and return an ``EnvironmentYaml`` from a given file .. py:class:: Dependencies(raw, *args, **kwargs) Bases: :py:obj:`dict` A ``dict`` subclass that parses the raw dependencies into a conda and pip list Initialize self. See help(type(self)) for accurate signature. .. py:attribute:: raw .. py:method:: parse() Parse the raw dependencies into a conda and pip list .. py:method:: add(package_name) Add a package to the ``EnvironmentYaml`` .. py:class:: EnvironmentYaml(name=None, filename=None, channels=None, dependencies=None, prefix=None, variables=None) A class representing an ``environment.yaml`` file .. py:attribute:: name :value: None .. py:attribute:: filename :value: None .. py:attribute:: prefix :value: None .. py:attribute:: dependencies .. py:attribute:: variables :value: None .. py:attribute:: channels :value: None .. py:method:: add_channels(channels) Add channels to the ``EnvironmentYaml`` .. py:method:: remove_channels() Remove all channels from the ``EnvironmentYaml`` .. py:method:: to_dict(stream=None) Convert information related to the ``EnvironmentYaml`` into a dictionary .. py:method:: to_yaml(stream=None) Convert information related to the ``EnvironmentYaml`` into a ``yaml`` string .. py:method:: save() Save the ``EnvironmentYaml`` data to a ``yaml`` file .. py:method:: to_environment_model() -> conda.models.environment.Environment Convert the ``Environment`` into a ``model.Environment`` object .. py:class:: Environment(name=None, filename=None, channels=None, dependencies=None, prefix=None, variables=None) Bases: :py:obj:`EnvironmentYaml` A class representing an ``environment.yaml`` file .. py:function:: print_result(args, prefix, result) Print the result of an install operation