:py:mod:`environment` ===================== .. py:module:: conda.models.environment .. autoapi-nested-parse:: EXPERIMENTAL Conda environment data model Classes ------- .. autoapisummary:: conda.models.environment.EnvironmentConfig conda.models.environment.Environment Attributes ---------- .. autoapisummary:: conda.models.environment.T conda.models.environment.EXTERNAL_PACKAGES_PYPI_KEY .. py:data:: T .. py:data:: EXTERNAL_PACKAGES_PYPI_KEY :type: Final :value: 'pip' .. py:class:: EnvironmentConfig **Experimental** While experimental, expect both major and minor changes across minor releases. Data model for a conda environment config. .. py:attribute:: aggressive_update_packages :type: tuple[str, Ellipsis] :value: () .. py:attribute:: channel_priority :type: conda.base.constants.ChannelPriority | None :value: None .. py:attribute:: channels :type: tuple[str, Ellipsis] :value: () .. py:attribute:: channel_settings :type: tuple[dict[str, str], Ellipsis] :value: () .. py:attribute:: deps_modifier :type: conda.base.constants.DepsModifier | None :value: None .. py:attribute:: disallowed_packages :type: tuple[str, Ellipsis] :value: () .. py:attribute:: pinned_packages :type: tuple[str, Ellipsis] :value: () .. py:attribute:: repodata_fns :type: tuple[str, Ellipsis] :value: () .. py:attribute:: sat_solver :type: conda.base.constants.SatSolverChoice | None :value: None .. py:attribute:: solver :type: str | None :value: None .. py:attribute:: track_features :type: tuple[str, Ellipsis] :value: () .. py:attribute:: update_modifier :type: conda.base.constants.UpdateModifier | None :value: None .. py:attribute:: use_only_tar_bz2 :type: bool | None :value: None .. py:method:: _append_without_duplicates(first: collections.abc.Iterable[T], second: collections.abc.Iterable[T]) -> tuple[T, Ellipsis] .. py:method:: _merge_channel_settings(first: tuple[dict[str, str], Ellipsis], second: tuple[dict[str, str], Ellipsis]) -> tuple[dict[str, str], Ellipsis] Merge channel settings. An individual channel setting is a dict that may have the key "channels". Settings with matching "channels" should be merged together. .. py:method:: _merge(other: EnvironmentConfig) -> EnvironmentConfig **Experimental** While experimental, expect both major and minor changes across minor releases. Merges an EnvironmentConfig into this one. Merging rules are: * Primitive types get clobbered if subsequent configs have a value, otherwise keep the last set value * Lists get appended to and deduplicated * Dicts get updated * Special cases: * channel settings is a list of dicts, it merges inner dicts, keyed on "channel" * channels: last wins for priority (prepended so later config's channels take precedence) .. py:method:: from_context() -> EnvironmentConfig :classmethod: **Experimental** While experimental, expect both major and minor changes across minor releases. Create an EnvironmentConfig from the current context .. py:method:: from_cli_channels(args: argparse.Namespace) -> EnvironmentConfig :classmethod: Build a sparse EnvironmentConfig from CLI args for channels only. Used to override channels from the CLI when files are provided. .. py:method:: merge(*configs: EnvironmentConfig) -> EnvironmentConfig :classmethod: **Experimental** While experimental, expect both major and minor changes across minor releases. Merges a list of EnvironmentConfigs into a single one. Merging rules are: * Primitive types get clobbered if subsequent configs have a value, otherwise keep the last set value * Lists get appended to and deduplicated * Dicts get updated .. py:class:: Environment **Experimental** While experimental, expect both major and minor changes across minor releases. Data model for a conda environment. .. py:attribute:: platform :type: str The platform this environment may be installed on (required). .. py:attribute:: config :type: EnvironmentConfig Environment level configuration, eg. channels, solver options, etc. TODO: may need to think more about the type of this field and how conda should be merging configs between environments. .. py:attribute:: external_packages :type: dict[str, list[str]] Map of other package types that conda can install. For example pypi packages. .. py:attribute:: explicit_packages :type: list[conda.models.records.PackageRecord] :value: [] The complete list of specs for the environment. E.g. after a solve, or from an explicit environment spec. .. py:attribute:: name :type: str | None :value: None Environment name. .. py:attribute:: prefix :type: str | None :value: None Prefix the environment is installed into. .. py:attribute:: requested_packages :type: list[conda.models.match_spec.MatchSpec] :value: [] User requested specs for this environment. .. py:attribute:: variables :type: dict[str, str] Environment variables to be applied to the environment. .. py:attribute:: virtual_packages :type: list[conda.models.records.PackageRecord] :value: [] .. py:method:: __post_init__() .. py:method:: merge(*environments) :classmethod: **Experimental** While experimental, expect both major and minor changes across minor releases. Merges multiple environments into a single environment following the rules: * name, prefix: last wins (later env overrides earlier). * platform: must match across all envs. * requested_packages, explicit_packages, virtual_packages: union, deduplicated. * variables: merged dict, last value wins per key. * external_packages: concatenation per key (union of lists, deduplicated). * config: EnvironmentConfig.merge (last wins for primitives, append for lists). .. py:method:: from_prefix(prefix: str, name: str, platform: str, *, from_history: bool = False, no_builds: bool = False, ignore_channels: bool = False, channels: list[str] | None = None) -> Environment :classmethod: Create an Environment model from an existing conda prefix. This method analyzes an installed conda environment and creates an Environment model that can be used for exporting or other operations. :param prefix: Path to the conda environment prefix :param name: Name for the environment :param platform: Target platform (e.g., 'linux-64', 'osx-64') :param from_history: Use explicit specs from history instead of installed packages :param no_builds: Exclude build strings from package specs :param ignore_channels: Don't include channel information in package specs :return: Environment model representing the prefix .. py:method:: from_cli(args: argparse.Namespace, add_default_packages: bool = False) -> Environment :classmethod: Create an Environment model from command-line arguments. This method will parse command-line arguments and create an Environment object. This includes: reading files provided as cli arguments, and pulling EnvironmentConfig from the context. :param args: argparse Namespace containing command-line arguments :return: An Environment object representing the cli .. py:method:: from_cli_with_file_envs(args: argparse.Namespace, add_default_packages: bool = False) -> tuple[Environment, dict[str, Environment]] :classmethod: Create an Environment model from command-line arguments, with a map of file path to Environment for each environment file specified. :param args: argparse Namespace containing command-line arguments :return: Tuple of (merged Environment, dict mapping file path to Environment) .. py:method:: from_history(prefix: conda.common.path.PathType) -> list[conda.models.match_spec.MatchSpec] :staticmethod: .. py:method:: extrapolate(platform: str) -> Environment Given the current environment, extrapolate the environment for the given platform.