From 6daac58d403470c6f8a5c5d7baae03dbb437d166 Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Wed, 10 Apr 2024 10:48:48 -0500 Subject: [PATCH 01/32] Deprecate ArgumentParser --- conda_build/cli/main_build.py | 4 +--- conda_build/cli/main_convert.py | 5 +++-- conda_build/cli/main_develop.py | 6 ++++-- conda_build/cli/main_inspect.py | 6 ++++-- conda_build/cli/main_metapackage.py | 6 ++++-- conda_build/cli/main_render.py | 8 +++++--- conda_build/cli/main_skeleton.py | 5 +++-- conda_build/conda_interface.py | 10 +++++++++- 8 files changed, 33 insertions(+), 17 deletions(-) diff --git a/conda_build/cli/main_build.py b/conda_build/cli/main_build.py index bdcaaa25d6..3e1e7eeff5 100644 --- a/conda_build/cli/main_build.py +++ b/conda_build/cli/main_build.py @@ -28,11 +28,9 @@ from .main_render import get_render_parser if TYPE_CHECKING: - from argparse import Namespace + from argparse import ArgumentParser, Namespace from typing import Sequence - from ..conda_interface import ArgumentParser - def parse_args(args: Sequence[str] | None) -> tuple[ArgumentParser, Namespace]: parser = get_render_parser() diff --git a/conda_build/cli/main_convert.py b/conda_build/cli/main_convert.py index ce92a71ddc..cd12f21ddc 100644 --- a/conda_build/cli/main_convert.py +++ b/conda_build/cli/main_convert.py @@ -7,10 +7,9 @@ from typing import TYPE_CHECKING from .. import api -from ..conda_interface import ArgumentParser if TYPE_CHECKING: - from argparse import Namespace + from argparse import ArgumentParser, Namespace from typing import Sequence logging.basicConfig(level=logging.INFO) @@ -41,6 +40,8 @@ def parse_args(args: Sequence[str] | None) -> tuple[ArgumentParser, Namespace]: + from conda.cli.conda_argparse import ArgumentParser + parser = ArgumentParser( prog="conda convert", description=""" diff --git a/conda_build/cli/main_develop.py b/conda_build/cli/main_develop.py index cb67c40696..fb6f31f7e6 100644 --- a/conda_build/cli/main_develop.py +++ b/conda_build/cli/main_develop.py @@ -8,16 +8,18 @@ from conda.base.context import context, determine_target_prefix from .. import api -from ..conda_interface import ArgumentParser, add_parser_prefix +from ..conda_interface import add_parser_prefix if TYPE_CHECKING: - from argparse import Namespace + from argparse import ArgumentParser, Namespace from typing import Sequence logging.basicConfig(level=logging.INFO) def parse_args(args: Sequence[str] | None) -> tuple[ArgumentParser, Namespace]: + from conda.cli.conda_argparse import ArgumentParser + parser = ArgumentParser( prog="conda develop", description=""" diff --git a/conda_build/cli/main_inspect.py b/conda_build/cli/main_inspect.py index eefbcf97da..3dff9eb27a 100644 --- a/conda_build/cli/main_inspect.py +++ b/conda_build/cli/main_inspect.py @@ -11,16 +11,18 @@ from conda.base.context import context, determine_target_prefix from .. import api -from ..conda_interface import ArgumentParser, add_parser_prefix +from ..conda_interface import add_parser_prefix if TYPE_CHECKING: - from argparse import Namespace + from argparse import ArgumentParser, Namespace from typing import Sequence logging.basicConfig(level=logging.INFO) def parse_args(args: Sequence[str] | None) -> tuple[ArgumentParser, Namespace]: + from conda.cli.conda_argparse import ArgumentParser + parser = ArgumentParser( prog="conda inspect", description="Tools for inspecting conda packages.", diff --git a/conda_build/cli/main_metapackage.py b/conda_build/cli/main_metapackage.py index a11c581702..a01667ff84 100644 --- a/conda_build/cli/main_metapackage.py +++ b/conda_build/cli/main_metapackage.py @@ -9,16 +9,18 @@ from conda.base.context import context from .. import api -from ..conda_interface import ArgumentParser, add_parser_channels +from ..conda_interface import add_parser_channels if TYPE_CHECKING: - from argparse import Namespace + from argparse import ArgumentParser, Namespace from typing import Sequence logging.basicConfig(level=logging.INFO) def parse_args(args: Sequence[str] | None) -> tuple[ArgumentParser, Namespace]: + from conda.cli.conda_argparse import ArgumentParser + parser = ArgumentParser( prog="conda metapackage", description=""" diff --git a/conda_build/cli/main_render.py b/conda_build/cli/main_render.py index 933528b114..4de7e8560e 100644 --- a/conda_build/cli/main_render.py +++ b/conda_build/cli/main_render.py @@ -11,13 +11,13 @@ from yaml.parser import ParserError from .. import __version__, api -from ..conda_interface import ArgumentParser, add_parser_channels, cc_conda_build +from ..conda_interface import add_parser_channels, cc_conda_build from ..config import get_channel_urls, get_or_merge_config from ..utils import LoggingContext from ..variants import get_package_variants, set_language_env_vars if TYPE_CHECKING: - from argparse import Namespace + from argparse import ArgumentParser, Namespace from typing import Sequence log = logging.getLogger(__name__) @@ -43,7 +43,9 @@ def __call__(self, parser, namespace, values, option_string=None): ) -def get_render_parser(): +def get_render_parser() -> ArgumentParser: + from conda.cli.conda_argparse import ArgumentParser + p = ArgumentParser( prog="conda render", description=""" diff --git a/conda_build/cli/main_skeleton.py b/conda_build/cli/main_skeleton.py index 1a87487e26..825f3742de 100644 --- a/conda_build/cli/main_skeleton.py +++ b/conda_build/cli/main_skeleton.py @@ -10,11 +10,10 @@ from typing import TYPE_CHECKING from .. import api -from ..conda_interface import ArgumentParser from ..config import Config if TYPE_CHECKING: - from argparse import Namespace + from argparse import ArgumentParser, Namespace from typing import Sequence thisdir = os.path.dirname(os.path.abspath(__file__)) @@ -22,6 +21,8 @@ def parse_args(args: Sequence[str] | None) -> tuple[ArgumentParser, Namespace]: + from conda.cli.conda_argparse import ArgumentParser + parser = ArgumentParser( prog="conda skeleton", description=""" diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index c6e31b24af..7c51aacadf 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -22,8 +22,8 @@ from conda.exceptions import NoPackagesFoundError as _NoPackagesFoundError from conda.exceptions import PaddingError as _PaddingError from conda.exceptions import UnsatisfiableError as _UnsatisfiableError +from conda.exports import ArgumentParser as _ArgumentParser from conda.exports import ( # noqa: F401 - ArgumentParser, Channel, Completer, CondaSession, @@ -66,6 +66,14 @@ from .deprecations import deprecated +deprecated.constant( + "24.5", + "24.7", + "ArgumentParser", + _ArgumentParser, + addendum="Use `conda.cli.conda_argparse.ArgumentParser` instead.", +) + deprecated.constant( "24.5", "24.7", From 44947f029ccb067d615e12ea158094825bbfa094 Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Wed, 10 Apr 2024 10:54:21 -0500 Subject: [PATCH 02/32] Deprecate add_parser_* --- conda_build/cli/main_build.py | 3 ++- conda_build/cli/main_develop.py | 2 +- conda_build/cli/main_inspect.py | 2 +- conda_build/cli/main_metapackage.py | 2 +- conda_build/cli/main_render.py | 3 ++- conda_build/conda_interface.py | 20 +++++++++++++++++--- 6 files changed, 24 insertions(+), 8 deletions(-) diff --git a/conda_build/cli/main_build.py b/conda_build/cli/main_build.py index 3e1e7eeff5..3d85fd3b02 100644 --- a/conda_build/cli/main_build.py +++ b/conda_build/cli/main_build.py @@ -14,10 +14,11 @@ from conda.auxlib.ish import dals from conda.base.context import context +from conda.cli.helpers import add_parser_channels from conda.common.io import dashlist from .. import api, build, source, utils -from ..conda_interface import add_parser_channels, cc_conda_build +from ..conda_interface import cc_conda_build from ..config import ( get_channel_urls, get_or_merge_config, diff --git a/conda_build/cli/main_develop.py b/conda_build/cli/main_develop.py index fb6f31f7e6..59528b6d3d 100644 --- a/conda_build/cli/main_develop.py +++ b/conda_build/cli/main_develop.py @@ -6,9 +6,9 @@ from typing import TYPE_CHECKING from conda.base.context import context, determine_target_prefix +from conda.cli.helpers import add_parser_prefix from .. import api -from ..conda_interface import add_parser_prefix if TYPE_CHECKING: from argparse import ArgumentParser, Namespace diff --git a/conda_build/cli/main_inspect.py b/conda_build/cli/main_inspect.py index 3dff9eb27a..13b7db312d 100644 --- a/conda_build/cli/main_inspect.py +++ b/conda_build/cli/main_inspect.py @@ -9,9 +9,9 @@ from typing import TYPE_CHECKING from conda.base.context import context, determine_target_prefix +from conda.cli.helpers import add_parser_prefix from .. import api -from ..conda_interface import add_parser_prefix if TYPE_CHECKING: from argparse import ArgumentParser, Namespace diff --git a/conda_build/cli/main_metapackage.py b/conda_build/cli/main_metapackage.py index a01667ff84..98a199d899 100644 --- a/conda_build/cli/main_metapackage.py +++ b/conda_build/cli/main_metapackage.py @@ -7,9 +7,9 @@ from typing import TYPE_CHECKING from conda.base.context import context +from conda.cli.helpers import add_parser_channels from .. import api -from ..conda_interface import add_parser_channels if TYPE_CHECKING: from argparse import ArgumentParser, Namespace diff --git a/conda_build/cli/main_render.py b/conda_build/cli/main_render.py index 4de7e8560e..7262159c41 100644 --- a/conda_build/cli/main_render.py +++ b/conda_build/cli/main_render.py @@ -8,10 +8,11 @@ from typing import TYPE_CHECKING import yaml +from conda.cli.helpers import add_parser_channels from yaml.parser import ParserError from .. import __version__, api -from ..conda_interface import add_parser_channels, cc_conda_build +from ..conda_interface import cc_conda_build from ..config import get_channel_urls, get_or_merge_config from ..utils import LoggingContext from ..variants import get_package_variants, set_language_env_vars diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index 7c51aacadf..31bbe77fa0 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -12,6 +12,9 @@ from conda.base.context import determine_target_prefix as _determine_target_prefix from conda.base.context import non_x86_machines as _non_x86_linux_machines from conda.base.context import reset_context as _reset_context +from conda.cli.conda_argparse import ArgumentParser as _ArgumentParser +from conda.cli.helpers import add_parser_channels as _add_parser_channels +from conda.cli.helpers import add_parser_prefix as _add_parser_prefix from conda.core.package_cache_data import ( ProgressiveFetchExtract as _ProgressiveFetchExtract, ) @@ -22,7 +25,6 @@ from conda.exceptions import NoPackagesFoundError as _NoPackagesFoundError from conda.exceptions import PaddingError as _PaddingError from conda.exceptions import UnsatisfiableError as _UnsatisfiableError -from conda.exports import ArgumentParser as _ArgumentParser from conda.exports import ( # noqa: F401 Channel, Completer, @@ -41,8 +43,6 @@ Unsatisfiable, VersionOrder, _toposort, - add_parser_channels, - add_parser_prefix, download, human_bytes, input, @@ -73,6 +73,20 @@ _ArgumentParser, addendum="Use `conda.cli.conda_argparse.ArgumentParser` instead.", ) +deprecated.constant( + "24.5", + "24.7", + "add_parser_channels", + _add_parser_channels, + addendum="Use `conda.cli.helpers.add_parser_channels` instead.", +) +deprecated.constant( + "24.5", + "24.7", + "add_parser_prefix", + _add_parser_prefix, + addendum="Use `conda.cli.helpers.add_parser_prefix` instead.", +) deprecated.constant( "24.5", From add5e6d7f5ec510c6b4b8ee4093efbd9135d39c1 Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Wed, 10 Apr 2024 11:06:37 -0500 Subject: [PATCH 03/32] Deprecate Channel --- conda_build/conda_interface.py | 12 ++++++++++-- conda_build/environ.py | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index 31bbe77fa0..b9d8917e30 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -26,7 +26,6 @@ from conda.exceptions import PaddingError as _PaddingError from conda.exceptions import UnsatisfiableError as _UnsatisfiableError from conda.exports import ( # noqa: F401 - Channel, Completer, CondaSession, EntityEncoder, @@ -62,6 +61,7 @@ ) from conda.exports import get_index as _get_index from conda.gateways.disk.read import compute_sum as _compute_sum +from conda.models.channel import Channel as _Channel from conda.models.channel import get_conda_build_local_url as _get_conda_build_local_url from .deprecations import deprecated @@ -88,6 +88,14 @@ addendum="Use `conda.cli.helpers.add_parser_prefix` instead.", ) +deprecated.constant( + "24.5", + "24.7", + "Channel", + _Channel, + addendum="Use `conda.models.channel.Channel` instead.", +) + deprecated.constant( "24.5", "24.7", @@ -292,7 +300,7 @@ "24.5", "24.7", "get_conda_channel", - Channel.from_value, + _Channel.from_value, addendum="Use `conda.models.channel.Channel.from_value` instead.", ) diff --git a/conda_build/environ.py b/conda_build/environ.py index 36f6b78171..03252ef6ff 100644 --- a/conda_build/environ.py +++ b/conda_build/environ.py @@ -38,11 +38,11 @@ PaddingError, UnsatisfiableError, ) -from conda.models.channel import prioritize_channels +from conda.models.channel import Channel, prioritize_channels from conda.models.match_spec import MatchSpec from . import utils -from .conda_interface import Channel, PackageRecord, TemporaryDirectory +from .conda_interface import PackageRecord, TemporaryDirectory from .deprecations import deprecated from .exceptions import BuildLockError, DependencyNeedsBuildingError from .features import feature_list From 23b3fe862420231c2a3aa861292af6fdf245995c Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Wed, 10 Apr 2024 11:09:17 -0500 Subject: [PATCH 04/32] Deprecate EntityEncoder --- conda_build/build.py | 2 +- conda_build/conda_interface.py | 14 +++++++++++--- tests/test_misc.py | 3 ++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/conda_build/build.py b/conda_build/build.py index d0c939d9e8..e0895ee441 100644 --- a/conda_build/build.py +++ b/conda_build/build.py @@ -26,6 +26,7 @@ import yaml from bs4 import UnicodeDammit from conda import __version__ as conda_version +from conda.auxlib.entity import EntityEncoder from conda.base.context import context, reset_context from conda.core.prefix_data import PrefixData from conda.exceptions import CondaError, NoPackagesFoundError, UnsatisfiableError @@ -34,7 +35,6 @@ from . import __version__ as conda_build_version from . import environ, noarch_python, source, tarcheck, utils from .conda_interface import ( - EntityEncoder, FileMode, MatchSpec, PathType, diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index b9d8917e30..b68ad49c57 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -8,6 +8,7 @@ from importlib import import_module as _import_module from conda import __version__ +from conda.auxlib.entity import EntityEncoder as _EntityEncoder from conda.base.context import context as _context from conda.base.context import determine_target_prefix as _determine_target_prefix from conda.base.context import non_x86_machines as _non_x86_linux_machines @@ -26,9 +27,8 @@ from conda.exceptions import PaddingError as _PaddingError from conda.exceptions import UnsatisfiableError as _UnsatisfiableError from conda.exports import ( # noqa: F401 - Completer, - CondaSession, - EntityEncoder, + Completer, # unused + CondaSession, # unused FileMode, InstalledPackages, MatchSpec, @@ -96,6 +96,14 @@ addendum="Use `conda.models.channel.Channel` instead.", ) +deprecated.constant( + "24.5", + "24.7", + "EntityEncoder", + _EntityEncoder, + addendum="Use `conda.auxlib.entity.EntityEncoder` instead.", +) + deprecated.constant( "24.5", "24.7", diff --git a/tests/test_misc.py b/tests/test_misc.py index bcdafcb196..e1a69e6f84 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -4,9 +4,10 @@ from pathlib import Path import pytest +from conda.auxlib.entity import EntityEncoder from conda_build._link import pyc_f -from conda_build.conda_interface import EntityEncoder, PathType +from conda_build.conda_interface import PathType @pytest.mark.parametrize( From 07098f87bf62af7d25e68b88e516118322c235ff Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Wed, 10 Apr 2024 11:12:38 -0500 Subject: [PATCH 05/32] Deprecate FileMode & PathType --- conda_build/build.py | 3 +-- conda_build/conda_interface.py | 18 ++++++++++++++++-- tests/test_misc.py | 2 +- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/conda_build/build.py b/conda_build/build.py index e0895ee441..b777770676 100644 --- a/conda_build/build.py +++ b/conda_build/build.py @@ -31,13 +31,12 @@ from conda.core.prefix_data import PrefixData from conda.exceptions import CondaError, NoPackagesFoundError, UnsatisfiableError from conda.models.channel import Channel +from conda.models.enums import FileMode, PathType from . import __version__ as conda_build_version from . import environ, noarch_python, source, tarcheck, utils from .conda_interface import ( - FileMode, MatchSpec, - PathType, TemporaryDirectory, env_path_backup_var_exists, prefix_placeholder, diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index b68ad49c57..9756edaac9 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -29,12 +29,10 @@ from conda.exports import ( # noqa: F401 Completer, # unused CondaSession, # unused - FileMode, InstalledPackages, MatchSpec, NoPackagesFound, PackageRecord, - PathType, Resolve, StringIO, TemporaryDirectory, @@ -63,6 +61,8 @@ from conda.gateways.disk.read import compute_sum as _compute_sum from conda.models.channel import Channel as _Channel from conda.models.channel import get_conda_build_local_url as _get_conda_build_local_url +from conda.models.enums import FileMode as _FileMode +from conda.models.enums import PathType as _PathType from .deprecations import deprecated @@ -95,6 +95,20 @@ _Channel, addendum="Use `conda.models.channel.Channel` instead.", ) +deprecated.constant( + "24.5", + "24.7", + "FileMode", + _FileMode, + addendum="Use `conda.models.enums.FileMode` instead.", +) +deprecated.constant( + "24.5", + "24.7", + "PathType", + _PathType, + addendum="Use `conda.models.enums.PathType` instead.", +) deprecated.constant( "24.5", diff --git a/tests/test_misc.py b/tests/test_misc.py index e1a69e6f84..4a5bb0d95c 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -5,9 +5,9 @@ import pytest from conda.auxlib.entity import EntityEncoder +from conda.models.enums import PathType from conda_build._link import pyc_f -from conda_build.conda_interface import PathType @pytest.mark.parametrize( From 4da76093fab842edb1cc7b2e371ea4e97d287456 Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Wed, 10 Apr 2024 11:16:00 -0500 Subject: [PATCH 06/32] Deprecate MatchSpec --- conda_build/build.py | 4 +--- conda_build/conda_interface.py | 11 +++++++++-- conda_build/metadata.py | 2 +- conda_build/skeletons/cpan.py | 2 +- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/conda_build/build.py b/conda_build/build.py index b777770676..f4320149c0 100644 --- a/conda_build/build.py +++ b/conda_build/build.py @@ -32,11 +32,11 @@ from conda.exceptions import CondaError, NoPackagesFoundError, UnsatisfiableError from conda.models.channel import Channel from conda.models.enums import FileMode, PathType +from conda.models.match_spec import MatchSpec from . import __version__ as conda_build_version from . import environ, noarch_python, source, tarcheck, utils from .conda_interface import ( - MatchSpec, TemporaryDirectory, env_path_backup_var_exists, prefix_placeholder, @@ -2350,8 +2350,6 @@ def create_build_envs(m: MetaData, notest): ) except DependencyNeedsBuildingError as e: # subpackages are not actually missing. We just haven't built them yet. - from .conda_interface import MatchSpec - other_outputs = ( m.other_outputs.values() if hasattr(m, "other_outputs") diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index 9756edaac9..9445285463 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -29,8 +29,7 @@ from conda.exports import ( # noqa: F401 Completer, # unused CondaSession, # unused - InstalledPackages, - MatchSpec, + InstalledPackages, # unused NoPackagesFound, PackageRecord, Resolve, @@ -63,6 +62,7 @@ from conda.models.channel import get_conda_build_local_url as _get_conda_build_local_url from conda.models.enums import FileMode as _FileMode from conda.models.enums import PathType as _PathType +from conda.models.match_spec import MatchSpec as _MatchSpec from .deprecations import deprecated @@ -109,6 +109,13 @@ _PathType, addendum="Use `conda.models.enums.PathType` instead.", ) +deprecated.constant( + "24.5", + "24.7", + "MatchSpec", + _MatchSpec, + addendum="Use `conda.models.match_spec.MatchSpec` instead.", +) deprecated.constant( "24.5", diff --git a/conda_build/metadata.py b/conda_build/metadata.py index 01f3367d03..abf31d401d 100644 --- a/conda_build/metadata.py +++ b/conda_build/metadata.py @@ -18,9 +18,9 @@ from bs4 import UnicodeDammit from conda.base.context import context from conda.gateways.disk.read import compute_sum +from conda.models.match_spec import MatchSpec from . import exceptions, utils, variants -from .conda_interface import MatchSpec from .config import Config, get_or_merge_config from .features import feature_list from .license_family import ensure_valid_license_family diff --git a/conda_build/skeletons/cpan.py b/conda_build/skeletons/cpan.py index 507086e4fe..d33dd79507 100644 --- a/conda_build/skeletons/cpan.py +++ b/conda_build/skeletons/cpan.py @@ -21,10 +21,10 @@ import requests from conda.core.index import get_index from conda.exceptions import CondaError, CondaHTTPError +from conda.models.match_spec import MatchSpec from .. import environ from ..conda_interface import ( - MatchSpec, Resolve, TemporaryDirectory, TmpDownload, From 24ea84d5bc3fbb88830297b8a6b488aa689719b4 Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Wed, 10 Apr 2024 11:18:28 -0500 Subject: [PATCH 07/32] Deprecate PackageRecord --- conda_build/conda_interface.py | 11 +++++++++-- conda_build/environ.py | 3 ++- conda_build/render.py | 3 ++- conda_build/utils.py | 2 +- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index 9445285463..90512a8f4c 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -30,8 +30,7 @@ Completer, # unused CondaSession, # unused InstalledPackages, # unused - NoPackagesFound, - PackageRecord, + NoPackagesFound, # unused Resolve, StringIO, TemporaryDirectory, @@ -63,6 +62,7 @@ from conda.models.enums import FileMode as _FileMode from conda.models.enums import PathType as _PathType from conda.models.match_spec import MatchSpec as _MatchSpec +from conda.models.records import PackageRecord as _PackageRecord from .deprecations import deprecated @@ -116,6 +116,13 @@ _MatchSpec, addendum="Use `conda.models.match_spec.MatchSpec` instead.", ) +deprecated.constant( + "24.5", + "24.7", + "PackageRecord", + _PackageRecord, + addendum="Use `conda.models.records.PackageRecord` instead.", +) deprecated.constant( "24.5", diff --git a/conda_build/environ.py b/conda_build/environ.py index 03252ef6ff..8087f1f370 100644 --- a/conda_build/environ.py +++ b/conda_build/environ.py @@ -40,9 +40,10 @@ ) from conda.models.channel import Channel, prioritize_channels from conda.models.match_spec import MatchSpec +from conda.models.records import PackageRecord from . import utils -from .conda_interface import PackageRecord, TemporaryDirectory +from .conda_interface import TemporaryDirectory from .deprecations import deprecated from .exceptions import BuildLockError, DependencyNeedsBuildingError from .features import feature_list diff --git a/conda_build/render.py b/conda_build/render.py index be17eaa461..f8aa2804a0 100644 --- a/conda_build/render.py +++ b/conda_build/render.py @@ -29,9 +29,10 @@ from conda.base.context import context from conda.core.package_cache_data import ProgressiveFetchExtract from conda.exceptions import UnsatisfiableError +from conda.models.records import PackageRecord from . import environ, exceptions, source, utils -from .conda_interface import PackageRecord, TemporaryDirectory, specs_from_url +from .conda_interface import TemporaryDirectory, specs_from_url from .exceptions import DependencyNeedsBuildingError from .index import get_build_index from .metadata import MetaData, combine_top_level_metadata_with_output diff --git a/conda_build/utils.py b/conda_build/utils.py index 05b0d827ff..c379daca28 100644 --- a/conda_build/utils.py +++ b/conda_build/utils.py @@ -58,9 +58,9 @@ from conda.gateways.disk.read import compute_sum from conda.models.channel import Channel from conda.models.match_spec import MatchSpec +from conda.models.records import PackageRecord from .conda_interface import ( - PackageRecord, StringIO, TemporaryDirectory, VersionOrder, From 24d21a568057ffd5613cac75ac9b007070926903 Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Wed, 10 Apr 2024 11:22:08 -0500 Subject: [PATCH 08/32] Deprecate Resolve --- conda_build/conda_interface.py | 10 +++++++++- conda_build/skeletons/cpan.py | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index 90512a8f4c..203259a95b 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -31,7 +31,6 @@ CondaSession, # unused InstalledPackages, # unused NoPackagesFound, # unused - Resolve, StringIO, TemporaryDirectory, TmpDownload, @@ -63,6 +62,7 @@ from conda.models.enums import PathType as _PathType from conda.models.match_spec import MatchSpec as _MatchSpec from conda.models.records import PackageRecord as _PackageRecord +from conda.resolve import Resolve as _Resolve from .deprecations import deprecated @@ -132,6 +132,14 @@ addendum="Use `conda.auxlib.entity.EntityEncoder` instead.", ) +deprecated.constant( + "24.5", + "24.7", + "Resolve", + _Resolve, + addendum="Use `conda.resolve.Resolve` instead.", +) + deprecated.constant( "24.5", "24.7", diff --git a/conda_build/skeletons/cpan.py b/conda_build/skeletons/cpan.py index d33dd79507..1875698274 100644 --- a/conda_build/skeletons/cpan.py +++ b/conda_build/skeletons/cpan.py @@ -22,10 +22,10 @@ from conda.core.index import get_index from conda.exceptions import CondaError, CondaHTTPError from conda.models.match_spec import MatchSpec +from conda.resolve import Resolve from .. import environ from ..conda_interface import ( - Resolve, TemporaryDirectory, TmpDownload, download, From e82dfe2110603a676d4c54cc4941f1805a1f3e3c Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Wed, 10 Apr 2024 11:24:28 -0500 Subject: [PATCH 09/32] Deprecate StringIO --- conda_build/bdist_conda.py | 3 ++- conda_build/conda_interface.py | 10 +++++++++- conda_build/skeletons/pypi.py | 2 +- conda_build/utils.py | 2 +- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/conda_build/bdist_conda.py b/conda_build/bdist_conda.py index 6e965c409d..1002352f42 100644 --- a/conda_build/bdist_conda.py +++ b/conda_build/bdist_conda.py @@ -4,6 +4,7 @@ import sys import time from collections import defaultdict +from io import StringIO from setuptools.command.install import install from setuptools.dist import Distribution @@ -11,7 +12,7 @@ from . import api from .build import handle_anaconda_upload -from .conda_interface import StringIO, spec_from_line +from .conda_interface import spec_from_line from .config import Config from .deprecations import deprecated from .metadata import MetaData diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index 203259a95b..03abc03ab3 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -6,6 +6,7 @@ import os as _os from functools import partial as _partial from importlib import import_module as _import_module +from io import StringIO as _StringIO from conda import __version__ from conda.auxlib.entity import EntityEncoder as _EntityEncoder @@ -31,7 +32,6 @@ CondaSession, # unused InstalledPackages, # unused NoPackagesFound, # unused - StringIO, TemporaryDirectory, TmpDownload, Unsatisfiable, @@ -162,6 +162,14 @@ _import_module, addendum="Use `importlib.import_module` instead.", ) +deprecated.constant( + "24.5", + "24.7", + "StringIO", + _StringIO, + addendum="Use `io.StringIO` instead.", +) + deprecated.constant( "24.5", "24.7", diff --git a/conda_build/skeletons/pypi.py b/conda_build/skeletons/pypi.py index 8dc6719f63..1320d23f73 100644 --- a/conda_build/skeletons/pypi.py +++ b/conda_build/skeletons/pypi.py @@ -12,6 +12,7 @@ import subprocess import sys from collections import OrderedDict, defaultdict +from io import StringIO from os import chdir, getcwd, listdir, makedirs from os.path import abspath, exists, isdir, isfile, join from shutil import copy2 @@ -26,7 +27,6 @@ from requests.packages.urllib3.util.url import parse_url from ..conda_interface import ( - StringIO, download, human_bytes, input, diff --git a/conda_build/utils.py b/conda_build/utils.py index c379daca28..98bc9af5fa 100644 --- a/conda_build/utils.py +++ b/conda_build/utils.py @@ -23,6 +23,7 @@ from collections import OrderedDict, defaultdict from functools import lru_cache from glob import glob +from io import StringIO from itertools import filterfalse from json.decoder import JSONDecodeError from locale import getpreferredencoding @@ -61,7 +62,6 @@ from conda.models.records import PackageRecord from .conda_interface import ( - StringIO, TemporaryDirectory, VersionOrder, cc_conda_build, From 07c3a7023318affcadf8cde920cdeca2f1714581 Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Wed, 10 Apr 2024 11:39:51 -0500 Subject: [PATCH 10/32] Deprecate TemporaryDirectory --- conda_build/build.py | 2 +- conda_build/conda_interface.py | 10 ++++-- conda_build/environ.py | 2 +- conda_build/post.py | 7 ++-- conda_build/render.py | 6 ++-- conda_build/skeletons/cpan.py | 2 +- conda_build/skeletons/cran.py | 3 +- conda_build/source.py | 3 +- conda_build/utils.py | 2 +- tests/cli/test_main_build.py | 20 ++++++------ tests/cli/test_main_render.py | 58 ++++++++++++++++++---------------- tests/test_source.py | 2 +- 12 files changed, 62 insertions(+), 55 deletions(-) diff --git a/conda_build/build.py b/conda_build/build.py index f4320149c0..05483b3de1 100644 --- a/conda_build/build.py +++ b/conda_build/build.py @@ -30,6 +30,7 @@ from conda.base.context import context, reset_context from conda.core.prefix_data import PrefixData from conda.exceptions import CondaError, NoPackagesFoundError, UnsatisfiableError +from conda.gateways.disk.create import TemporaryDirectory from conda.models.channel import Channel from conda.models.enums import FileMode, PathType from conda.models.match_spec import MatchSpec @@ -37,7 +38,6 @@ from . import __version__ as conda_build_version from . import environ, noarch_python, source, tarcheck, utils from .conda_interface import ( - TemporaryDirectory, env_path_backup_var_exists, prefix_placeholder, url_path, diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index 03abc03ab3..76eece35c2 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -32,7 +32,6 @@ CondaSession, # unused InstalledPackages, # unused NoPackagesFound, # unused - TemporaryDirectory, TmpDownload, Unsatisfiable, VersionOrder, @@ -55,6 +54,7 @@ win_path_to_unix, ) from conda.exports import get_index as _get_index +from conda.gateways.disk.create import TemporaryDirectory as _TemporaryDirectory from conda.gateways.disk.read import compute_sum as _compute_sum from conda.models.channel import Channel as _Channel from conda.models.channel import get_conda_build_local_url as _get_conda_build_local_url @@ -131,7 +131,6 @@ _EntityEncoder, addendum="Use `conda.auxlib.entity.EntityEncoder` instead.", ) - deprecated.constant( "24.5", "24.7", @@ -139,6 +138,13 @@ _Resolve, addendum="Use `conda.resolve.Resolve` instead.", ) +deprecated.constant( + "24.5", + "24.7", + "TemporaryDirectory", + _TemporaryDirectory, + addendum="Use `conda.gateways.disk.create.TemporaryDirectory` instead.", +) deprecated.constant( "24.5", diff --git a/conda_build/environ.py b/conda_build/environ.py index 8087f1f370..5a24d83172 100644 --- a/conda_build/environ.py +++ b/conda_build/environ.py @@ -38,12 +38,12 @@ PaddingError, UnsatisfiableError, ) +from conda.gateways.disk.create import TemporaryDirectory from conda.models.channel import Channel, prioritize_channels from conda.models.match_spec import MatchSpec from conda.models.records import PackageRecord from . import utils -from .conda_interface import TemporaryDirectory from .deprecations import deprecated from .exceptions import BuildLockError, DependencyNeedsBuildingError from .features import feature_list diff --git a/conda_build/post.py b/conda_build/post.py index eea8a584b6..f63d6851d5 100644 --- a/conda_build/post.py +++ b/conda_build/post.py @@ -35,15 +35,12 @@ from typing import TYPE_CHECKING from conda.core.prefix_data import PrefixData +from conda.gateways.disk.create import TemporaryDirectory from conda.gateways.disk.read import compute_sum from conda.models.records import PrefixRecord from . import utils -from .conda_interface import ( - TemporaryDirectory, - lchmod, - walk_prefix, -) +from .conda_interface import lchmod, walk_prefix from .exceptions import OverDependingError, OverLinkingError, RunPathError from .inspect_pkg import which_package from .os_utils import external, macho diff --git a/conda_build/render.py b/conda_build/render.py index f8aa2804a0..9b7c9172c0 100644 --- a/conda_build/render.py +++ b/conda_build/render.py @@ -10,7 +10,6 @@ import subprocess import sys import tarfile -import tempfile from collections import OrderedDict, defaultdict from contextlib import contextmanager from functools import lru_cache @@ -29,10 +28,11 @@ from conda.base.context import context from conda.core.package_cache_data import ProgressiveFetchExtract from conda.exceptions import UnsatisfiableError +from conda.gateways.disk.create import TemporaryDirectory from conda.models.records import PackageRecord from . import environ, exceptions, source, utils -from .conda_interface import TemporaryDirectory, specs_from_url +from .conda_interface import specs_from_url from .exceptions import DependencyNeedsBuildingError from .index import get_build_index from .metadata import MetaData, combine_top_level_metadata_with_output @@ -944,7 +944,7 @@ def open_recipe(recipe: str | os.PathLike | Path) -> Iterator[Path]: yield recipe elif recipe.suffixes in [[".tar"], [".tar", ".gz"], [".tgz"], [".tar", ".bz2"]]: # extract the recipe to a temporary directory - with tempfile.TemporaryDirectory() as tmp, tarfile.open(recipe, "r:*") as tar: + with TemporaryDirectory() as tmp, tarfile.open(recipe, "r:*") as tar: tar.extractall(path=tmp) yield Path(tmp) elif recipe.suffix == ".yaml": diff --git a/conda_build/skeletons/cpan.py b/conda_build/skeletons/cpan.py index 1875698274..579602f5b7 100644 --- a/conda_build/skeletons/cpan.py +++ b/conda_build/skeletons/cpan.py @@ -21,12 +21,12 @@ import requests from conda.core.index import get_index from conda.exceptions import CondaError, CondaHTTPError +from conda.gateways.disk.create import TemporaryDirectory from conda.models.match_spec import MatchSpec from conda.resolve import Resolve from .. import environ from ..conda_interface import ( - TemporaryDirectory, TmpDownload, download, ) diff --git a/conda_build/skeletons/cran.py b/conda_build/skeletons/cran.py index 7140c9a89f..1f1e435ec9 100755 --- a/conda_build/skeletons/cran.py +++ b/conda_build/skeletons/cran.py @@ -42,9 +42,10 @@ from typing import TYPE_CHECKING from conda.common.io import dashlist +from conda.gateways.disk.create import TemporaryDirectory from .. import source -from ..conda_interface import TemporaryDirectory, cc_conda_build +from ..conda_interface import cc_conda_build from ..config import get_or_merge_config from ..license_family import allowed_license_families, guess_license_family from ..metadata import MetaData diff --git a/conda_build/source.py b/conda_build/source.py index 984fb239e8..9035708018 100644 --- a/conda_build/source.py +++ b/conda_build/source.py @@ -16,9 +16,10 @@ from urllib.parse import urljoin from conda.exceptions import CondaHTTPError +from conda.gateways.disk.create import TemporaryDirectory from conda.gateways.disk.read import compute_sum -from .conda_interface import TemporaryDirectory, download, url_path +from .conda_interface import download, url_path from .exceptions import MissingDependency from .os_utils import external from .utils import ( diff --git a/conda_build/utils.py b/conda_build/utils.py index 98bc9af5fa..4f327a78ed 100644 --- a/conda_build/utils.py +++ b/conda_build/utils.py @@ -56,13 +56,13 @@ ) from conda.base.context import context from conda.exceptions import CondaHTTPError +from conda.gateways.disk.create import TemporaryDirectory from conda.gateways.disk.read import compute_sum from conda.models.channel import Channel from conda.models.match_spec import MatchSpec from conda.models.records import PackageRecord from .conda_interface import ( - TemporaryDirectory, VersionOrder, cc_conda_build, download, diff --git a/tests/cli/test_main_build.py b/tests/cli/test_main_build.py index 9da5b48418..15b3d67237 100644 --- a/tests/cli/test_main_build.py +++ b/tests/cli/test_main_build.py @@ -11,7 +11,6 @@ from conda_build import api from conda_build.cli import main_build, main_render -from conda_build.conda_interface import TemporaryDirectory from conda_build.config import ( Config, zstd_compression_level_default, @@ -264,20 +263,19 @@ def test_purge(testing_workdir, testing_metadata): @pytest.mark.serial -def test_purge_all(testing_workdir, testing_metadata): +def test_purge_all( + testing_workdir: str, testing_metadata: MetaData, tmp_path: Path +) -> None: """ purge-all clears out build folders as well as build packages in the osx-64 folders and such """ api.output_yaml(testing_metadata, "meta.yaml") - with TemporaryDirectory() as tmpdir: - testing_metadata.config.croot = tmpdir - outputs = api.build( - testing_workdir, config=testing_metadata.config, notest=True - ) - args = ["purge-all", "--croot", tmpdir] - main_build.execute(args) - assert not get_build_folders(testing_metadata.config.croot) - assert not any(os.path.isfile(fn) for fn in outputs) + testing_metadata.config.croot = str(tmp_path) + outputs = api.build(testing_workdir, config=testing_metadata.config, notest=True) + args = ["purge-all", f"--croot={tmp_path}"] + main_build.execute(args) + assert not get_build_folders(testing_metadata.config.croot) + assert not any(os.path.isfile(fn) for fn in outputs) @pytest.mark.serial diff --git a/tests/cli/test_main_render.py b/tests/cli/test_main_render.py index 59fff7901c..bf00ac6fd1 100644 --- a/tests/cli/test_main_render.py +++ b/tests/cli/test_main_render.py @@ -1,47 +1,51 @@ # Copyright (C) 2014 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause +from __future__ import annotations + import os import sys +from typing import TYPE_CHECKING import pytest import yaml from conda_build import api from conda_build.cli import main_render -from conda_build.conda_interface import TemporaryDirectory from ..utils import metadata_dir +if TYPE_CHECKING: + from pathlib import Path + -def test_render_add_channel(): +def test_render_add_channel(tmp_path: Path) -> None: """This recipe requires the conda_build_test_requirement package, which is only on the conda_build_test channel. This verifies that the -c argument works for rendering.""" - with TemporaryDirectory() as tmpdir: - rendered_filename = os.path.join(tmpdir, "out.yaml") - args = [ - "-c", - "conda_build_test", - os.path.join(metadata_dir, "_recipe_requiring_external_channel"), - "--file", - rendered_filename, - ] - main_render.execute(args) - with open(rendered_filename) as rendered_file: - rendered_meta = yaml.safe_load(rendered_file) - required_package_string = [ - pkg - for pkg in rendered_meta["requirements"]["build"] - if "conda_build_test_requirement" in pkg - ][0] - required_package_details = required_package_string.split(" ") - assert len(required_package_details) > 1, ( - "Expected version number on successful " - f"rendering, but got only {required_package_details}" - ) - assert ( - required_package_details[1] == "1.0" - ), f"Expected version number 1.0 on successful rendering, but got {required_package_details[1]}" + rendered_filename = os.path.join(tmp_path, "out.yaml") + args = [ + "-c", + "conda_build_test", + os.path.join(metadata_dir, "_recipe_requiring_external_channel"), + "--file", + rendered_filename, + ] + main_render.execute(args) + with open(rendered_filename) as rendered_file: + rendered_meta = yaml.safe_load(rendered_file) + required_package_string = [ + pkg + for pkg in rendered_meta["requirements"]["build"] + if "conda_build_test_requirement" in pkg + ][0] + required_package_details = required_package_string.split(" ") + assert len(required_package_details) > 1, ( + "Expected version number on successful " + f"rendering, but got only {required_package_details}" + ) + assert ( + required_package_details[1] == "1.0" + ), f"Expected version number 1.0 on successful rendering, but got {required_package_details[1]}" def test_render_without_channel_fails(tmp_path): diff --git a/tests/test_source.py b/tests/test_source.py index 711407d153..1cae2f9997 100644 --- a/tests/test_source.py +++ b/tests/test_source.py @@ -5,10 +5,10 @@ import tarfile import pytest +from conda.gateways.disk.create import TemporaryDirectory from conda.gateways.disk.read import compute_sum from conda_build import source -from conda_build.conda_interface import TemporaryDirectory from conda_build.source import download_to_cache from conda_build.utils import reset_deduplicator From 80752b6e964ab21d5104502054056d01ef49c496 Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Wed, 10 Apr 2024 13:29:28 -0500 Subject: [PATCH 11/32] Deprecate TmpDownload --- conda_build/conda_interface.py | 9 ++++++++- conda_build/skeletons/cpan.py | 6 ++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index 76eece35c2..391a8f1392 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -32,7 +32,6 @@ CondaSession, # unused InstalledPackages, # unused NoPackagesFound, # unused - TmpDownload, Unsatisfiable, VersionOrder, _toposort, @@ -54,6 +53,7 @@ win_path_to_unix, ) from conda.exports import get_index as _get_index +from conda.gateways.connection.download import TmpDownload as _TmpDownload from conda.gateways.disk.create import TemporaryDirectory as _TemporaryDirectory from conda.gateways.disk.read import compute_sum as _compute_sum from conda.models.channel import Channel as _Channel @@ -145,6 +145,13 @@ _TemporaryDirectory, addendum="Use `conda.gateways.disk.create.TemporaryDirectory` instead.", ) +deprecated.constant( + "24.5", + "24.7", + "TmpDownload", + _TmpDownload, + addendum="Use `conda.gateways.connection.download.TmpDownload` instead.", +) deprecated.constant( "24.5", diff --git a/conda_build/skeletons/cpan.py b/conda_build/skeletons/cpan.py index 579602f5b7..382d697a5e 100644 --- a/conda_build/skeletons/cpan.py +++ b/conda_build/skeletons/cpan.py @@ -21,15 +21,13 @@ import requests from conda.core.index import get_index from conda.exceptions import CondaError, CondaHTTPError +from conda.gateways.connection.download import TmpDownload from conda.gateways.disk.create import TemporaryDirectory from conda.models.match_spec import MatchSpec from conda.resolve import Resolve from .. import environ -from ..conda_interface import ( - TmpDownload, - download, -) +from ..conda_interface import download from ..config import Config, get_or_merge_config from ..utils import check_call_env, on_linux, on_win from ..variants import get_default_variant From 60df4dd0edd430a7600de11b19571df49eea1f8a Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Wed, 10 Apr 2024 13:32:02 -0500 Subject: [PATCH 12/32] Deprecate download --- conda_build/conda_interface.py | 9 ++++++++- conda_build/skeletons/cpan.py | 3 +-- conda_build/skeletons/pypi.py | 2 +- conda_build/source.py | 3 ++- conda_build/utils.py | 2 +- tests/cli/test_main_convert.py | 2 +- tests/cli/test_main_develop.py | 3 ++- tests/test_api_convert.py | 2 +- 8 files changed, 17 insertions(+), 9 deletions(-) diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index 391a8f1392..2e8169b54f 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -35,7 +35,6 @@ Unsatisfiable, VersionOrder, _toposort, - download, human_bytes, input, lchmod, @@ -54,6 +53,7 @@ ) from conda.exports import get_index as _get_index from conda.gateways.connection.download import TmpDownload as _TmpDownload +from conda.gateways.connection.download import download as _download from conda.gateways.disk.create import TemporaryDirectory as _TemporaryDirectory from conda.gateways.disk.read import compute_sum as _compute_sum from conda.models.channel import Channel as _Channel @@ -152,6 +152,13 @@ _TmpDownload, addendum="Use `conda.gateways.connection.download.TmpDownload` instead.", ) +deprecated.constant( + "24.5", + "24.7", + "download", + _download, + addendum="Use `conda.gateways.connection.download.download` instead.", +) deprecated.constant( "24.5", diff --git a/conda_build/skeletons/cpan.py b/conda_build/skeletons/cpan.py index 382d697a5e..14964b4b16 100644 --- a/conda_build/skeletons/cpan.py +++ b/conda_build/skeletons/cpan.py @@ -21,13 +21,12 @@ import requests from conda.core.index import get_index from conda.exceptions import CondaError, CondaHTTPError -from conda.gateways.connection.download import TmpDownload +from conda.gateways.connection.download import TmpDownload, download from conda.gateways.disk.create import TemporaryDirectory from conda.models.match_spec import MatchSpec from conda.resolve import Resolve from .. import environ -from ..conda_interface import download from ..config import Config, get_or_merge_config from ..utils import check_call_env, on_linux, on_win from ..variants import get_default_variant diff --git a/conda_build/skeletons/pypi.py b/conda_build/skeletons/pypi.py index 1320d23f73..930e96c7f5 100644 --- a/conda_build/skeletons/pypi.py +++ b/conda_build/skeletons/pypi.py @@ -23,11 +23,11 @@ import requests import yaml from conda.base.context import context +from conda.gateways.connection.download import download from conda.gateways.disk.read import compute_sum from requests.packages.urllib3.util.url import parse_url from ..conda_interface import ( - download, human_bytes, input, normalized_version, diff --git a/conda_build/source.py b/conda_build/source.py index 9035708018..d76fb35ed9 100644 --- a/conda_build/source.py +++ b/conda_build/source.py @@ -16,10 +16,11 @@ from urllib.parse import urljoin from conda.exceptions import CondaHTTPError +from conda.gateways.connection.download import download from conda.gateways.disk.create import TemporaryDirectory from conda.gateways.disk.read import compute_sum -from .conda_interface import download, url_path +from .conda_interface import url_path from .exceptions import MissingDependency from .os_utils import external from .utils import ( diff --git a/conda_build/utils.py b/conda_build/utils.py index 4f327a78ed..d7fd223e48 100644 --- a/conda_build/utils.py +++ b/conda_build/utils.py @@ -56,6 +56,7 @@ ) from conda.base.context import context from conda.exceptions import CondaHTTPError +from conda.gateways.connection.download import download from conda.gateways.disk.create import TemporaryDirectory from conda.gateways.disk.read import compute_sum from conda.models.channel import Channel @@ -65,7 +66,6 @@ from .conda_interface import ( VersionOrder, cc_conda_build, - download, unix_path_to_win, win_path_to_unix, ) diff --git a/tests/cli/test_main_convert.py b/tests/cli/test_main_convert.py index 0be658b9d3..9ff65849d9 100644 --- a/tests/cli/test_main_convert.py +++ b/tests/cli/test_main_convert.py @@ -3,9 +3,9 @@ import os import pytest +from conda.gateways.connection.download import download from conda_build.cli import main_convert -from conda_build.conda_interface import download from conda_build.tarcheck import TarCheck from conda_build.utils import on_win diff --git a/tests/cli/test_main_develop.py b/tests/cli/test_main_develop.py index ede3758cfb..c0c3cdca3d 100644 --- a/tests/cli/test_main_develop.py +++ b/tests/cli/test_main_develop.py @@ -3,8 +3,9 @@ import os import sys +from conda.gateways.connection.download import download + from conda_build.cli import main_develop -from conda_build.conda_interface import download from conda_build.utils import get_site_packages, tar_xf diff --git a/tests/test_api_convert.py b/tests/test_api_convert.py index 7da9ede2d3..c0e46b7bf3 100644 --- a/tests/test_api_convert.py +++ b/tests/test_api_convert.py @@ -7,9 +7,9 @@ import tarfile import pytest +from conda.gateways.connection.download import download from conda_build import api -from conda_build.conda_interface import download from conda_build.utils import on_win, package_has_file from .utils import assert_package_consistency, metadata_dir From f1551251e13a332b236ef4813e9bb7b1f6966506 Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Wed, 10 Apr 2024 14:13:50 -0500 Subject: [PATCH 13/32] Deprecate VersionOrder Update utils.py --- conda_build/conda_interface.py | 11 +++++++++-- conda_build/os_utils/liefldd.py | 3 ++- conda_build/render.py | 3 +-- conda_build/utils.py | 2 +- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index 2e8169b54f..846f6bbf6e 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -32,8 +32,7 @@ CondaSession, # unused InstalledPackages, # unused NoPackagesFound, # unused - Unsatisfiable, - VersionOrder, + Unsatisfiable, # unused _toposort, human_bytes, input, @@ -62,6 +61,7 @@ from conda.models.enums import PathType as _PathType from conda.models.match_spec import MatchSpec as _MatchSpec from conda.models.records import PackageRecord as _PackageRecord +from conda.models.version import VersionOrder as _VersionOrder from conda.resolve import Resolve as _Resolve from .deprecations import deprecated @@ -123,6 +123,13 @@ _PackageRecord, addendum="Use `conda.models.records.PackageRecord` instead.", ) +deprecated.constant( + "24.5", + "24.7", + "VersionOrder", + _VersionOrder, + addendum="Use `conda.models.version.VersionOrder` instead.", +) deprecated.constant( "24.5", diff --git a/conda_build/os_utils/liefldd.py b/conda_build/os_utils/liefldd.py index 9b14454c4f..d02cd2bd30 100644 --- a/conda_build/os_utils/liefldd.py +++ b/conda_build/os_utils/liefldd.py @@ -13,6 +13,8 @@ from pathlib import Path from subprocess import PIPE, Popen +from conda.models.version import VersionOrder + from ..utils import on_mac, on_win, rec_glob from .external import find_executable @@ -963,7 +965,6 @@ def get_static_lib_exports_dumpbin(filename): results.append((result, version)) except: pass - from ..conda_interface import VersionOrder results = sorted(results, key=lambda x: VersionOrder(x[1])) dumpbin_exe = results[-1][0] diff --git a/conda_build/render.py b/conda_build/render.py index 9b7c9172c0..55515e721d 100644 --- a/conda_build/render.py +++ b/conda_build/render.py @@ -30,6 +30,7 @@ from conda.exceptions import UnsatisfiableError from conda.gateways.disk.create import TemporaryDirectory from conda.models.records import PackageRecord +from conda.models.version import VersionOrder from . import environ, exceptions, source, utils from .conda_interface import specs_from_url @@ -807,8 +808,6 @@ def distribute_variants( # which python version we prefer. `python_age` can use used to tweak which # python gets used here. if metadata.noarch or metadata.noarch_python: - from .conda_interface import VersionOrder - age = int( metadata.get_value( "build/noarch_python_build_age", metadata.config.noarch_python_build_age diff --git a/conda_build/utils.py b/conda_build/utils.py index d7fd223e48..0d367960a0 100644 --- a/conda_build/utils.py +++ b/conda_build/utils.py @@ -62,9 +62,9 @@ from conda.models.channel import Channel from conda.models.match_spec import MatchSpec from conda.models.records import PackageRecord +from conda.models.version import VersionOrder from .conda_interface import ( - VersionOrder, cc_conda_build, unix_path_to_win, win_path_to_unix, From 29a42945324d05231648760c84d4fe4d77c8a3fa Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Wed, 10 Apr 2024 14:16:18 -0500 Subject: [PATCH 14/32] Deprecate _toposort --- conda_build/conda_interface.py | 9 ++++++++- conda_build/metadata.py | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index 846f6bbf6e..1324b43867 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -17,6 +17,7 @@ from conda.cli.conda_argparse import ArgumentParser as _ArgumentParser from conda.cli.helpers import add_parser_channels as _add_parser_channels from conda.cli.helpers import add_parser_prefix as _add_parser_prefix +from conda.common.toposort import _toposort as __toposort from conda.core.package_cache_data import ( ProgressiveFetchExtract as _ProgressiveFetchExtract, ) @@ -33,7 +34,6 @@ InstalledPackages, # unused NoPackagesFound, # unused Unsatisfiable, # unused - _toposort, human_bytes, input, lchmod, @@ -166,6 +166,13 @@ _download, addendum="Use `conda.gateways.connection.download.download` instead.", ) +deprecated.constant( + "24.5", + "24.7", + "_toposort", + __toposort, + addendum="Use `conda.common.toposort._toposort` instead.", +) deprecated.constant( "24.5", diff --git a/conda_build/metadata.py b/conda_build/metadata.py index abf31d401d..6828ed5548 100644 --- a/conda_build/metadata.py +++ b/conda_build/metadata.py @@ -815,7 +815,7 @@ def toposort(output_metadata_map): will naturally lead to non-overlapping files in each package and also the correct files being present during the install and test procedures, provided they are run in this order.""" - from .conda_interface import _toposort + from conda.common.toposort import _toposort # We only care about the conda packages built by this recipe. Non-conda # packages get sorted to the end. From 07816b5f30470d29f628143c6b8fa3d3298be2eb Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Wed, 10 Apr 2024 14:17:46 -0500 Subject: [PATCH 15/32] Deprecate human_bytes --- conda_build/conda_interface.py | 9 ++++++++- conda_build/skeletons/pypi.py | 8 ++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index 1324b43867..46c2031ba2 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -34,7 +34,6 @@ InstalledPackages, # unused NoPackagesFound, # unused Unsatisfiable, # unused - human_bytes, input, lchmod, normalized_version, @@ -63,6 +62,7 @@ from conda.models.records import PackageRecord as _PackageRecord from conda.models.version import VersionOrder as _VersionOrder from conda.resolve import Resolve as _Resolve +from conda.utils import human_bytes as _human_bytes from .deprecations import deprecated @@ -173,6 +173,13 @@ __toposort, addendum="Use `conda.common.toposort._toposort` instead.", ) +deprecated.constant( + "24.5", + "24.7", + "human_bytes", + _human_bytes, + addendum="Use `conda.utils.human_bytes` instead.", +) deprecated.constant( "24.5", diff --git a/conda_build/skeletons/pypi.py b/conda_build/skeletons/pypi.py index 930e96c7f5..ed79fffff3 100644 --- a/conda_build/skeletons/pypi.py +++ b/conda_build/skeletons/pypi.py @@ -25,14 +25,10 @@ from conda.base.context import context from conda.gateways.connection.download import download from conda.gateways.disk.read import compute_sum +from conda.utils import human_bytes from requests.packages.urllib3.util.url import parse_url -from ..conda_interface import ( - human_bytes, - input, - normalized_version, - spec_from_line, -) +from ..conda_interface import input, normalized_version, spec_from_line from ..config import Config from ..environ import create_env from ..license_family import allowed_license_families, guess_license_family From 7c100a0a9183061c97ce6f1a7764ad7ca6da8ec7 Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Wed, 10 Apr 2024 14:19:29 -0500 Subject: [PATCH 16/32] Deprecate input --- conda_build/conda_interface.py | 9 ++++++++- conda_build/skeletons/pypi.py | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index 46c2031ba2..78f2d78813 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -4,6 +4,7 @@ import configparser as _configparser import os as _os +from builtins import input as _input from functools import partial as _partial from importlib import import_module as _import_module from io import StringIO as _StringIO @@ -34,7 +35,6 @@ InstalledPackages, # unused NoPackagesFound, # unused Unsatisfiable, # unused - input, lchmod, normalized_version, prefix_placeholder, @@ -210,6 +210,13 @@ _StringIO, addendum="Use `io.StringIO` instead.", ) +deprecated.constant( + "24.5", + "24.7", + "input", + _input, + addendum="Use `input` instead.", +) deprecated.constant( "24.5", diff --git a/conda_build/skeletons/pypi.py b/conda_build/skeletons/pypi.py index ed79fffff3..1ce4b94e26 100644 --- a/conda_build/skeletons/pypi.py +++ b/conda_build/skeletons/pypi.py @@ -28,7 +28,7 @@ from conda.utils import human_bytes from requests.packages.urllib3.util.url import parse_url -from ..conda_interface import input, normalized_version, spec_from_line +from ..conda_interface import normalized_version, spec_from_line from ..config import Config from ..environ import create_env from ..license_family import allowed_license_families, guess_license_family From 8e285267fafc7af535020e5d5ef44dc86c6d2ece Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Wed, 10 Apr 2024 14:22:45 -0500 Subject: [PATCH 17/32] Deprecate lchmod --- conda_build/conda_interface.py | 9 ++++++++- conda_build/post.py | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index 78f2d78813..4f90744b42 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -35,7 +35,6 @@ InstalledPackages, # unused NoPackagesFound, # unused Unsatisfiable, # unused - lchmod, normalized_version, prefix_placeholder, rm_rf, @@ -53,6 +52,7 @@ from conda.gateways.connection.download import TmpDownload as _TmpDownload from conda.gateways.connection.download import download as _download from conda.gateways.disk.create import TemporaryDirectory as _TemporaryDirectory +from conda.gateways.disk.link import lchmod as _lchmod from conda.gateways.disk.read import compute_sum as _compute_sum from conda.models.channel import Channel as _Channel from conda.models.channel import get_conda_build_local_url as _get_conda_build_local_url @@ -180,6 +180,13 @@ _human_bytes, addendum="Use `conda.utils.human_bytes` instead.", ) +deprecated.constant( + "24.5", + "24.7", + "lchmod", + _lchmod, + addendum="Use `conda.gateways.disk.link.lchmod` instead.", +) deprecated.constant( "24.5", diff --git a/conda_build/post.py b/conda_build/post.py index f63d6851d5..6fd41a6dc2 100644 --- a/conda_build/post.py +++ b/conda_build/post.py @@ -36,11 +36,12 @@ from conda.core.prefix_data import PrefixData from conda.gateways.disk.create import TemporaryDirectory +from conda.gateways.disk.link import lchmod from conda.gateways.disk.read import compute_sum from conda.models.records import PrefixRecord from . import utils -from .conda_interface import lchmod, walk_prefix +from .conda_interface import walk_prefix from .exceptions import OverDependingError, OverLinkingError, RunPathError from .inspect_pkg import which_package from .os_utils import external, macho From ce49bdcc510d2a8f020d4e7a097b7163959d1979 Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Wed, 10 Apr 2024 14:24:13 -0500 Subject: [PATCH 18/32] Deprecate normalized_version --- conda_build/conda_interface.py | 9 ++++++++- conda_build/skeletons/pypi.py | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index 4f90744b42..864c0abb52 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -35,7 +35,6 @@ InstalledPackages, # unused NoPackagesFound, # unused Unsatisfiable, # unused - normalized_version, prefix_placeholder, rm_rf, spec_from_line, @@ -61,6 +60,7 @@ from conda.models.match_spec import MatchSpec as _MatchSpec from conda.models.records import PackageRecord as _PackageRecord from conda.models.version import VersionOrder as _VersionOrder +from conda.models.version import normalized_version as _normalized_version from conda.resolve import Resolve as _Resolve from conda.utils import human_bytes as _human_bytes @@ -130,6 +130,13 @@ _VersionOrder, addendum="Use `conda.models.version.VersionOrder` instead.", ) +deprecated.constant( + "24.5", + "24.7", + "normalized_version", + _normalized_version, + addendum="Use `conda.models.version.normalized_version` instead.", +) deprecated.constant( "24.5", diff --git a/conda_build/skeletons/pypi.py b/conda_build/skeletons/pypi.py index 1ce4b94e26..0d0401e832 100644 --- a/conda_build/skeletons/pypi.py +++ b/conda_build/skeletons/pypi.py @@ -25,10 +25,11 @@ from conda.base.context import context from conda.gateways.connection.download import download from conda.gateways.disk.read import compute_sum +from conda.modules.version import normalized_version from conda.utils import human_bytes from requests.packages.urllib3.util.url import parse_url -from ..conda_interface import normalized_version, spec_from_line +from ..conda_interface import spec_from_line from ..config import Config from ..environ import create_env from ..license_family import allowed_license_families, guess_license_family From 3e0aefbffe57c3d32de050fe25d47f8cd9dcc36b Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Wed, 10 Apr 2024 14:27:45 -0500 Subject: [PATCH 19/32] Deprecate prefix_placeholder --- conda_build/build.py | 17 +++++++---------- conda_build/conda_interface.py | 9 ++++++++- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/conda_build/build.py b/conda_build/build.py index 05483b3de1..33c9039b02 100644 --- a/conda_build/build.py +++ b/conda_build/build.py @@ -27,6 +27,7 @@ from bs4 import UnicodeDammit from conda import __version__ as conda_version from conda.auxlib.entity import EntityEncoder +from conda.base.constants import PREFIX_PLACEHOLDER from conda.base.context import context, reset_context from conda.core.prefix_data import PrefixData from conda.exceptions import CondaError, NoPackagesFoundError, UnsatisfiableError @@ -37,11 +38,7 @@ from . import __version__ as conda_build_version from . import environ, noarch_python, source, tarcheck, utils -from .conda_interface import ( - env_path_backup_var_exists, - prefix_placeholder, - url_path, -) +from .conda_interface import env_path_backup_var_exists, url_path from .config import Config from .create_test import create_all_test_files from .deprecations import deprecated @@ -194,7 +191,7 @@ def have_prefix_files(files, prefix): """ prefix_bytes = prefix.encode(utils.codec) - prefix_placeholder_bytes = prefix_placeholder.encode(utils.codec) + prefix_placeholder_bytes = PREFIX_PLACEHOLDER.encode(utils.codec) searches = {prefix: prefix_bytes} if utils.on_win: # some windows libraries use unix-style path separators @@ -205,7 +202,7 @@ def have_prefix_files(files, prefix): double_backslash_prefix = prefix.replace("\\", "\\\\") double_backslash_prefix_bytes = double_backslash_prefix.encode(utils.codec) searches[double_backslash_prefix] = double_backslash_prefix_bytes - searches[prefix_placeholder] = prefix_placeholder_bytes + searches[PREFIX_PLACEHOLDER] = prefix_placeholder_bytes min_prefix = min(len(k) for k, _ in searches.items()) # mm.find is incredibly slow, so ripgrep is used to pre-filter the list. @@ -1148,13 +1145,13 @@ def get_files_with_prefix(m, replacements, files_in, prefix): prefix[0].upper() + prefix[1:], prefix[0].lower() + prefix[1:], prefix_u, - prefix_placeholder.replace("\\", "'"), - prefix_placeholder.replace("/", "\\"), + PREFIX_PLACEHOLDER.replace("\\", "'"), + PREFIX_PLACEHOLDER.replace("/", "\\"), ] # some python/json files store an escaped version of prefix pfx_variants.extend([pfx.replace("\\", "\\\\") for pfx in pfx_variants]) else: - pfx_variants = (prefix, prefix_placeholder) + pfx_variants = (prefix, PREFIX_PLACEHOLDER) # replacing \ with \\ here is for regex escaping re_test = ( b"(" diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index 864c0abb52..433af8661f 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -11,6 +11,7 @@ from conda import __version__ from conda.auxlib.entity import EntityEncoder as _EntityEncoder +from conda.base.constants import PREFIX_PLACEHOLDER as _PREFIX_PLACEHOLDER from conda.base.context import context as _context from conda.base.context import determine_target_prefix as _determine_target_prefix from conda.base.context import non_x86_machines as _non_x86_linux_machines @@ -35,7 +36,6 @@ InstalledPackages, # unused NoPackagesFound, # unused Unsatisfiable, # unused - prefix_placeholder, rm_rf, spec_from_line, specs_from_args, @@ -194,6 +194,13 @@ _lchmod, addendum="Use `conda.gateways.disk.link.lchmod` instead.", ) +deprecated.constant( + "24.5", + "24.7", + "prefix_placeholder", + _PREFIX_PLACEHOLDER, + addendum="Use `conda.base.constants.PREFIX_PLACEHOLDER` instead.", +) deprecated.constant( "24.5", From ed4427fe75e095b8a82c59f5308bd69ffafc1fab Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Thu, 11 Apr 2024 00:10:57 -0500 Subject: [PATCH 20/32] Deprecate rm_rf --- conda_build/conda_interface.py | 9 ++++++++- conda_build/utils.py | 11 ++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index 433af8661f..9bd1cc6a03 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -36,7 +36,6 @@ InstalledPackages, # unused NoPackagesFound, # unused Unsatisfiable, # unused - rm_rf, spec_from_line, specs_from_args, specs_from_url, @@ -65,6 +64,7 @@ from conda.utils import human_bytes as _human_bytes from .deprecations import deprecated +from .utils import rm_rf as _rm_rf deprecated.constant( "24.5", @@ -201,6 +201,13 @@ _PREFIX_PLACEHOLDER, addendum="Use `conda.base.constants.PREFIX_PLACEHOLDER` instead.", ) +deprecated.constant( + "24.5", + "24.7", + "rm_rf", + _rm_rf, + addendum="Use `conda_build.utils.rm_rf` instead.", +) deprecated.constant( "24.5", diff --git a/conda_build/utils.py b/conda_build/utils.py index 0d367960a0..4ce7563afa 100644 --- a/conda_build/utils.py +++ b/conda_build/utils.py @@ -69,7 +69,7 @@ unix_path_to_win, win_path_to_unix, ) -from .conda_interface import rm_rf as _rm_rf +from .deprecations import deprecated from .exceptions import BuildLockError if TYPE_CHECKING: @@ -1617,8 +1617,13 @@ def filter_info_files(files_list, prefix): ) -def rm_rf(path, config=None): - return _rm_rf(path) +@deprecated.argument("24.5", "24.7", "config") +def rm_rf(path): + from conda.core.prefix_data import delete_prefix_from_linked_data + from conda.gateways.disk.delete import rm_rf as rm_rf + + rm_rf(path) + delete_prefix_from_linked_data(path) # https://stackoverflow.com/a/31459386/1170370 From 43b3ee78cf4da8143e42368719cd4c2572529d87 Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Thu, 11 Apr 2024 11:32:01 -0500 Subject: [PATCH 21/32] Deprecate spec[s]_from_* --- conda_build/bdist_conda.py | 2 +- conda_build/conda_interface.py | 27 ++++++++++++++++++++++++--- conda_build/inspect_pkg.py | 4 +--- conda_build/render.py | 2 +- conda_build/skeletons/pypi.py | 2 +- 5 files changed, 28 insertions(+), 9 deletions(-) diff --git a/conda_build/bdist_conda.py b/conda_build/bdist_conda.py index 1002352f42..45a1ff845e 100644 --- a/conda_build/bdist_conda.py +++ b/conda_build/bdist_conda.py @@ -6,13 +6,13 @@ from collections import defaultdict from io import StringIO +from conda.cli.common import spec_from_line from setuptools.command.install import install from setuptools.dist import Distribution from setuptools.errors import BaseError, OptionError from . import api from .build import handle_anaconda_upload -from .conda_interface import spec_from_line from .config import Config from .deprecations import deprecated from .metadata import MetaData diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index 9bd1cc6a03..c38ec02592 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -16,6 +16,9 @@ from conda.base.context import determine_target_prefix as _determine_target_prefix from conda.base.context import non_x86_machines as _non_x86_linux_machines from conda.base.context import reset_context as _reset_context +from conda.cli.common import spec_from_line as _spec_from_line +from conda.cli.common import specs_from_args as _specs_from_args +from conda.cli.common import specs_from_url as _specs_from_url from conda.cli.conda_argparse import ArgumentParser as _ArgumentParser from conda.cli.helpers import add_parser_channels as _add_parser_channels from conda.cli.helpers import add_parser_prefix as _add_parser_prefix @@ -36,9 +39,6 @@ InstalledPackages, # unused NoPackagesFound, # unused Unsatisfiable, # unused - spec_from_line, - specs_from_args, - specs_from_url, symlink_conda, unix_path_to_win, untracked, @@ -208,6 +208,27 @@ _rm_rf, addendum="Use `conda_build.utils.rm_rf` instead.", ) +deprecated.constant( + "24.5", + "24.7", + "spec_from_line", + _spec_from_line, + addendum="Use `conda.cli.common.spec_from_line` instead.", +) +deprecated.constant( + "24.5", + "24.7", + "specs_from_args", + _specs_from_args, + addendum="Use `conda.cli.common.specs_from_args` instead.", +) +deprecated.constant( + "24.5", + "24.7", + "specs_from_url", + _specs_from_url, + addendum="Use `conda.cli.common.specs_from_url` instead.", +) deprecated.constant( "24.5", diff --git a/conda_build/inspect_pkg.py b/conda_build/inspect_pkg.py index 7d7c61f8f9..b202a7eb68 100644 --- a/conda_build/inspect_pkg.py +++ b/conda_build/inspect_pkg.py @@ -15,13 +15,11 @@ from conda.api import Solver from conda.base.context import context +from conda.cli.common import specs_from_args from conda.core.index import get_index from conda.core.prefix_data import PrefixData from conda.models.records import PrefixRecord -from .conda_interface import ( - specs_from_args, -) from .os_utils.ldd import ( get_linkages, get_package_obj_files, diff --git a/conda_build/render.py b/conda_build/render.py index 55515e721d..78a9ed643e 100644 --- a/conda_build/render.py +++ b/conda_build/render.py @@ -26,6 +26,7 @@ import yaml from conda.base.context import context +from conda.cli.common import specs_from_url from conda.core.package_cache_data import ProgressiveFetchExtract from conda.exceptions import UnsatisfiableError from conda.gateways.disk.create import TemporaryDirectory @@ -33,7 +34,6 @@ from conda.models.version import VersionOrder from . import environ, exceptions, source, utils -from .conda_interface import specs_from_url from .exceptions import DependencyNeedsBuildingError from .index import get_build_index from .metadata import MetaData, combine_top_level_metadata_with_output diff --git a/conda_build/skeletons/pypi.py b/conda_build/skeletons/pypi.py index 0d0401e832..de846c74d3 100644 --- a/conda_build/skeletons/pypi.py +++ b/conda_build/skeletons/pypi.py @@ -23,13 +23,13 @@ import requests import yaml from conda.base.context import context +from conda.cli.common import spec_from_line from conda.gateways.connection.download import download from conda.gateways.disk.read import compute_sum from conda.modules.version import normalized_version from conda.utils import human_bytes from requests.packages.urllib3.util.url import parse_url -from ..conda_interface import spec_from_line from ..config import Config from ..environ import create_env from ..license_family import allowed_license_families, guess_license_family From 611538b36e0b47ea055b134982555a446e72546a Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Thu, 11 Apr 2024 11:34:41 -0500 Subject: [PATCH 22/32] Deprecate unix_path_to_win --- conda_build/conda_interface.py | 11 +++++++++-- conda_build/utils.py | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index c38ec02592..66dee441cb 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -39,8 +39,7 @@ InstalledPackages, # unused NoPackagesFound, # unused Unsatisfiable, # unused - symlink_conda, - unix_path_to_win, + symlink_conda, # unused untracked, url_path, walk_prefix, @@ -62,6 +61,7 @@ from conda.models.version import normalized_version as _normalized_version from conda.resolve import Resolve as _Resolve from conda.utils import human_bytes as _human_bytes +from conda.utils import unix_path_to_win as _unix_path_to_win from .deprecations import deprecated from .utils import rm_rf as _rm_rf @@ -229,6 +229,13 @@ _specs_from_url, addendum="Use `conda.cli.common.specs_from_url` instead.", ) +deprecated.constant( + "24.5", + "24.7", + "unix_path_to_win", + _unix_path_to_win, + addendum="Use `conda.utils.unix_path_to_win` instead.", +) deprecated.constant( "24.5", diff --git a/conda_build/utils.py b/conda_build/utils.py index 4ce7563afa..8cce97a431 100644 --- a/conda_build/utils.py +++ b/conda_build/utils.py @@ -63,10 +63,10 @@ from conda.models.match_spec import MatchSpec from conda.models.records import PackageRecord from conda.models.version import VersionOrder +from conda.utils import unix_path_to_win from .conda_interface import ( cc_conda_build, - unix_path_to_win, win_path_to_unix, ) from .deprecations import deprecated From 6211c682e2cd3bc32c939541a40a4569401278d4 Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Thu, 11 Apr 2024 11:36:00 -0500 Subject: [PATCH 23/32] Deprecate untracked --- conda_build/conda_interface.py | 9 ++++++++- conda_build/os_utils/ldd.py | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index 66dee441cb..5be3cfe934 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -40,7 +40,6 @@ NoPackagesFound, # unused Unsatisfiable, # unused symlink_conda, # unused - untracked, url_path, walk_prefix, win_path_to_unix, @@ -51,6 +50,7 @@ from conda.gateways.disk.create import TemporaryDirectory as _TemporaryDirectory from conda.gateways.disk.link import lchmod as _lchmod from conda.gateways.disk.read import compute_sum as _compute_sum +from conda.misc import untracked as _untracked from conda.models.channel import Channel as _Channel from conda.models.channel import get_conda_build_local_url as _get_conda_build_local_url from conda.models.enums import FileMode as _FileMode @@ -236,6 +236,13 @@ _unix_path_to_win, addendum="Use `conda.utils.unix_path_to_win` instead.", ) +deprecated.constant( + "24.5", + "24.7", + "untracked", + _untracked, + addendum="Use `conda.misc.untracked` instead.", +) deprecated.constant( "24.5", diff --git a/conda_build/os_utils/ldd.py b/conda_build/os_utils/ldd.py index 6f15173f29..c07a7adb71 100644 --- a/conda_build/os_utils/ldd.py +++ b/conda_build/os_utils/ldd.py @@ -9,7 +9,8 @@ from pathlib import Path from typing import TYPE_CHECKING -from ..conda_interface import untracked +from conda.misc import untracked + from ..utils import on_linux, on_mac from .macho import otool from .pyldd import codefile_class, inspect_linkages, machofile From c944714a5ba1a31ca2c61700b1c681280d6576ce Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Thu, 11 Apr 2024 11:37:47 -0500 Subject: [PATCH 24/32] Deprecate url_path --- conda_build/build.py | 3 ++- conda_build/conda_interface.py | 9 ++++++++- conda_build/config.py | 3 ++- conda_build/index.py | 2 +- conda_build/source.py | 2 +- tests/test_api_build.py | 2 +- 6 files changed, 15 insertions(+), 6 deletions(-) diff --git a/conda_build/build.py b/conda_build/build.py index 33c9039b02..0839caa3ca 100644 --- a/conda_build/build.py +++ b/conda_build/build.py @@ -35,10 +35,11 @@ from conda.models.channel import Channel from conda.models.enums import FileMode, PathType from conda.models.match_spec import MatchSpec +from conda.utils import url_path from . import __version__ as conda_build_version from . import environ, noarch_python, source, tarcheck, utils -from .conda_interface import env_path_backup_var_exists, url_path +from .conda_interface import env_path_backup_var_exists from .config import Config from .create_test import create_all_test_files from .deprecations import deprecated diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index 5be3cfe934..8eaa685902 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -40,7 +40,6 @@ NoPackagesFound, # unused Unsatisfiable, # unused symlink_conda, # unused - url_path, walk_prefix, win_path_to_unix, ) @@ -62,6 +61,7 @@ from conda.resolve import Resolve as _Resolve from conda.utils import human_bytes as _human_bytes from conda.utils import unix_path_to_win as _unix_path_to_win +from conda.utils import url_path as _url_path from .deprecations import deprecated from .utils import rm_rf as _rm_rf @@ -243,6 +243,13 @@ _untracked, addendum="Use `conda.misc.untracked` instead.", ) +deprecated.constant( + "24.5", + "24.7", + "url_path", + _url_path, + addendum="Use `conda.utils.url_path` instead.", +) deprecated.constant( "24.5", diff --git a/conda_build/config.py b/conda_build/config.py index fd599506bc..560531b460 100644 --- a/conda_build/config.py +++ b/conda_build/config.py @@ -17,8 +17,9 @@ from typing import TYPE_CHECKING from conda.base.context import context +from conda.utils import url_path -from .conda_interface import cc_conda_build, url_path +from .conda_interface import cc_conda_build from .utils import ( get_build_folders, get_conda_operation_locks, diff --git a/conda_build/index.py b/conda_build/index.py index 28a470f5c4..28f29063aa 100644 --- a/conda_build/index.py +++ b/conda_build/index.py @@ -11,10 +11,10 @@ from conda.base.context import context from conda.core.index import get_index from conda.exceptions import CondaHTTPError +from conda.utils import url_path from conda_index.index import update_index as _update_index from . import utils -from .conda_interface import url_path from .deprecations import deprecated from .utils import ( CONDA_PACKAGE_EXTENSION_V1, diff --git a/conda_build/source.py b/conda_build/source.py index d76fb35ed9..c7b3d1921b 100644 --- a/conda_build/source.py +++ b/conda_build/source.py @@ -19,8 +19,8 @@ from conda.gateways.connection.download import download from conda.gateways.disk.create import TemporaryDirectory from conda.gateways.disk.read import compute_sum +from conda.utils import url_path -from .conda_interface import url_path from .exceptions import MissingDependency from .os_utils import external from .utils import ( diff --git a/tests/test_api_build.py b/tests/test_api_build.py index 5932bf4f1a..8871fcedf7 100644 --- a/tests/test_api_build.py +++ b/tests/test_api_build.py @@ -30,10 +30,10 @@ from conda.base.context import context, reset_context from conda.common.compat import on_linux, on_mac, on_win from conda.exceptions import ClobberError, CondaError, CondaMultiError, LinkError +from conda.utils import url_path from conda_index.api import update_index from conda_build import __version__, api, exceptions -from conda_build.conda_interface import url_path from conda_build.config import Config from conda_build.exceptions import ( CondaBuildException, From 9fa63468700a89fa0f278ddce4547af7130ee54d Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Thu, 11 Apr 2024 11:38:46 -0500 Subject: [PATCH 25/32] Deprecate walk_prefix --- conda_build/conda_interface.py | 9 ++++++++- conda_build/post.py | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index 8eaa685902..1bca9cb090 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -40,7 +40,6 @@ NoPackagesFound, # unused Unsatisfiable, # unused symlink_conda, # unused - walk_prefix, win_path_to_unix, ) from conda.exports import get_index as _get_index @@ -50,6 +49,7 @@ from conda.gateways.disk.link import lchmod as _lchmod from conda.gateways.disk.read import compute_sum as _compute_sum from conda.misc import untracked as _untracked +from conda.misc import walk_prefix as _walk_prefix from conda.models.channel import Channel as _Channel from conda.models.channel import get_conda_build_local_url as _get_conda_build_local_url from conda.models.enums import FileMode as _FileMode @@ -250,6 +250,13 @@ _url_path, addendum="Use `conda.utils.url_path` instead.", ) +deprecated.constant( + "24.5", + "24.7", + "walk_prefix", + _walk_prefix, + addendum="Use `conda.misc.walk_prefix` instead.", +) deprecated.constant( "24.5", diff --git a/conda_build/post.py b/conda_build/post.py index 6fd41a6dc2..30a4057a30 100644 --- a/conda_build/post.py +++ b/conda_build/post.py @@ -38,10 +38,10 @@ from conda.gateways.disk.create import TemporaryDirectory from conda.gateways.disk.link import lchmod from conda.gateways.disk.read import compute_sum +from conda.misc import walk_prefix from conda.models.records import PrefixRecord from . import utils -from .conda_interface import walk_prefix from .exceptions import OverDependingError, OverLinkingError, RunPathError from .inspect_pkg import which_package from .os_utils import external, macho From d0cb53a53804bd7c443de1c11964549574d7aa07 Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Thu, 11 Apr 2024 11:40:52 -0500 Subject: [PATCH 26/32] Deprecate win_path_to_unix --- conda_build/conda_interface.py | 9 ++++++++- conda_build/utils.py | 6 ++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index 1bca9cb090..4729257dd1 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -22,6 +22,7 @@ from conda.cli.conda_argparse import ArgumentParser as _ArgumentParser from conda.cli.helpers import add_parser_channels as _add_parser_channels from conda.cli.helpers import add_parser_prefix as _add_parser_prefix +from conda.common.path import win_path_to_unix as _win_path_to_unix from conda.common.toposort import _toposort as __toposort from conda.core.package_cache_data import ( ProgressiveFetchExtract as _ProgressiveFetchExtract, @@ -40,7 +41,6 @@ NoPackagesFound, # unused Unsatisfiable, # unused symlink_conda, # unused - win_path_to_unix, ) from conda.exports import get_index as _get_index from conda.gateways.connection.download import TmpDownload as _TmpDownload @@ -257,6 +257,13 @@ _walk_prefix, addendum="Use `conda.misc.walk_prefix` instead.", ) +deprecated.constant( + "24.5", + "24.7", + "win_path_to_unix", + _win_path_to_unix, + addendum="Use `conda.common.path.win_path_to_unix` instead.", +) deprecated.constant( "24.5", diff --git a/conda_build/utils.py b/conda_build/utils.py index 8cce97a431..26c22c640d 100644 --- a/conda_build/utils.py +++ b/conda_build/utils.py @@ -55,6 +55,7 @@ KNOWN_SUBDIRS, ) from conda.base.context import context +from conda.common.path import win_path_to_unix from conda.exceptions import CondaHTTPError from conda.gateways.connection.download import download from conda.gateways.disk.create import TemporaryDirectory @@ -65,10 +66,7 @@ from conda.models.version import VersionOrder from conda.utils import unix_path_to_win -from .conda_interface import ( - cc_conda_build, - win_path_to_unix, -) +from .conda_interface import cc_conda_build from .deprecations import deprecated from .exceptions import BuildLockError From ec0feebdf5abf06d236b4375e5e732195f0b40b4 Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Thu, 11 Apr 2024 11:49:13 -0500 Subject: [PATCH 27/32] Deprecate unused --- conda_build/conda_interface.py | 57 +++++++++++++++++++++++++++++----- 1 file changed, 49 insertions(+), 8 deletions(-) diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index 4729257dd1..d9e409d210 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -33,18 +33,15 @@ from conda.exceptions import LockError as _LockError from conda.exceptions import NoPackagesFoundError as _NoPackagesFoundError from conda.exceptions import PaddingError as _PaddingError +from conda.exceptions import ResolvePackageNotFound as _ResolvePackageNotFound from conda.exceptions import UnsatisfiableError as _UnsatisfiableError -from conda.exports import ( # noqa: F401 - Completer, # unused - CondaSession, # unused - InstalledPackages, # unused - NoPackagesFound, # unused - Unsatisfiable, # unused - symlink_conda, # unused -) +from conda.exports import Completer as _Completer +from conda.exports import InstalledPackages as _InstalledPackages from conda.exports import get_index as _get_index +from conda.exports import symlink_conda as _symlink_conda from conda.gateways.connection.download import TmpDownload as _TmpDownload from conda.gateways.connection.download import download as _download +from conda.gateways.connection.session import CondaSession as _CondaSession from conda.gateways.disk.create import TemporaryDirectory as _TemporaryDirectory from conda.gateways.disk.link import lchmod as _lchmod from conda.gateways.disk.read import compute_sum as _compute_sum @@ -66,6 +63,50 @@ from .deprecations import deprecated from .utils import rm_rf as _rm_rf +deprecated.constant( + "24.5", + "24.7", + "Completer", + _Completer, + addendum="Unused.", +) +deprecated.constant( + "24.5", + "24.7", + "CondaSession", + _CondaSession, + addendum="Use `conda.gateways.connection.session.CondaSession` instead.", +) +deprecated.constant( + "24.5", + "24.7", + "InstalledPackages", + _InstalledPackages, + addendum="Unused.", +) +deprecated.constant( + "24.5", + "24.7", + "NoPackagesFound", + _ResolvePackageNotFound, + addendum="Use `conda.exceptions.ResolvePackageNotFound` instead.", +) +deprecated.constant( + "24.5", + "24.7", + "Unsatisfiable", + _UnsatisfiableError, + addendum="Use `conda.exceptions.UnsatisfiableError` instead.", +) +deprecated.constant( + "24.5", + "24.7", + "symlink_conda", + _symlink_conda, + addendum="Unused.", +) + + deprecated.constant( "24.5", "24.7", From 81be10d642a4f0614109da27cc1eeede967b3bc7 Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Thu, 11 Apr 2024 12:02:28 -0500 Subject: [PATCH 28/32] Deprecate cc_conda_build --- conda_build/cli/main_build.py | 61 ++++++++++++++++++---------------- conda_build/cli/main_render.py | 4 +-- conda_build/conda_interface.py | 8 ++++- conda_build/config.py | 35 ++++++++++--------- conda_build/skeletons/cran.py | 4 +-- conda_build/utils.py | 7 ++-- conda_build/variants.py | 5 ++- tests/test_api_render.py | 37 ++++++++++----------- tests/test_utils.py | 7 ++-- tests/utils.py | 7 +--- 10 files changed, 90 insertions(+), 85 deletions(-) diff --git a/conda_build/cli/main_build.py b/conda_build/cli/main_build.py index 3d85fd3b02..39c835010a 100644 --- a/conda_build/cli/main_build.py +++ b/conda_build/cli/main_build.py @@ -18,7 +18,6 @@ from conda.common.io import dashlist from .. import api, build, source, utils -from ..conda_interface import cc_conda_build from ..config import ( get_channel_urls, get_or_merge_config, @@ -69,7 +68,7 @@ def parse_args(args: Sequence[str] | None) -> tuple[ArgumentParser, Namespace]: action="store_false", help="Don't include the recipe inside the built package.", dest="include_recipe", - default=cc_conda_build.get("include_recipe", "true").lower() == "true", + default=context.conda_build.get("include_recipe", "true").lower() == "true", ) parser.add_argument( "-s", @@ -124,7 +123,7 @@ def parse_args(args: Sequence[str] | None) -> tuple[ArgumentParser, Namespace]: "Skip recipes for which there already exists an existing build " "(locally or in the channels)." ), - default=cc_conda_build.get("skip_existing", "false").lower() == "true", + default=context.conda_build.get("skip_existing", "false").lower() == "true", ) parser.add_argument( "--keep-old-work", @@ -144,7 +143,7 @@ def parse_args(args: Sequence[str] | None) -> tuple[ArgumentParser, Namespace]: "--quiet", action="store_true", help="do not display progress bar", - default=cc_conda_build.get("quiet", "false").lower() == "true", + default=context.conda_build.get("quiet", "false").lower() == "true", ) parser.add_argument( "--debug", @@ -154,12 +153,12 @@ def parse_args(args: Sequence[str] | None) -> tuple[ArgumentParser, Namespace]: parser.add_argument( "--token", help="Token to pass through to anaconda upload", - default=cc_conda_build.get("anaconda_token"), + default=context.conda_build.get("anaconda_token"), ) parser.add_argument( "--user", help="User/organization to upload packages to on anaconda.org or pypi", - default=cc_conda_build.get("user"), + default=context.conda_build.get("user"), ) parser.add_argument( "--label", @@ -184,7 +183,7 @@ def parse_args(args: Sequence[str] | None) -> tuple[ArgumentParser, Namespace]: ), type=int, choices=range(1, 23), - default=cc_conda_build.get( + default=context.conda_build.get( "zstd_compression_level", zstd_compression_level_default ), ) @@ -209,23 +208,23 @@ def parse_args(args: Sequence[str] | None) -> tuple[ArgumentParser, Namespace]: "--config-file", help="path to .pypirc file to use when uploading to pypi", default=( - abspath(expanduser(expandvars(cc_conda_build.get("pypirc")))) - if cc_conda_build.get("pypirc") - else cc_conda_build.get("pypirc") + abspath(expanduser(expandvars(pypirc))) + if (pypirc := context.conda_build.get("pypirc")) + else None ), ) pypi_grp.add_argument( "--repository", "-r", help="PyPI repository to upload to", - default=cc_conda_build.get("pypi_repository", "pypitest"), + default=context.conda_build.get("pypi_repository", "pypitest"), ) parser.add_argument( "--no-activate", action="store_false", help="do not activate the build and test envs; just prepend to PATH", dest="activate", - default=cc_conda_build.get("activate", "true").lower() == "true", + default=context.conda_build.get("activate", "true").lower() == "true", ) parser.add_argument( "--no-build-id", @@ -236,7 +235,7 @@ def parse_args(args: Sequence[str] | None) -> tuple[ArgumentParser, Namespace]: ), dest="set_build_id", # note: inverted - dest stores positive logic - default=cc_conda_build.get("set_build_id", "true").lower() == "true", + default=context.conda_build.get("set_build_id", "true").lower() == "true", ) parser.add_argument( "--build-id-pat", @@ -245,7 +244,7 @@ def parse_args(args: Sequence[str] | None) -> tuple[ArgumentParser, Namespace]: "paths being too long." ), dest="build_id_pat", - default=cc_conda_build.get("build_id_pat", "{n}_{t}"), + default=context.conda_build.get("build_id_pat", "{n}_{t}"), ) parser.add_argument( "--croot", @@ -258,21 +257,22 @@ def parse_args(args: Sequence[str] | None) -> tuple[ArgumentParser, Namespace]: "--verify", action="store_true", help="run verification on recipes or packages when building", - default=cc_conda_build.get("verify", "true").lower() == "true", + default=context.conda_build.get("verify", "true").lower() == "true", ) parser.add_argument( "--no-verify", action="store_false", dest="verify", help="do not run verification on recipes or packages when building", - default=cc_conda_build.get("verify", "true").lower() == "true", + default=context.conda_build.get("verify", "true").lower() == "true", ) parser.add_argument( "--strict-verify", action="store_true", dest="exit_on_verify_error", help="Exit if any conda-verify check fail, instead of only printing them", - default=cc_conda_build.get("exit_on_verify_error", "false").lower() == "true", + default=context.conda_build.get("exit_on_verify_error", "false").lower() + == "true", ) parser.add_argument( "--output-folder", @@ -280,7 +280,7 @@ def parse_args(args: Sequence[str] | None) -> tuple[ArgumentParser, Namespace]: "folder to dump output package to. Package are moved here if build or test succeeds." " Destination folder must exist prior to using this." ), - default=cc_conda_build.get("output_folder"), + default=context.conda_build.get("output_folder"), ) parser.add_argument( "--no-prefix-length-fallback", @@ -349,7 +349,7 @@ def parse_args(args: Sequence[str] | None) -> tuple[ArgumentParser, Namespace]: "linked to any executables or shared libraries in built packages. This is disabled " "by default, but will be enabled by default in conda-build 4.0." ), - default=cc_conda_build.get("error_overlinking", "false").lower() == "true", + default=context.conda_build.get("error_overlinking", "false").lower() == "true", ) parser.add_argument( "--no-error-overlinking", @@ -360,7 +360,7 @@ def parse_args(args: Sequence[str] | None) -> tuple[ArgumentParser, Namespace]: "linked to any executables or shared libraries in built packages. This is currently " "the default behavior, but will change in conda-build 4.0." ), - default=cc_conda_build.get("error_overlinking", "false").lower() == "true", + default=context.conda_build.get("error_overlinking", "false").lower() == "true", ) parser.add_argument( "--error-overdepending", @@ -371,7 +371,8 @@ def parse_args(args: Sequence[str] | None) -> tuple[ArgumentParser, Namespace]: "`run_exports` are not auto-loaded by the OSes DSO loading mechanism by " "any of the files in this package." ), - default=cc_conda_build.get("error_overdepending", "false").lower() == "true", + default=context.conda_build.get("error_overdepending", "false").lower() + == "true", ) parser.add_argument( "--no-error-overdepending", @@ -382,7 +383,8 @@ def parse_args(args: Sequence[str] | None) -> tuple[ArgumentParser, Namespace]: "`run_exports` are not auto-loaded by the OSes DSO loading mechanism by " "any of the files in this package." ), - default=cc_conda_build.get("error_overdepending", "false").lower() == "true", + default=context.conda_build.get("error_overdepending", "false").lower() + == "true", ) parser.add_argument( "--long-test-prefix", @@ -392,7 +394,7 @@ def parse_args(args: Sequence[str] | None) -> tuple[ArgumentParser, Namespace]: "Linux and Mac. Prefix length matches the --prefix-length flag. This is on by " "default in conda-build 3.0+" ), - default=cc_conda_build.get("long_test_prefix", "true").lower() == "true", + default=context.conda_build.get("long_test_prefix", "true").lower() == "true", ) parser.add_argument( "--no-long-test-prefix", @@ -402,7 +404,7 @@ def parse_args(args: Sequence[str] | None) -> tuple[ArgumentParser, Namespace]: "Do not use a long prefix for the test prefix, as well as the build prefix." " Affects only Linux and Mac. Prefix length matches the --prefix-length flag. " ), - default=cc_conda_build.get("long_test_prefix", "true").lower() == "true", + default=context.conda_build.get("long_test_prefix", "true").lower() == "true", ) parser.add_argument( "--keep-going", @@ -419,16 +421,17 @@ def parse_args(args: Sequence[str] | None) -> tuple[ArgumentParser, Namespace]: "Path to store the source files (archives, git clones, etc.) during the build." ), default=( - abspath(expanduser(expandvars(cc_conda_build.get("cache_dir")))) - if cc_conda_build.get("cache_dir") - else cc_conda_build.get("cache_dir") + abspath(expanduser(expandvars(cache_dir))) + if (cache_dir := context.conda_build.get("cache_dir")) + else None ), ) parser.add_argument( "--no-copy-test-source-files", dest="copy_test_source_files", action="store_false", - default=cc_conda_build.get("copy_test_source_files", "true").lower() == "true", + default=context.conda_build.get("copy_test_source_files", "true").lower() + == "true", help=( "Disables copying the files necessary for testing the package into " "the info/test folder. Passing this argument means it may not be possible " @@ -444,7 +447,7 @@ def parse_args(args: Sequence[str] | None) -> tuple[ArgumentParser, Namespace]: "Merge the build and host directories, even when host section or compiler " "jinja2 is present" ), - default=cc_conda_build.get("merge_build_host", "false").lower() == "true", + default=context.conda_build.get("merge_build_host", "false").lower() == "true", ) parser.add_argument( "--stats-file", diff --git a/conda_build/cli/main_render.py b/conda_build/cli/main_render.py index 7262159c41..c3ac8ace5b 100644 --- a/conda_build/cli/main_render.py +++ b/conda_build/cli/main_render.py @@ -8,11 +8,11 @@ from typing import TYPE_CHECKING import yaml +from conda.base.context import context from conda.cli.helpers import add_parser_channels from yaml.parser import ParserError from .. import __version__, api -from ..conda_interface import cc_conda_build from ..config import get_channel_urls, get_or_merge_config from ..utils import LoggingContext from ..variants import get_package_variants, set_language_env_vars @@ -141,7 +141,7 @@ def get_render_parser() -> ArgumentParser: "--old-build-string", dest="filename_hashing", action="store_false", - default=cc_conda_build.get("filename_hashing", "true").lower() == "true", + default=context.conda_build.get("filename_hashing", "true").lower() == "true", help=( "Disable hash additions to filenames to distinguish package " "variants from one another. NOTE: any filename collisions are " diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index d9e409d210..b0e36ef438 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -519,7 +519,13 @@ _partial(_determine_target_prefix, _context), addendum="Use `conda.base.context.context.target_prefix` instead.", ) -cc_conda_build = _context.conda_build if hasattr(_context, "conda_build") else {} +deprecated.constant( + "24.5", + "24.7", + "cc_conda_build", + _context.conda_build, + addendum="Use `conda.base.context.context.conda_build` instead.", +) deprecated.constant( "24.5", diff --git a/conda_build/config.py b/conda_build/config.py index 560531b460..98f3e8b447 100644 --- a/conda_build/config.py +++ b/conda_build/config.py @@ -19,7 +19,6 @@ from conda.base.context import context from conda.utils import url_path -from .conda_interface import cc_conda_build from .utils import ( get_build_folders, get_conda_operation_locks, @@ -111,14 +110,16 @@ def _get_default_settings(): Setting("test_run_post", False), Setting( "filename_hashing", - cc_conda_build.get("filename_hashing", filename_hashing_default).lower() + context.conda_build.get( + "filename_hashing", filename_hashing_default + ).lower() == "true", ), Setting("keep_old_work", False), Setting( "_src_cache_root", - abspath(expanduser(expandvars(cc_conda_build.get("cache_dir")))) - if cc_conda_build.get("cache_dir") + abspath(expanduser(expandvars(cache_dir))) + if (cache_dir := context.conda_build.get("cache_dir")) else _src_cache_root_default, ), Setting("copy_test_source_files", True), @@ -143,30 +144,32 @@ def _get_default_settings(): # cli/main_build.py that this default will switch in conda-build 4.0. Setting( "error_overlinking", - cc_conda_build.get("error_overlinking", error_overlinking_default).lower() + context.conda_build.get( + "error_overlinking", error_overlinking_default + ).lower() == "true", ), Setting( "error_overdepending", - cc_conda_build.get( + context.conda_build.get( "error_overdepending", error_overdepending_default ).lower() == "true", ), Setting( "noarch_python_build_age", - cc_conda_build.get( + context.conda_build.get( "noarch_python_build_age", noarch_python_build_age_default ), ), Setting( "enable_static", - cc_conda_build.get("enable_static", enable_static_default).lower() + context.conda_build.get("enable_static", enable_static_default).lower() == "true", ), Setting( "no_rewrite_stdout_env", - cc_conda_build.get( + context.conda_build.get( "no_rewrite_stdout_env", no_rewrite_stdout_env_default ).lower() == "true", @@ -205,11 +208,13 @@ def _get_default_settings(): Setting("verify", True), Setting( "ignore_verify_codes", - cc_conda_build.get("ignore_verify_codes", ignore_verify_codes_default), + context.conda_build.get("ignore_verify_codes", ignore_verify_codes_default), ), Setting( "exit_on_verify_error", - cc_conda_build.get("exit_on_verify_error", exit_on_verify_error_default), + context.conda_build.get( + "exit_on_verify_error", exit_on_verify_error_default + ), ), # Recipes that have no host section, only build, should bypass the build/host line. # This is to make older recipes still work with cross-compiling. True cross-compiling @@ -227,17 +232,17 @@ def _get_default_settings(): Setting("_pip_cache_dir", None), Setting( "zstd_compression_level", - cc_conda_build.get( + context.conda_build.get( "zstd_compression_level", zstd_compression_level_default ), ), # this can be set to different values (currently only 2 means anything) to use package formats Setting( "conda_pkg_format", - cc_conda_build.get("pkg_format", conda_pkg_format_default), + context.conda_build.get("pkg_format", conda_pkg_format_default), ), Setting("suppress_variables", False), - Setting("build_id_pat", cc_conda_build.get("build_id_pat", "{n}_{t}")), + Setting("build_id_pat", context.conda_build.get("build_id_pat", "{n}_{t}")), ] @@ -450,7 +455,7 @@ def croot(self) -> str: """This is where source caches and work folders live""" if not self._croot: _bld_root_env = os.getenv("CONDA_BLD_PATH") - _bld_root_rc = cc_conda_build.get("root-dir") + _bld_root_rc = context.conda_build.get("root-dir") if _bld_root_env: self._croot = abspath(expanduser(_bld_root_env)) elif _bld_root_rc: diff --git a/conda_build/skeletons/cran.py b/conda_build/skeletons/cran.py index 1f1e435ec9..fbd959dba2 100755 --- a/conda_build/skeletons/cran.py +++ b/conda_build/skeletons/cran.py @@ -41,11 +41,11 @@ from typing import TYPE_CHECKING +from conda.base.context import context from conda.common.io import dashlist from conda.gateways.disk.create import TemporaryDirectory from .. import source -from ..conda_interface import cc_conda_build from ..config import get_or_merge_config from ..license_family import allowed_license_families, guess_license_family from ..metadata import MetaData @@ -455,7 +455,7 @@ def add_parser(repos): cran.add_argument( "-m", "--variant-config-files", - default=cc_conda_build.get("skeleton_config_yaml", None), + default=context.conda_build.get("skeleton_config_yaml", None), help="""Variant config file to add. These yaml files can contain keys such as `cran_mirror`. Only one can be provided here.""", ) diff --git a/conda_build/utils.py b/conda_build/utils.py index 26c22c640d..52110e5d22 100644 --- a/conda_build/utils.py +++ b/conda_build/utils.py @@ -66,7 +66,6 @@ from conda.models.version import VersionOrder from conda.utils import unix_path_to_win -from .conda_interface import cc_conda_build from .deprecations import deprecated from .exceptions import BuildLockError @@ -1679,10 +1678,8 @@ def reset_deduplicator(): def get_logger(name, level=logging.INFO, dedupe=True, add_stdout_stderr_handlers=True): config_file = None - if cc_conda_build.get("log_config_file"): - config_file = abspath( - expanduser(expandvars(cc_conda_build.get("log_config_file"))) - ) + if log_config_file := context.conda_build.get("log_config_file"): + config_file = abspath(expanduser(expandvars(log_config_file))) # by loading config file here, and then only adding handlers later, people # should be able to override conda-build's logger settings here. if config_file: diff --git a/conda_build/variants.py b/conda_build/variants.py index c5bbe9a41e..1e911b2c0b 100644 --- a/conda_build/variants.py +++ b/conda_build/variants.py @@ -14,7 +14,6 @@ import yaml from conda.base.context import context -from .conda_interface import cc_conda_build from .utils import ensure_list, get_logger, islist, on_win, trim_empty_keys from .version import _parse as parse_version @@ -224,8 +223,8 @@ def find_config_files(metadata_or_path, config): if not files and not config.ignore_system_variants: # user config - if cc_conda_build.get("config_file"): - cfg = resolve(cc_conda_build["config_file"]) + if config_file := context.conda_build.get("config_file"): + cfg = resolve(config_file) else: cfg = resolve(os.path.join("~", "conda_build_config.yaml")) if os.path.isfile(cfg): diff --git a/tests/test_api_render.py b/tests/test_api_render.py index 7849daa01c..60a381ebf1 100644 --- a/tests/test_api_render.py +++ b/tests/test_api_render.py @@ -15,7 +15,6 @@ from conda.common.compat import on_win from conda_build import api, render -from conda_build.conda_interface import cc_conda_build from conda_build.variants import validate_spec from .utils import metadata_dir, variants_dir @@ -213,7 +212,7 @@ def test_noarch_with_no_platform_deps(testing_workdir, testing_config): assert len(build_ids) == 1 -def test_setting_condarc_vars_with_env_var_expansion(testing_workdir): +def test_setting_condarc_vars_with_env_var_expansion(testing_workdir, mocker): os.makedirs("config") # python won't be used - the stuff in the recipe folder will override it python_versions = ["2.6", "3.4", "3.11"] @@ -221,27 +220,25 @@ def test_setting_condarc_vars_with_env_var_expansion(testing_workdir): with open(os.path.join("config", "conda_build_config.yaml"), "w") as f: yaml.dump(config, f, default_flow_style=False) - cc_conda_build_backup = cc_conda_build.copy() - # hacky equivalent of changing condarc - # careful, this is global and affects other tests! make sure to clear it! - cc_conda_build.update( - {"config_file": "${TEST_WORKDIR}/config/conda_build_config.yaml"} + mocker.patch( + "conda.base.context.Context.conda_build", + new_callable=mocker.PropertyMock, + return_value={ + "config_file": "${TEST_WORKDIR}/config/conda_build_config.yaml", + **context.conda_build, + }, ) os.environ["TEST_WORKDIR"] = testing_workdir - try: - m = api.render( - os.path.join(variants_dir, "19_used_variables"), - bypass_env_check=True, - finalize=False, - )[0][0] - # this one should have gotten clobbered by the values in the recipe - assert m.config.variant["python"] not in python_versions - # this confirms that we loaded the config file correctly - assert len(m.config.squished_variants["bzip2"]) == 2 - finally: - cc_conda_build.clear() - cc_conda_build.update(cc_conda_build_backup) + m = api.render( + os.path.join(variants_dir, "19_used_variables"), + bypass_env_check=True, + finalize=False, + )[0][0] + # this one should have gotten clobbered by the values in the recipe + assert m.config.variant["python"] not in python_versions + # this confirms that we loaded the config file correctly + assert len(m.config.squished_variants["bzip2"]) == 2 def test_self_reference_run_exports_pin_subpackage_picks_up_version_correctly(): diff --git a/tests/test_utils.py b/tests/test_utils.py index d245e65796..c0c85077d9 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -204,8 +204,11 @@ def test_logger_config_from_file(testing_workdir, capfd, mocker): handlers: [console] """ ) - cc_conda_build = mocker.patch.object(utils, "cc_conda_build") - cc_conda_build.get.return_value = test_file + mocker.patch( + "conda.base.context.Context.conda_build", + new_callable=mocker.PropertyMock, + return_value={"log_config_file": test_file}, + ) log = utils.get_logger(__name__) # default log level is INFO, but our config file should set level to DEBUG log.warn("test message") diff --git a/tests/utils.py b/tests/utils.py index 125cda7c91..b4ed64912b 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -8,10 +8,9 @@ from pathlib import Path from typing import TYPE_CHECKING -from conda.base.context import context, reset_context +from conda.base.context import reset_context from conda.common.compat import on_mac -from conda_build.conda_interface import cc_conda_build from conda_build.metadata import MetaData if TYPE_CHECKING: @@ -153,7 +152,3 @@ def get_noarch_python_meta(meta): def reset_config(search_path=None): reset_context(search_path) - cc_conda_build.clear() - cc_conda_build.update( - context.conda_build if hasattr(context, "conda_build") else {} - ) From d90c037c1d40bacf082211aa3386a432e3dc0cc3 Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Thu, 11 Apr 2024 12:05:21 -0500 Subject: [PATCH 29/32] Deprecate env_path_backup_var_exists --- conda_build/build.py | 7 ------- conda_build/conda_interface.py | 10 +++++++--- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/conda_build/build.py b/conda_build/build.py index 0839caa3ca..88461ac941 100644 --- a/conda_build/build.py +++ b/conda_build/build.py @@ -39,7 +39,6 @@ from . import __version__ as conda_build_version from . import environ, noarch_python, source, tarcheck, utils -from .conda_interface import env_path_backup_var_exists from .config import Config from .create_test import create_all_test_files from .deprecations import deprecated @@ -2411,8 +2410,6 @@ def build( with utils.path_prepended(m.config.build_prefix): env = environ.get_dict(m=m) env["CONDA_BUILD_STATE"] = "BUILD" - if env_path_backup_var_exists: - env["CONDA_PATH_BACKUP"] = os.environ["CONDA_PATH_BACKUP"] # this should be a no-op if source is already here if m.needs_source_for_render: @@ -3442,8 +3439,6 @@ def test( env.update(environ.get_dict(m=metadata, prefix=config.test_prefix)) env["CONDA_BUILD_STATE"] = "TEST" env["CONDA_BUILD"] = "1" - if env_path_backup_var_exists: - env["CONDA_PATH_BACKUP"] = os.environ["CONDA_PATH_BACKUP"] if not metadata.config.activate or metadata.name() == "conda": # prepend bin (or Scripts) directory @@ -3526,8 +3521,6 @@ def test( env = dict(os.environ.copy()) env.update(environ.get_dict(m=metadata, prefix=metadata.config.test_prefix)) env["CONDA_BUILD_STATE"] = "TEST" - if env_path_backup_var_exists: - env["CONDA_PATH_BACKUP"] = os.environ["CONDA_PATH_BACKUP"] if config.test_run_post: from .utils import get_installed_packages diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index b0e36ef438..8591373bc1 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -535,9 +535,13 @@ addendum="Use `conda.models.channel.Channel.from_value` instead.", ) -# When deactivating envs (e.g. switching from root to build/test) this env var is used, -# except the PR that removed this has been reverted (for now) and Windows doesn't need it. -env_path_backup_var_exists = _os.getenv("CONDA_PATH_BACKUP") +deprecated.constant( + "24.5", + "24.7", + "env_path_backup_var_exists", + _os.getenv("CONDA_PATH_BACKUP"), + addendum="Unused.", +) @deprecated( From 7e11f116c25e8b27eca3e353af0a69c2509ace7f Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Thu, 11 Apr 2024 12:16:04 -0500 Subject: [PATCH 30/32] Add news --- news/5276-deprecating-conda_interface | 56 +++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 news/5276-deprecating-conda_interface diff --git a/news/5276-deprecating-conda_interface b/news/5276-deprecating-conda_interface new file mode 100644 index 0000000000..701b9a53f1 --- /dev/null +++ b/news/5276-deprecating-conda_interface @@ -0,0 +1,56 @@ +### Enhancements + +* + +### Bug fixes + +* + +### Deprecations + +* Deprecate `conda_build.conda_interface._toposort`. Use `conda.common.toposort._toposort` instead. (#5276) +* Deprecate `conda_build.conda_interface.add_parser_channels`. Use `conda.cli.helpers.add_parser_channels` instead. (#5276) +* Deprecate `conda_build.conda_interface.add_parser_prefix`. Use `conda.cli.helpers.add_parser_prefix` instead. (#5276) +* Deprecate `conda_build.conda_interface.ArgumentParser`. Use `conda.cli.conda_argparse.ArgumentParser` instead. (#5276) +* Deprecate `conda_build.conda_interface.cc_conda_build`. Use `conda.base.context.context.conda_build` instead. (#5276) +* Deprecate `conda_build.conda_interface.Channel`. Use `conda.models.channel.Channel` instead. (#5276) +* Deprecate `conda_build.conda_interface.Completer`. Unused. (#5276) +* Deprecate `conda_build.conda_interface.CondaSession`. Use `conda.gateways.connection.session.CondaSession` instead. (#5276) +* Deprecate `conda_build.conda_interface.download`. Use `conda.gateways.connection.download.download` instead. (#5276) +* Deprecate `conda_build.conda_interface.EntityEncoder`. Use `conda.auxlib.entity.EntityEncoder` instead. (#5276) +* Deprecate `conda_build.conda_interface.env_path_backup_var_exists`. Unused. (#5276) +* Deprecate `conda_build.conda_interface.FileMode`. Use `conda.models.enums.FileMode` instead. (#5276) +* Deprecate `conda_build.conda_interface.human_bytes`. Use `conda.utils.human_bytes` instead. (#5276) +* Deprecate `conda_build.conda_interface.input`. Use `input` instead. (#5276) +* Deprecate `conda_build.conda_interface.InstalledPackages`. Unused. (#5276) +* Deprecate `conda_build.conda_interface.lchmod`. Use `conda.gateways.disk.link.lchmod` instead. (#5276) +* Deprecate `conda_build.conda_interface.MatchSpec`. Use `conda.models.match_spec.MatchSpec` instead. (#5276) +* Deprecate `conda_build.conda_interface.NoPackagesFound`. Use `conda.exceptions.ResolvePackageNotFound` instead. (#5276) +* Deprecate `conda_build.conda_interface.normalized_version`. Use `conda.models.version.normalized_version` instead. (#5276) +* Deprecate `conda_build.conda_interface.PackageRecord`. Use `conda.models.records.PackageRecord` instead. (#5276) +* Deprecate `conda_build.conda_interface.PathType`. Use `conda.models.enums.PathType` instead. (#5276) +* Deprecate `conda_build.conda_interface.prefix_placeholder`. Use `conda.base.constants.PREFIX_PLACEHOLDER` instead. (#5276) +* Deprecate `conda_build.conda_interface.Resolve`. Use `conda.resolve.Resolve` instead. (#5276) +* Deprecate `conda_build.conda_interface.rm_rf`. Use `conda_build.utils.rm_rf` instead. (#5276) +* Deprecate `conda_build.conda_interface.spec_from_line`. Use `conda.cli.common.spec_from_line` instead. (#5276) +* Deprecate `conda_build.conda_interface.specs_from_args`. Use `conda.cli.common.specs_from_args` instead. (#5276) +* Deprecate `conda_build.conda_interface.specs_from_url`. Use `conda.cli.common.specs_from_url` instead. (#5276) +* Deprecate `conda_build.conda_interface.StringIO`. Use `io.StringIO` instead. (#5276) +* Deprecate `conda_build.conda_interface.symlink_conda`. Unused. (#5276) +* Deprecate `conda_build.conda_interface.TempDirectory`. Use `conda.gateways.disk.create.TemporaryDirectory` instead. (#5276) +* Deprecate `conda_build.conda_interface.TmpDownload`. Use `conda.gateways.connection.download.TmpDownload` instead. (#5276) +* Deprecate `conda_build.conda_interface.unix_path_to_win`. Use `conda.utils.unix_path_to_win` instead. (#5276) +* Deprecate `conda_build.conda_interface.Unsatisfiable`. Use `conda.exceptions.UnsatisfiableError` instead. (#5276) +* Deprecate `conda_build.conda_interface.untracked`. Use `conda.misc.untracked` instead. (#5276) +* Deprecate `conda_build.conda_interface.url_path`. Use `conda.utils.url_path` instead. (#5276) +* Deprecate `conda_build.conda_interface.VersionOrder`. Use `conda.models.version.VersionOrder` instead. (#5276) +* Deprecate `conda_build.conda_interface.walk_prefix`. Use `conda.misc.walk_prefix` instead. (#5276) +* Deprecate `conda_build.conda_interface.win_path_to_unix`. Use `conda.common.path.win_path_to_unix` instead. (#5276) + +### Docs + +* + +### Other + +* From 301f761fa9f73e835836afbb8dbc0cdcc1ea24fa Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Thu, 11 Apr 2024 12:16:48 -0500 Subject: [PATCH 31/32] Fix --- conda_build/skeletons/pypi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conda_build/skeletons/pypi.py b/conda_build/skeletons/pypi.py index de846c74d3..7df95a9ad5 100644 --- a/conda_build/skeletons/pypi.py +++ b/conda_build/skeletons/pypi.py @@ -26,7 +26,7 @@ from conda.cli.common import spec_from_line from conda.gateways.connection.download import download from conda.gateways.disk.read import compute_sum -from conda.modules.version import normalized_version +from conda.models.version import normalized_version from conda.utils import human_bytes from requests.packages.urllib3.util.url import parse_url From cfc9682c245dd4cd82cc340226fbecdddda31484 Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Thu, 11 Apr 2024 12:32:49 -0500 Subject: [PATCH 32/32] Fallback import for conda<23.11 --- conda_build/cli/main_build.py | 7 ++++++- conda_build/cli/main_develop.py | 7 ++++++- conda_build/cli/main_inspect.py | 7 ++++++- conda_build/cli/main_metapackage.py | 7 ++++++- conda_build/cli/main_render.py | 7 ++++++- conda_build/conda_interface.py | 10 ++++++++-- 6 files changed, 38 insertions(+), 7 deletions(-) diff --git a/conda_build/cli/main_build.py b/conda_build/cli/main_build.py index 39c835010a..18e24827e0 100644 --- a/conda_build/cli/main_build.py +++ b/conda_build/cli/main_build.py @@ -14,7 +14,6 @@ from conda.auxlib.ish import dals from conda.base.context import context -from conda.cli.helpers import add_parser_channels from conda.common.io import dashlist from .. import api, build, source, utils @@ -27,6 +26,12 @@ from .actions import KeyValueAction from .main_render import get_render_parser +try: + from conda.cli.helpers import add_parser_channels +except ImportError: + # conda<23.11 + from conda.cli.conda_argparse import add_parser_channels + if TYPE_CHECKING: from argparse import ArgumentParser, Namespace from typing import Sequence diff --git a/conda_build/cli/main_develop.py b/conda_build/cli/main_develop.py index 59528b6d3d..326c5fd2a7 100644 --- a/conda_build/cli/main_develop.py +++ b/conda_build/cli/main_develop.py @@ -6,10 +6,15 @@ from typing import TYPE_CHECKING from conda.base.context import context, determine_target_prefix -from conda.cli.helpers import add_parser_prefix from .. import api +try: + from conda.cli.helpers import add_parser_prefix +except ImportError: + # conda<23.11 + from conda.cli.conda_argparse import add_parser_prefix + if TYPE_CHECKING: from argparse import ArgumentParser, Namespace from typing import Sequence diff --git a/conda_build/cli/main_inspect.py b/conda_build/cli/main_inspect.py index 13b7db312d..88b31cb837 100644 --- a/conda_build/cli/main_inspect.py +++ b/conda_build/cli/main_inspect.py @@ -9,10 +9,15 @@ from typing import TYPE_CHECKING from conda.base.context import context, determine_target_prefix -from conda.cli.helpers import add_parser_prefix from .. import api +try: + from conda.cli.helpers import add_parser_prefix +except ImportError: + # conda<23.11 + from conda.cli.conda_argparse import add_parser_prefix + if TYPE_CHECKING: from argparse import ArgumentParser, Namespace from typing import Sequence diff --git a/conda_build/cli/main_metapackage.py b/conda_build/cli/main_metapackage.py index 98a199d899..0e4507359e 100644 --- a/conda_build/cli/main_metapackage.py +++ b/conda_build/cli/main_metapackage.py @@ -7,10 +7,15 @@ from typing import TYPE_CHECKING from conda.base.context import context -from conda.cli.helpers import add_parser_channels from .. import api +try: + from conda.cli.helpers import add_parser_channels +except ImportError: + # conda<23.11 + from conda.cli.conda_argparse import add_parser_channels + if TYPE_CHECKING: from argparse import ArgumentParser, Namespace from typing import Sequence diff --git a/conda_build/cli/main_render.py b/conda_build/cli/main_render.py index c3ac8ace5b..3e0bf845f5 100644 --- a/conda_build/cli/main_render.py +++ b/conda_build/cli/main_render.py @@ -9,7 +9,6 @@ import yaml from conda.base.context import context -from conda.cli.helpers import add_parser_channels from yaml.parser import ParserError from .. import __version__, api @@ -17,6 +16,12 @@ from ..utils import LoggingContext from ..variants import get_package_variants, set_language_env_vars +try: + from conda.cli.helpers import add_parser_channels +except ImportError: + # conda<23.11 + from conda.cli.conda_argparse import add_parser_channels + if TYPE_CHECKING: from argparse import ArgumentParser, Namespace from typing import Sequence diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index 8591373bc1..c5acfbfd06 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -20,8 +20,6 @@ from conda.cli.common import specs_from_args as _specs_from_args from conda.cli.common import specs_from_url as _specs_from_url from conda.cli.conda_argparse import ArgumentParser as _ArgumentParser -from conda.cli.helpers import add_parser_channels as _add_parser_channels -from conda.cli.helpers import add_parser_prefix as _add_parser_prefix from conda.common.path import win_path_to_unix as _win_path_to_unix from conda.common.toposort import _toposort as __toposort from conda.core.package_cache_data import ( @@ -63,6 +61,14 @@ from .deprecations import deprecated from .utils import rm_rf as _rm_rf +try: + from conda.cli.helpers import add_parser_channels as _add_parser_channels + from conda.cli.helpers import add_parser_prefix as _add_parser_prefix +except ImportError: + # conda<23.11 + from conda.cli.conda_argparse import add_parser_channels as _add_parser_channels + from conda.cli.conda_argparse import add_parser_prefix as _add_parser_prefix + deprecated.constant( "24.5", "24.7",