From f4db0dc20f83915fdaf43a682a75ad6f3f81a193 Mon Sep 17 00:00:00 2001 From: Bianca Henderson Date: Fri, 8 Mar 2024 14:01:00 -0500 Subject: [PATCH 01/20] Deprecate CONDA_VERSION and binstar_upload constants --- conda_build/cli/main_build.py | 7 ++++--- conda_build/cli/main_metapackage.py | 8 +++++--- conda_build/conda_interface.py | 19 +++++++++++++++++-- conda_build/config.py | 5 +++-- 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/conda_build/cli/main_build.py b/conda_build/cli/main_build.py index de698df22c..bdcaaa25d6 100644 --- a/conda_build/cli/main_build.py +++ b/conda_build/cli/main_build.py @@ -13,10 +13,11 @@ from typing import TYPE_CHECKING from conda.auxlib.ish import dals +from conda.base.context import context from conda.common.io import dashlist from .. import api, build, source, utils -from ..conda_interface import add_parser_channels, binstar_upload, cc_conda_build +from ..conda_interface import add_parser_channels, cc_conda_build from ..config import ( get_channel_urls, get_or_merge_config, @@ -55,14 +56,14 @@ def parse_args(args: Sequence[str] | None) -> tuple[ArgumentParser, Namespace]: action="store_false", help="Do not ask to upload the package to anaconda.org.", dest="anaconda_upload", - default=binstar_upload, + default=context.binstar_upload, ) parser.add_argument( "--no-binstar-upload", action="store_false", help=argparse.SUPPRESS, dest="anaconda_upload", - default=binstar_upload, + default=context.binstar_upload, ) parser.add_argument( "--no-include-recipe", diff --git a/conda_build/cli/main_metapackage.py b/conda_build/cli/main_metapackage.py index b295b4130e..a11c581702 100644 --- a/conda_build/cli/main_metapackage.py +++ b/conda_build/cli/main_metapackage.py @@ -6,8 +6,10 @@ import logging from typing import TYPE_CHECKING +from conda.base.context import context + from .. import api -from ..conda_interface import ArgumentParser, add_parser_channels, binstar_upload +from ..conda_interface import ArgumentParser, add_parser_channels if TYPE_CHECKING: from argparse import Namespace @@ -35,14 +37,14 @@ def parse_args(args: Sequence[str] | None) -> tuple[ArgumentParser, Namespace]: action="store_false", help="Do not ask to upload the package to anaconda.org.", dest="anaconda_upload", - default=binstar_upload, + default=context.binstar_upload, ) parser.add_argument( "--no-binstar-upload", action="store_false", help=argparse.SUPPRESS, dest="anaconda_upload", - default=binstar_upload, + default=context.binstar_upload, ) parser.add_argument("--token", help="Token to pass through to anaconda upload") parser.add_argument( diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index f309b338a0..a243015ab8 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -7,7 +7,7 @@ from functools import partial from importlib import import_module # noqa: F401 -from conda import __version__ as CONDA_VERSION # noqa: F401 +from conda import __version__ from conda.auxlib.packaging import ( # noqa: F401 _get_version_from_git_tag as get_version_from_git_tag, ) @@ -67,7 +67,13 @@ from .deprecations import deprecated # TODO: Go to references of all properties below and import them from `context` instead -binstar_upload = context.binstar_upload +deprecated.constant( + "24.3", + "24.5", + "binstar_upload", + context.binstar_upload, + addendum="Use `conda.base.context.context.binstar_upload` instead.", +) default_python = context.default_python envs_dirs = context.envs_dirs pkgs_dirs = list(context.pkgs_dirs) @@ -117,3 +123,12 @@ def handle_proxy_407(x, y): ) def md5_file(path: str | os.PathLike) -> str: return compute_sum(path, "md5") + + +deprecated.constant( + "24.3", + "24.5", + "CONDA_VERSION", + __version__, + addendum="Use `conda.__version__` instead.", +) diff --git a/conda_build/config.py b/conda_build/config.py index 5d4ba590d3..0b7b6c50eb 100644 --- a/conda_build/config.py +++ b/conda_build/config.py @@ -15,8 +15,9 @@ from os.path import abspath, expanduser, expandvars, join from typing import TYPE_CHECKING +from conda.base.context import context + from .conda_interface import ( - binstar_upload, cc_conda_build, cc_platform, root_dir, @@ -87,7 +88,7 @@ def set_invocation_time(): def _get_default_settings(): return [ Setting("activate", True), - Setting("anaconda_upload", binstar_upload), + Setting("anaconda_upload", context.binstar_upload), Setting("force_upload", True), Setting("channel_urls", []), Setting("dirty", False), From c90eb18ef123b237586fa4f8965be0678cf87f83 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 8 Mar 2024 21:42:20 +0000 Subject: [PATCH 02/20] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- conda_build/conda_interface.py | 1 - 1 file changed, 1 deletion(-) diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index 9f4abc98f4..d2c20c7dc6 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -8,7 +8,6 @@ from importlib import import_module # noqa: F401 from conda import __version__ - from conda.base.context import context, determine_target_prefix, reset_context from conda.base.context import non_x86_machines as non_x86_linux_machines # noqa: F401 from conda.core.package_cache import ProgressiveFetchExtract # noqa: F401 From 606c9565a4cdfe982b3a05b69259fe6f48913d67 Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Tue, 12 Mar 2024 09:20:39 -0500 Subject: [PATCH 03/20] Bump deprecation versions --- conda_build/conda_interface.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index 0e221c1a53..870246ce6c 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -67,8 +67,8 @@ deprecated.constant("24.1.0", "24.5.0", "get_index", _get_index) # TODO: Go to references of all properties below and import them from `context` instead deprecated.constant( - "24.3", "24.5", + "24.7", "binstar_upload", context.binstar_upload, addendum="Use `conda.base.context.context.binstar_upload` instead.", @@ -125,8 +125,8 @@ def md5_file(path: str | os.PathLike) -> str: deprecated.constant( - "24.3", "24.5", + "24.7", "CONDA_VERSION", __version__, addendum="Use `conda.__version__` instead.", From e21eb63f6b54116181d1d17b95e40e10d69496f6 Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Tue, 12 Mar 2024 09:23:53 -0500 Subject: [PATCH 04/20] Deprecating default_python --- conda_build/conda_interface.py | 8 +++++++- conda_build/skeletons/pypi.py | 7 ++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index 870246ce6c..1c0bcf0214 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -73,7 +73,13 @@ context.binstar_upload, addendum="Use `conda.base.context.context.binstar_upload` instead.", ) -default_python = context.default_python +deprecated.constant( + "24.5", + "24.7", + "default_python", + context.default_python, + addendum="Use `conda.base.context.context.default_python` instead.", +) envs_dirs = context.envs_dirs pkgs_dirs = list(context.pkgs_dirs) cc_platform = context.platform diff --git a/conda_build/skeletons/pypi.py b/conda_build/skeletons/pypi.py index 92e2ff9efd..a16b0a84f9 100644 --- a/conda_build/skeletons/pypi.py +++ b/conda_build/skeletons/pypi.py @@ -19,13 +19,13 @@ import pkginfo import requests import yaml +from conda.base.context import context from conda.gateways.disk.read import compute_sum from requests.packages.urllib3.util.url import parse_url from ..conda_interface import ( StringIO, configparser, - default_python, download, human_bytes, input, @@ -281,7 +281,8 @@ def skeletonize( if not config: config = Config() - python_version = python_version or config.variant.get("python", default_python) + if not python_version: + python_version = config.variant.get("python", context.default_python) created_recipes = [] while packages: @@ -556,7 +557,7 @@ def add_parser(repos): pypi.add_argument( "--python-version", action="store", - default=default_python, + default=context.default_python, help="""Version of Python to use to run setup.py. Default is %(default)s.""", choices=["2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12"], ) From 5d27d382eab6748eb08033567bface89d81e0c99 Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Tue, 12 Mar 2024 09:25:36 -0500 Subject: [PATCH 05/20] Deprecating envs_dirs --- conda_build/conda_interface.py | 8 +++++++- conda_build/metadata.py | 5 +++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index 1c0bcf0214..633b9d8148 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -80,7 +80,13 @@ context.default_python, addendum="Use `conda.base.context.context.default_python` instead.", ) -envs_dirs = context.envs_dirs +deprecated.constant( + "24.5", + "24.7", + "envs_dirs", + context.envs_dirs, + addendum="Use `conda.base.context.context.envs_dirs` instead.", +) pkgs_dirs = list(context.pkgs_dirs) cc_platform = context.platform root_dir = context.root_dir diff --git a/conda_build/metadata.py b/conda_build/metadata.py index 633b6de8fc..f1805f43a0 100644 --- a/conda_build/metadata.py +++ b/conda_build/metadata.py @@ -16,10 +16,11 @@ from typing import TYPE_CHECKING, overload from bs4 import UnicodeDammit +from conda.base.context import context from conda.gateways.disk.read import compute_sum from . import exceptions, utils, variants -from .conda_interface import MatchSpec, envs_dirs +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 @@ -781,7 +782,7 @@ def build_string_from_metadata(metadata): # but we don't presently have an API there. def _get_env_path(env_name_or_path): if not os.path.isdir(env_name_or_path): - for envs_dir in list(envs_dirs) + [os.getcwd()]: + for envs_dir in list(context.envs_dirs) + [os.getcwd()]: path = os.path.join(envs_dir, env_name_or_path) if os.path.isdir(path): env_name_or_path = path From 0d5b02ce01c7b36c97ae0b9054c1977440f70a67 Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Tue, 12 Mar 2024 09:38:18 -0500 Subject: [PATCH 06/20] Deprecating pkgs_dirs --- conda_build/build.py | 3 +-- conda_build/conda_interface.py | 8 +++++++- conda_build/environ.py | 16 +++++++++------- conda_build/render.py | 7 ++++--- conda_build/utils.py | 5 +---- 5 files changed, 22 insertions(+), 17 deletions(-) diff --git a/conda_build/build.py b/conda_build/build.py index 9e62fc7293..a39e223cb4 100644 --- a/conda_build/build.py +++ b/conda_build/build.py @@ -39,7 +39,6 @@ env_path_backup_var_exists, get_conda_channel, get_rc_urls, - pkgs_dirs, prefix_placeholder, reset_context, root_dir, @@ -3388,7 +3387,7 @@ def test( and recipedir_or_package_or_metadata.endswith(CONDA_PACKAGE_EXTENSIONS) and any( os.path.dirname(recipedir_or_package_or_metadata) in pkgs_dir - for pkgs_dir in pkgs_dirs + for pkgs_dir in context.pkgs_dirs ) ) if not in_pkg_cache: diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index 633b9d8148..56a2403022 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -87,7 +87,13 @@ context.envs_dirs, addendum="Use `conda.base.context.context.envs_dirs` instead.", ) -pkgs_dirs = list(context.pkgs_dirs) +deprecated.constant( + "24.5", + "24.7", + "pkgs_dirs", + list(context.pkgs_dirs), + addendum="Use `conda.base.context.context.pkgs_dirs` instead.", +) cc_platform = context.platform root_dir = context.root_dir root_writable = context.root_writable diff --git a/conda_build/environ.py b/conda_build/environ.py index f7260ac92e..f036983d05 100644 --- a/conda_build/environ.py +++ b/conda_build/environ.py @@ -48,7 +48,6 @@ TemporaryDirectory, context, create_default_packages, - pkgs_dirs, reset_context, root_dir, ) @@ -993,7 +992,7 @@ def get_install_actions( pkg_dir = str(exc) folder = 0 while ( - os.path.dirname(pkg_dir) not in pkgs_dirs + os.path.dirname(pkg_dir) not in context.pkgs_dirs and folder < 20 ): pkg_dir = os.path.dirname(pkg_dir) @@ -1003,7 +1002,7 @@ def get_install_actions( "Removing the folder and retrying", pkg_dir, ) - if pkg_dir in pkgs_dirs and os.path.isdir(pkg_dir): + if pkg_dir in context.pkgs_dirs and os.path.isdir(pkg_dir): utils.rm_rf(pkg_dir) if retries < max_env_retry: log.warn( @@ -1194,7 +1193,10 @@ def create_env( with utils.try_acquire_locks(locks, timeout=config.timeout): pkg_dir = str(exc) folder = 0 - while os.path.dirname(pkg_dir) not in pkgs_dirs and folder < 20: + while ( + os.path.dirname(pkg_dir) not in context.pkgs_dirs + and folder < 20 + ): pkg_dir = os.path.dirname(pkg_dir) folder += 1 log.warn( @@ -1268,9 +1270,9 @@ def get_pkg_dirs_locks(dirs, config): def clean_pkg_cache(dist: str, config: Config) -> None: with utils.LoggingContext(logging.DEBUG if config.debug else logging.WARN): - locks = get_pkg_dirs_locks([config.bldpkgs_dir] + pkgs_dirs, config) + locks = get_pkg_dirs_locks((config.bldpkgs_dir, *context.pkgs_dirs), config) with utils.try_acquire_locks(locks, timeout=config.timeout): - for pkgs_dir in pkgs_dirs: + for pkgs_dir in context.pkgs_dirs: if any( os.path.exists(os.path.join(pkgs_dir, f"{dist}{ext}")) for ext in ("", *CONDA_PACKAGE_EXTENSIONS) @@ -1286,7 +1288,7 @@ def clean_pkg_cache(dist: str, config: Config) -> None: # Note that this call acquires the relevant locks, so this must be called # outside the lock context above. - remove_existing_packages(pkgs_dirs, [dist], config) + remove_existing_packages(context.pkgs_dirs, [dist], config) def remove_existing_packages(dirs, fns, config): diff --git a/conda_build/render.py b/conda_build/render.py index 9ba417bf23..7e64256dda 100644 --- a/conda_build/render.py +++ b/conda_build/render.py @@ -25,6 +25,7 @@ from pathlib import Path import yaml +from conda.base.context import context from . import environ, exceptions, source, utils from .conda_interface import ( @@ -32,7 +33,6 @@ ProgressiveFetchExtract, TemporaryDirectory, UnsatisfiableError, - pkgs_dirs, specs_from_url, ) from .exceptions import DependencyNeedsBuildingError @@ -247,7 +247,7 @@ def _filter_run_exports(specs, ignore_list): def find_pkg_dir_or_file_in_pkgs_dirs( distribution: str, m: MetaData, files_only: bool = False ) -> str | None: - for cache in map(Path, (*pkgs_dirs, *m.config.bldpkgs_dirs)): + for cache in map(Path, (*context.pkgs_dirs, *m.config.bldpkgs_dirs)): package = cache / (distribution + CONDA_PACKAGE_EXTENSION_V1) if package.is_file(): return str(package) @@ -274,6 +274,7 @@ def find_pkg_dir_or_file_in_pkgs_dirs( archive.add(entry, arcname=entry.name) return str(package) + return None @lru_cache(maxsize=None) @@ -385,7 +386,7 @@ def execute_download_actions(m, precs, env, package_subset=None, require_files=F pfe = ProgressiveFetchExtract(link_prefs=(link_prec,)) with utils.LoggingContext(): pfe.execute() - for pkg_dir in pkgs_dirs: + for pkg_dir in context.pkgs_dirs: _loc = join(pkg_dir, prec.fn) if isfile(_loc): pkg_loc = _loc diff --git a/conda_build/utils.py b/conda_build/utils.py index 7635c45a6f..11f8c840cf 100644 --- a/conda_build/utils.py +++ b/conda_build/utils.py @@ -66,7 +66,6 @@ context, download, get_conda_channel, - pkgs_dirs, root_dir, unix_path_to_win, win_path_to_unix, @@ -754,9 +753,7 @@ def get_conda_operation_locks(locking=True, bldpkgs_dirs=None, timeout=900): bldpkgs_dirs = ensure_list(bldpkgs_dirs) # locks enabled by default if locking: - _pkgs_dirs = pkgs_dirs[:1] - locked_folders = _pkgs_dirs + list(bldpkgs_dirs) - for folder in locked_folders: + for folder in (*context.pkgs_dirs[:1], *bldpkgs_dirs): if not os.path.isdir(folder): os.makedirs(folder) lock = get_lock(folder, timeout=timeout) From aa4df8e88ba4b3b727ea37079f995deef5111c2e Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Tue, 12 Mar 2024 09:40:20 -0500 Subject: [PATCH 07/20] Deprecating cc_platform --- conda_build/conda_interface.py | 8 +++++++- conda_build/config.py | 5 ++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index 56a2403022..291710ca53 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -94,7 +94,13 @@ list(context.pkgs_dirs), addendum="Use `conda.base.context.context.pkgs_dirs` instead.", ) -cc_platform = context.platform +deprecated.constant( + "24.5", + "24.7", + "cc_platform", + context.platform, + addendum="Use `conda.base.context.context.platform` instead.", +) root_dir = context.root_dir root_writable = context.root_writable subdir = context.subdir diff --git a/conda_build/config.py b/conda_build/config.py index 0b7b6c50eb..8e97b8b29f 100644 --- a/conda_build/config.py +++ b/conda_build/config.py @@ -19,7 +19,6 @@ from .conda_interface import ( cc_conda_build, - cc_platform, root_dir, root_writable, subdir, @@ -381,8 +380,8 @@ def noarch(self): return self.host_platform == "noarch" def reset_platform(self): - if not self.platform == cc_platform: - self.platform = cc_platform + if not self.platform == context.platform: + self.platform = context.platform @property def subdir(self): From 051993aed40f56d169cf991479ce0a6472f96a12 Mon Sep 17 00:00:00 2001 From: Bianca Henderson Date: Tue, 12 Mar 2024 10:51:29 -0400 Subject: [PATCH 08/20] Deprecate root_dir --- conda_build/build.py | 5 ++--- conda_build/conda_interface.py | 8 +++++++- conda_build/config.py | 3 +-- conda_build/environ.py | 5 ++--- conda_build/os_utils/external.py | 13 +++++++------ conda_build/utils.py | 7 +++---- 6 files changed, 22 insertions(+), 19 deletions(-) diff --git a/conda_build/build.py b/conda_build/build.py index a39e223cb4..16f4012fbe 100644 --- a/conda_build/build.py +++ b/conda_build/build.py @@ -22,6 +22,7 @@ import yaml from bs4 import UnicodeDammit from conda import __version__ as conda_version +from conda.base.context import context from conda.core.prefix_data import PrefixData from . import __version__ as conda_build_version @@ -35,13 +36,11 @@ PathType, TemporaryDirectory, UnsatisfiableError, - context, env_path_backup_var_exists, get_conda_channel, get_rc_urls, prefix_placeholder, reset_context, - root_dir, url_path, ) from .config import Config @@ -1423,7 +1422,7 @@ def write_about_json(m): extra.update(m.config.extra_meta) d["root_pkgs"] = [ f"{prec.name} {prec.version} {prec.build}" - for prec in PrefixData(root_dir).iter_records() + for prec in PrefixData(context.root_dir).iter_records() ] # Include the extra section of the metadata in the about.json d["extra"] = extra diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index 291710ca53..747262f318 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -101,7 +101,13 @@ context.platform, addendum="Use `conda.base.context.context.platform` instead.", ) -root_dir = context.root_dir +deprecated.constant( + "24.5", + "24.7", + "root_dir", + context.root_dir, + addendum="Use `conda.base.context.context.root_dir` instead.", +) root_writable = context.root_writable subdir = context.subdir create_default_packages = context.create_default_packages diff --git a/conda_build/config.py b/conda_build/config.py index 8e97b8b29f..0e013ea0d7 100644 --- a/conda_build/config.py +++ b/conda_build/config.py @@ -19,7 +19,6 @@ from .conda_interface import ( cc_conda_build, - root_dir, root_writable, subdir, url_path, @@ -460,7 +459,7 @@ def croot(self) -> str: elif _bld_root_rc: self._croot = abspath(expanduser(expandvars(_bld_root_rc))) elif root_writable: - self._croot = join(root_dir, "conda-bld") + self._croot = join(context.root_dir, "conda-bld") else: self._croot = abspath(expanduser("~/conda-bld")) return self._croot diff --git a/conda_build/environ.py b/conda_build/environ.py index f036983d05..05949df87c 100644 --- a/conda_build/environ.py +++ b/conda_build/environ.py @@ -24,6 +24,7 @@ DEFAULTS_CHANNEL_NAME, UNKNOWN_CHANNEL, ) +from conda.base.context import context from conda.common.io import env_vars from conda.core.index import LAST_CHANNEL_URLS from conda.core.link import PrefixSetup, UnlinkLinkTransaction @@ -46,10 +47,8 @@ PackageRecord, ProgressiveFetchExtract, TemporaryDirectory, - context, create_default_packages, reset_context, - root_dir, ) from .deprecations import deprecated from .exceptions import BuildLockError, DependencyNeedsBuildingError @@ -424,7 +423,7 @@ def conda_build_vars(prefix, config): "HTTP_PROXY": os.getenv("HTTP_PROXY", ""), "REQUESTS_CA_BUNDLE": os.getenv("REQUESTS_CA_BUNDLE", ""), "DIRTY": "1" if config.dirty else "", - "ROOT": root_dir, + "ROOT": context.root_dir, } diff --git a/conda_build/os_utils/external.py b/conda_build/os_utils/external.py index 8b84833c00..f1d91d098b 100644 --- a/conda_build/os_utils/external.py +++ b/conda_build/os_utils/external.py @@ -5,7 +5,8 @@ from glob import glob from os.path import expanduser, isfile, join -from ..conda_interface import root_dir +from conda.base.context import context + from ..utils import on_win @@ -16,10 +17,10 @@ def find_executable(executable, prefix=None, all_matches=False): result = None if on_win: dir_paths = [ - join(root_dir, "Scripts"), - join(root_dir, "Library\\mingw-w64\\bin"), - join(root_dir, "Library\\usr\\bin"), - join(root_dir, "Library\\bin"), + join(context.root_dir, "Scripts"), + join(context.root_dir, "Library\\mingw-w64\\bin"), + join(context.root_dir, "Library\\usr\\bin"), + join(context.root_dir, "Library\\bin"), ] if prefix: dir_paths[0:0] = [ @@ -30,7 +31,7 @@ def find_executable(executable, prefix=None, all_matches=False): ] else: dir_paths = [ - join(root_dir, "bin"), + join(context.root_dir, "bin"), ] if prefix: dir_paths.insert(0, join(prefix, "bin")) diff --git a/conda_build/utils.py b/conda_build/utils.py index 11f8c840cf..5c5901a8ef 100644 --- a/conda_build/utils.py +++ b/conda_build/utils.py @@ -53,6 +53,7 @@ CONDA_PACKAGE_EXTENSIONS, KNOWN_SUBDIRS, ) +from conda.base.context import context from conda.gateways.disk.read import compute_sum from conda.models.match_spec import MatchSpec @@ -63,10 +64,8 @@ TemporaryDirectory, VersionOrder, cc_conda_build, - context, download, get_conda_channel, - root_dir, unix_path_to_win, win_path_to_unix, ) @@ -85,7 +84,7 @@ on_linux = sys.platform == "linux" codec = getpreferredencoding() or "utf-8" -root_script_dir = os.path.join(root_dir, "Scripts" if on_win else "bin") +root_script_dir = os.path.join(context.root_dir, "Scripts" if on_win else "bin") mmap_MAP_PRIVATE = 0 if on_win else mmap.MAP_PRIVATE mmap_PROT_READ = 0 if on_win else mmap.PROT_READ mmap_PROT_WRITE = 0 if on_win else mmap.PROT_WRITE @@ -709,7 +708,7 @@ def merge_tree( # at any time, but the lock within this process should all be tied to the same tracking # mechanism. _lock_folders = ( - os.path.join(root_dir, "locks"), + os.path.join(context.root_dir, "locks"), os.path.expanduser(os.path.join("~", ".conda_build_locks")), ) From 63922d0bc5c37d77f4c59055e3cd2c47449eee90 Mon Sep 17 00:00:00 2001 From: Bianca Henderson Date: Tue, 12 Mar 2024 10:53:46 -0400 Subject: [PATCH 09/20] Deprecate root_writable --- conda_build/conda_interface.py | 8 +++++++- conda_build/config.py | 3 +-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index 747262f318..f69d5f30a5 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -108,7 +108,13 @@ context.root_dir, addendum="Use `conda.base.context.context.root_dir` instead.", ) -root_writable = context.root_writable +deprecated.constant( + "24.5", + "24.7", + "root_writable", + context.root_writable, + addendum="Use `conda.base.context.context.root_writable` instead.", +) subdir = context.subdir create_default_packages = context.create_default_packages diff --git a/conda_build/config.py b/conda_build/config.py index 0e013ea0d7..ad9058f3d5 100644 --- a/conda_build/config.py +++ b/conda_build/config.py @@ -19,7 +19,6 @@ from .conda_interface import ( cc_conda_build, - root_writable, subdir, url_path, ) @@ -458,7 +457,7 @@ def croot(self) -> str: self._croot = abspath(expanduser(_bld_root_env)) elif _bld_root_rc: self._croot = abspath(expanduser(expandvars(_bld_root_rc))) - elif root_writable: + elif context.root_writable: self._croot = join(context.root_dir, "conda-bld") else: self._croot = abspath(expanduser("~/conda-bld")) From 8d1e0711bbe4cf1a268c8f320c087558ac423aa1 Mon Sep 17 00:00:00 2001 From: Bianca Henderson Date: Tue, 12 Mar 2024 11:01:46 -0400 Subject: [PATCH 10/20] Add news file --- news/5222-deprecating-conda_interface | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 news/5222-deprecating-conda_interface diff --git a/news/5222-deprecating-conda_interface b/news/5222-deprecating-conda_interface new file mode 100644 index 0000000000..1b7a31875d --- /dev/null +++ b/news/5222-deprecating-conda_interface @@ -0,0 +1,26 @@ +### Enhancements + +* + +### Bug fixes + +* + +### Deprecations + +* Deprecate `conda_build.conda_interface.CONDA_VERSION` constant. Use `conda.__version__` instead. (#5222) +* Deprecate `conda_build.conda_interface.binstar_upload` constant. Use `conda.base.context.context.binstar_upload` instead. (#5222) +* Deprectate `conda_build.conda_interface.default_python` constant. Use `conda.base.context.context.default_python` instead. (#5222) +* Deprecate `conda_build.conda_interface.envs_dirs` constant. Use `conda.base.context.context.envs_dirs` instead. (#5222) +* Deprecate `conda_build.conda_interface.pkgs_dirs` constant. Use `conda.base.context.context.pkgs_dirs` instead. (#5222) +* Deprecate `conda_build.conda_interface.cc_platform` constant. Use `conda.base.context.context.platform` instead. (#5222) +* Deprecate `conda_build.conda_interface.root_dir` constant. Use `conda.base.context.context.root_dir` instead. (#5222) +* Deprecate `conda_build.conda_interface.root_writable` constant. Use `conda.base.context.context.root_writable` instead. (#5222) + +### Docs + +* + +### Other + +* From d9fa624d154e3472e2952e18a454df705633d79c Mon Sep 17 00:00:00 2001 From: Bianca Henderson Date: Tue, 12 Mar 2024 11:11:03 -0400 Subject: [PATCH 11/20] Deprecate subdir constant --- conda_build/conda_interface.py | 8 +++++++- conda_build/config.py | 12 ++++-------- conda_build/index.py | 7 ++++--- conda_build/inspect_pkg.py | 8 ++++---- conda_build/variants.py | 5 +++-- news/5222-deprecating-conda_interface | 1 + tests/test_api_render.py | 7 ++++--- tests/test_subpackages.py | 4 ++-- 8 files changed, 29 insertions(+), 23 deletions(-) diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index f69d5f30a5..a6ea4516c7 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -115,7 +115,13 @@ context.root_writable, addendum="Use `conda.base.context.context.root_writable` instead.", ) -subdir = context.subdir +deprecated.constant( + "24.5", + "24.7", + "subdir", + context.subdir, + addendum="Use `conda.base.context.context.subdir` instead.", +) create_default_packages = context.create_default_packages get_rc_urls = lambda: list(context.channels) diff --git a/conda_build/config.py b/conda_build/config.py index ad9058f3d5..de93e365d6 100644 --- a/conda_build/config.py +++ b/conda_build/config.py @@ -17,11 +17,7 @@ from conda.base.context import context -from .conda_interface import ( - cc_conda_build, - subdir, - url_path, -) +from .conda_interface import cc_conda_build, url_path from .utils import ( get_build_folders, get_conda_operation_locks, @@ -319,7 +315,7 @@ def set_lang(variant, lang): def arch(self): """Always the native (build system) arch, except when pretending to be some other platform""" - return self._arch or subdir.rsplit("-", 1)[1] + return self._arch or context.subdir.rsplit("-", 1)[1] @arch.setter def arch(self, value): @@ -335,7 +331,7 @@ def arch(self, value): def platform(self): """Always the native (build system) OS, except when pretending to be some other platform""" - return self._platform or subdir.rsplit("-", 1)[0] + return self._platform or context.subdir.rsplit("-", 1)[0] @platform.setter def platform(self, value): @@ -715,7 +711,7 @@ def bldpkgs_dirs(self): # subdir should be the native platform, while self.subdir would be the host platform. return { join(self.croot, self.host_subdir), - join(self.croot, subdir), + join(self.croot, context.subdir), join(self.croot, "noarch"), } diff --git a/conda_build/index.py b/conda_build/index.py index cd36cc9cac..e4d07a52ff 100644 --- a/conda_build/index.py +++ b/conda_build/index.py @@ -8,11 +8,12 @@ from functools import partial from os.path import dirname +from conda.base.context import context from conda.core.index import get_index from conda_index.index import update_index as _update_index -from . import conda_interface, utils -from .conda_interface import CondaHTTPError, context, url_path +from . import utils +from .conda_interface import CondaHTTPError, url_path from .deprecations import deprecated from .utils import ( CONDA_PACKAGE_EXTENSION_V1, @@ -128,7 +129,7 @@ def get_build_index( # native content and the noarch content. if subdir == "noarch": - subdir = conda_interface.subdir + subdir = context.subdir try: # get_index() is like conda reading the index, not conda_index # creating a new index. diff --git a/conda_build/inspect_pkg.py b/conda_build/inspect_pkg.py index 7a9985fc8a..7d7c61f8f9 100644 --- a/conda_build/inspect_pkg.py +++ b/conda_build/inspect_pkg.py @@ -14,11 +14,11 @@ from typing import TYPE_CHECKING from conda.api import Solver +from conda.base.context import context from conda.core.index import get_index from conda.core.prefix_data import PrefixData from conda.models.records import PrefixRecord -from . import conda_interface from .conda_interface import ( specs_from_args, ) @@ -104,14 +104,14 @@ def check_install( Solver( prefix, channel_urls, - [subdir or conda_interface.subdir], + [subdir or context.subdir], specs_from_args(packages), ).solve_for_transaction(ignore_pinned=True).print_transaction_summary() def print_linkages( depmap: dict[ - PrefixRecord | Literal["not found" | "system" | "untracked"], + PrefixRecord | Literal["not found", "system", "untracked"], list[tuple[str, str, str]], ], show_files: bool = False, @@ -217,7 +217,7 @@ def inspect_linkages( untracked: bool = False, all_packages: bool = False, show_files: bool = False, - groupby: Literal["package" | "dependency"] = "package", + groupby: Literal["package", "dependency"] = "package", sysroot="", ): if not packages and not untracked and not all_packages: diff --git a/conda_build/variants.py b/conda_build/variants.py index 2ece5f4bd6..c5c6d41bb1 100644 --- a/conda_build/variants.py +++ b/conda_build/variants.py @@ -11,8 +11,9 @@ from itertools import product import yaml +from conda.base.context import context -from .conda_interface import cc_conda_build, subdir +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 @@ -84,7 +85,7 @@ }, } -arch_name = subdir.rsplit("-", 1)[-1] +arch_name = context.subdir.rsplit("-", 1)[-1] SUFFIX_MAP = { "PY": "python", diff --git a/news/5222-deprecating-conda_interface b/news/5222-deprecating-conda_interface index 1b7a31875d..260c02cb6d 100644 --- a/news/5222-deprecating-conda_interface +++ b/news/5222-deprecating-conda_interface @@ -16,6 +16,7 @@ * Deprecate `conda_build.conda_interface.cc_platform` constant. Use `conda.base.context.context.platform` instead. (#5222) * Deprecate `conda_build.conda_interface.root_dir` constant. Use `conda.base.context.context.root_dir` instead. (#5222) * Deprecate `conda_build.conda_interface.root_writable` constant. Use `conda.base.context.context.root_writable` instead. (#5222) +* Deprecate `conda_build.conda_interface.subdir` constant. Use `conda.base.context.context.subdir` instead. (#5222) ### Docs diff --git a/tests/test_api_render.py b/tests/test_api_render.py index 868053876b..3c9361b03c 100644 --- a/tests/test_api_render.py +++ b/tests/test_api_render.py @@ -9,10 +9,11 @@ import pytest import yaml +from conda.base.context import context from conda.common.compat import on_win from conda_build import api, render -from conda_build.conda_interface import cc_conda_build, subdir +from conda_build.conda_interface import cc_conda_build from .utils import metadata_dir, variants_dir @@ -166,7 +167,7 @@ def test_pin_depends(testing_config): def test_cross_recipe_with_only_build_section(testing_config): recipe = os.path.join(metadata_dir, "_cross_prefix_elision_compiler_used") metadata = api.render(recipe, config=testing_config, bypass_env_check=True)[0][0] - assert metadata.config.host_subdir != subdir + assert metadata.config.host_subdir != context.subdir assert metadata.config.build_prefix != metadata.config.host_prefix assert not metadata.build_is_host @@ -175,7 +176,7 @@ def test_cross_info_index_platform(testing_config): recipe = os.path.join(metadata_dir, "_cross_build_unix_windows") metadata = api.render(recipe, config=testing_config, bypass_env_check=True)[0][0] info_index = metadata.info_index() - assert metadata.config.host_subdir != subdir + assert metadata.config.host_subdir != context.subdir assert metadata.config.host_subdir == info_index["subdir"] assert metadata.config.host_platform != metadata.config.platform assert metadata.config.host_platform == info_index["platform"] diff --git a/tests/test_subpackages.py b/tests/test_subpackages.py index 3c3b011c58..4fe966c054 100644 --- a/tests/test_subpackages.py +++ b/tests/test_subpackages.py @@ -8,9 +8,9 @@ from pathlib import Path import pytest +from conda.base.context import context from conda_build import api, utils -from conda_build.conda_interface import subdir from conda_build.render import finalize_metadata from .utils import get_valid_recipes, subpackage_dir @@ -145,7 +145,7 @@ def test_output_specific_subdir(testing_config): assert len(metadata) == 3 for m, _, _ in metadata: if m.name() in ("default_subdir", "default_subdir_2"): - assert m.config.target_subdir == subdir + assert m.config.target_subdir == context.subdir elif m.name() == "custom_subdir": assert m.config.target_subdir == "linux-aarch64" else: From 4e9180d1cd50b4078e77db990a5ea23b6ee9955c Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Tue, 12 Mar 2024 10:15:42 -0500 Subject: [PATCH 12/20] Deprecate create_default_packages --- conda_build/conda_interface.py | 9 +++++++-- conda_build/environ.py | 3 +-- news/5222-deprecating-conda_interface | 3 ++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index a6ea4516c7..02609d3d34 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -65,7 +65,6 @@ from .deprecations import deprecated deprecated.constant("24.1.0", "24.5.0", "get_index", _get_index) -# TODO: Go to references of all properties below and import them from `context` instead deprecated.constant( "24.5", "24.7", @@ -122,7 +121,13 @@ context.subdir, addendum="Use `conda.base.context.context.subdir` instead.", ) -create_default_packages = context.create_default_packages +deprecated.constant( + "24.5", + "24.7", + "create_default_packages", + context.create_default_packages, + addendum="Use `conda.base.context.context.create_default_packages` instead.", +) get_rc_urls = lambda: list(context.channels) get_prefix = partial(determine_target_prefix, context) diff --git a/conda_build/environ.py b/conda_build/environ.py index 05949df87c..661f4700f7 100644 --- a/conda_build/environ.py +++ b/conda_build/environ.py @@ -47,7 +47,6 @@ PackageRecord, ProgressiveFetchExtract, TemporaryDirectory, - create_default_packages, reset_context, ) from .deprecations import deprecated @@ -919,7 +918,7 @@ def get_install_actions( conda_log_level = logging.WARN specs = list(specs) if specs: - specs.extend(create_default_packages) + specs.extend(context.create_default_packages) if verbose or debug: capture = contextlib.nullcontext if debug: diff --git a/news/5222-deprecating-conda_interface b/news/5222-deprecating-conda_interface index 260c02cb6d..3f0832f36e 100644 --- a/news/5222-deprecating-conda_interface +++ b/news/5222-deprecating-conda_interface @@ -10,13 +10,14 @@ * Deprecate `conda_build.conda_interface.CONDA_VERSION` constant. Use `conda.__version__` instead. (#5222) * Deprecate `conda_build.conda_interface.binstar_upload` constant. Use `conda.base.context.context.binstar_upload` instead. (#5222) -* Deprectate `conda_build.conda_interface.default_python` constant. Use `conda.base.context.context.default_python` instead. (#5222) +* Deprecate `conda_build.conda_interface.default_python` constant. Use `conda.base.context.context.default_python` instead. (#5222) * Deprecate `conda_build.conda_interface.envs_dirs` constant. Use `conda.base.context.context.envs_dirs` instead. (#5222) * Deprecate `conda_build.conda_interface.pkgs_dirs` constant. Use `conda.base.context.context.pkgs_dirs` instead. (#5222) * Deprecate `conda_build.conda_interface.cc_platform` constant. Use `conda.base.context.context.platform` instead. (#5222) * Deprecate `conda_build.conda_interface.root_dir` constant. Use `conda.base.context.context.root_dir` instead. (#5222) * Deprecate `conda_build.conda_interface.root_writable` constant. Use `conda.base.context.context.root_writable` instead. (#5222) * Deprecate `conda_build.conda_interface.subdir` constant. Use `conda.base.context.context.subdir` instead. (#5222) +* Deprecate `conda_build.conda_interface.create_default_packages` constant. Use `conda.base.context.context.create_default_packages` instead. (#5222) ### Docs From 72df1cb1f02805151119e99802a39db0d6084cd3 Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Tue, 12 Mar 2024 10:20:44 -0500 Subject: [PATCH 13/20] Deprecate get_rc_urls --- conda_build/build.py | 9 +++++---- conda_build/conda_interface.py | 8 +++++++- news/5222-deprecating-conda_interface | 1 + 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/conda_build/build.py b/conda_build/build.py index 16f4012fbe..46a6d879af 100644 --- a/conda_build/build.py +++ b/conda_build/build.py @@ -38,7 +38,6 @@ UnsatisfiableError, env_path_backup_var_exists, get_conda_channel, - get_rc_urls, prefix_placeholder, reset_context, url_path, @@ -1404,7 +1403,7 @@ def write_about_json(m): # conda env will be in most, but not necessarily all installations. # Don't die if we don't see it. stripped_channels = [] - for channel in get_rc_urls() + list(m.config.channel_urls): + for channel in (*context.channels, *m.config.channel_urls): stripped_channels.append(sanitize_channel(channel)) d["channels"] = stripped_channels evars = ["CIO_TEST"] @@ -4158,8 +4157,10 @@ def is_package_built(metadata, env, include_local=True): _delegated_update_index(d, verbose=metadata.config.debug, warn=False, threads=1) subdir = getattr(metadata.config, f"{env}_subdir") - urls = [url_path(metadata.config.output_folder), "local"] if include_local else [] - urls += get_rc_urls() + urls = [ + *([url_path(metadata.config.output_folder), "local"] if include_local else []), + *context.channels, + ] if metadata.config.channel_urls: urls.extend(metadata.config.channel_urls) diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index 02609d3d34..ca11268a97 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -129,7 +129,13 @@ addendum="Use `conda.base.context.context.create_default_packages` instead.", ) -get_rc_urls = lambda: list(context.channels) +deprecated.constant( + "24.5", + "24.7", + "get_rc_urls", + lambda: list(context.channels), + addendum="Use `conda.base.context.context.channels` instead.", +) get_prefix = partial(determine_target_prefix, context) cc_conda_build = context.conda_build if hasattr(context, "conda_build") else {} diff --git a/news/5222-deprecating-conda_interface b/news/5222-deprecating-conda_interface index 3f0832f36e..6153b1c3e8 100644 --- a/news/5222-deprecating-conda_interface +++ b/news/5222-deprecating-conda_interface @@ -18,6 +18,7 @@ * Deprecate `conda_build.conda_interface.root_writable` constant. Use `conda.base.context.context.root_writable` instead. (#5222) * Deprecate `conda_build.conda_interface.subdir` constant. Use `conda.base.context.context.subdir` instead. (#5222) * Deprecate `conda_build.conda_interface.create_default_packages` constant. Use `conda.base.context.context.create_default_packages` instead. (#5222) +* Deprecate `conda_build.conda_interface.get_rc_urls` function. Use `conda.base.context.context.channels` instead. (#5222) ### Docs From c2aa957dfbac8f147b03318ae4bad2455592e003 Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Tue, 12 Mar 2024 10:24:57 -0500 Subject: [PATCH 14/20] Deprecate get_prefix --- conda_build/conda_interface.py | 8 +++++++- news/5222-deprecating-conda_interface | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index ca11268a97..d489966c07 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -136,7 +136,13 @@ lambda: list(context.channels), addendum="Use `conda.base.context.context.channels` instead.", ) -get_prefix = partial(determine_target_prefix, context) +deprecated.constant( + "24.5", + "24.7", + "get_prefix", + 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 {} get_conda_channel = Channel.from_value diff --git a/news/5222-deprecating-conda_interface b/news/5222-deprecating-conda_interface index 6153b1c3e8..f8a6f1e030 100644 --- a/news/5222-deprecating-conda_interface +++ b/news/5222-deprecating-conda_interface @@ -19,6 +19,7 @@ * Deprecate `conda_build.conda_interface.subdir` constant. Use `conda.base.context.context.subdir` instead. (#5222) * Deprecate `conda_build.conda_interface.create_default_packages` constant. Use `conda.base.context.context.create_default_packages` instead. (#5222) * Deprecate `conda_build.conda_interface.get_rc_urls` function. Use `conda.base.context.context.channels` instead. (#5222) +* Deprecate `conda_build.conda_interface.get_prefix` function. Use `conda.base.context.context.target_prefix` instead. (#5222) ### Docs From f8c9b1e297565e3304d7092e7f29eeac743e3f11 Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Tue, 12 Mar 2024 10:30:43 -0500 Subject: [PATCH 15/20] Deprecate get_conda_channel --- conda_build/build.py | 4 ++-- conda_build/conda_interface.py | 8 +++++++- conda_build/utils.py | 4 ++-- news/5222-deprecating-conda_interface | 1 + 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/conda_build/build.py b/conda_build/build.py index 46a6d879af..209d9181c1 100644 --- a/conda_build/build.py +++ b/conda_build/build.py @@ -24,6 +24,7 @@ from conda import __version__ as conda_version from conda.base.context import context from conda.core.prefix_data import PrefixData +from conda.models.channel import Channel from . import __version__ as conda_build_version from . import environ, noarch_python, source, tarcheck, utils @@ -37,7 +38,6 @@ TemporaryDirectory, UnsatisfiableError, env_path_backup_var_exists, - get_conda_channel, prefix_placeholder, reset_context, url_path, @@ -1331,7 +1331,7 @@ def record_prefix_files(m, files_with_prefix): def sanitize_channel(channel): - return get_conda_channel(channel).urls(with_credentials=False, subdirs=[""])[0] + return Channel.from_value(channel).urls(with_credentials=False, subdirs=[""])[0] def write_info_files_file(m, files): diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index d489966c07..d775238854 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -145,7 +145,13 @@ ) cc_conda_build = context.conda_build if hasattr(context, "conda_build") else {} -get_conda_channel = Channel.from_value +deprecated.constant( + "24.5", + "24.7", + "get_conda_channel", + Channel.from_value, + addendum="Use `conda.models.channel.Channel.from_value` instead.", +) # Disallow softlinks. This avoids a lot of dumb issues, at the potential cost of disk space. os.environ["CONDA_ALLOW_SOFTLINKS"] = "false" diff --git a/conda_build/utils.py b/conda_build/utils.py index 5c5901a8ef..2381d149b4 100644 --- a/conda_build/utils.py +++ b/conda_build/utils.py @@ -55,6 +55,7 @@ ) from conda.base.context import context from conda.gateways.disk.read import compute_sum +from conda.models.channel import Channel from conda.models.match_spec import MatchSpec from .conda_interface import ( @@ -65,7 +66,6 @@ VersionOrder, cc_conda_build, download, - get_conda_channel, unix_path_to_win, win_path_to_unix, ) @@ -2106,7 +2106,7 @@ def write_bat_activation_text(file_handle, m): def download_channeldata(channel_url): global channeldata_cache if channel_url.startswith("file://") or channel_url not in channeldata_cache: - urls = get_conda_channel(channel_url).urls() + urls = Channel.from_value(channel_url).urls() urls = {url.rsplit("/", 1)[0] for url in urls} data = {} for url in urls: diff --git a/news/5222-deprecating-conda_interface b/news/5222-deprecating-conda_interface index f8a6f1e030..451fcf06d4 100644 --- a/news/5222-deprecating-conda_interface +++ b/news/5222-deprecating-conda_interface @@ -20,6 +20,7 @@ * Deprecate `conda_build.conda_interface.create_default_packages` constant. Use `conda.base.context.context.create_default_packages` instead. (#5222) * Deprecate `conda_build.conda_interface.get_rc_urls` function. Use `conda.base.context.context.channels` instead. (#5222) * Deprecate `conda_build.conda_interface.get_prefix` function. Use `conda.base.context.context.target_prefix` instead. (#5222) +* Deprecate `conda_build.conda_interface.get_conda_channel` function. Use `conda.models.channel.Channel.from_value` instead. (#5222) ### Docs From efd79ac1eed2befacadee6cd824befba2e9a1fa4 Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Tue, 12 Mar 2024 10:39:15 -0500 Subject: [PATCH 16/20] Move CONDA_ALLOW_SOFTLINKS --- conda_build/__init__.py | 8 ++++++++ conda_build/conda_interface.py | 6 +----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/conda_build/__init__.py b/conda_build/__init__.py index 91367d0d86..d5f1ff38d9 100644 --- a/conda_build/__init__.py +++ b/conda_build/__init__.py @@ -1,5 +1,9 @@ # Copyright (C) 2014 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause +import os + +from conda.base.context import reset_context + from .__version__ import __version__ __all__ = ["__version__"] @@ -15,3 +19,7 @@ "render", "skeleton", ] + +# Disallow softlinks. This avoids a lot of dumb issues, at the potential cost of disk space. +os.environ["CONDA_ALLOW_SOFTLINKS"] = "false" +reset_context() diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index d775238854..4b6130ead3 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -8,7 +8,7 @@ from importlib import import_module # noqa: F401 from conda import __version__ -from conda.base.context import context, determine_target_prefix, reset_context +from conda.base.context import context, determine_target_prefix from conda.base.context import non_x86_machines as non_x86_linux_machines # noqa: F401 from conda.core.package_cache import ProgressiveFetchExtract # noqa: F401 from conda.exceptions import ( # noqa: F401 @@ -153,10 +153,6 @@ addendum="Use `conda.models.channel.Channel.from_value` instead.", ) -# Disallow softlinks. This avoids a lot of dumb issues, at the potential cost of disk space. -os.environ["CONDA_ALLOW_SOFTLINKS"] = "false" -reset_context() - # 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.environ.get("CONDA_PATH_BACKUP", None) From 2faec8834049743285fb8156f42fefb107ffd23f Mon Sep 17 00:00:00 2001 From: Bianca Henderson Date: Tue, 12 Mar 2024 12:35:39 -0400 Subject: [PATCH 17/20] Update reset_context() imports --- conda_build/build.py | 3 +-- conda_build/environ.py | 3 +-- tests/test_api_build.py | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/conda_build/build.py b/conda_build/build.py index 209d9181c1..41e8b880b0 100644 --- a/conda_build/build.py +++ b/conda_build/build.py @@ -22,7 +22,7 @@ import yaml from bs4 import UnicodeDammit from conda import __version__ as conda_version -from conda.base.context import context +from conda.base.context import context, reset_context from conda.core.prefix_data import PrefixData from conda.models.channel import Channel @@ -39,7 +39,6 @@ UnsatisfiableError, env_path_backup_var_exists, prefix_placeholder, - reset_context, url_path, ) from .config import Config diff --git a/conda_build/environ.py b/conda_build/environ.py index 661f4700f7..a6fca61837 100644 --- a/conda_build/environ.py +++ b/conda_build/environ.py @@ -24,7 +24,7 @@ DEFAULTS_CHANNEL_NAME, UNKNOWN_CHANNEL, ) -from conda.base.context import context +from conda.base.context import context, reset_context from conda.common.io import env_vars from conda.core.index import LAST_CHANNEL_URLS from conda.core.link import PrefixSetup, UnlinkLinkTransaction @@ -47,7 +47,6 @@ PackageRecord, ProgressiveFetchExtract, TemporaryDirectory, - reset_context, ) from .deprecations import deprecated from .exceptions import BuildLockError, DependencyNeedsBuildingError diff --git a/tests/test_api_build.py b/tests/test_api_build.py index 0d2bd3b5f0..c067e5f137 100644 --- a/tests/test_api_build.py +++ b/tests/test_api_build.py @@ -26,6 +26,7 @@ import yaml from binstar_client.commands import remove, show from binstar_client.errors import NotFound +from conda.base.context import reset_context from conda.common.compat import on_linux, on_mac, on_win from conda.exceptions import ClobberError, CondaMultiError from conda_index.api import update_index @@ -35,7 +36,6 @@ CondaError, LinkError, context, - reset_context, url_path, ) from conda_build.config import Config From b3c6823e593a315862a2b6926f9f04f42a65ed1f Mon Sep 17 00:00:00 2001 From: Bianca Henderson Date: Wed, 13 Mar 2024 15:03:55 -0400 Subject: [PATCH 18/20] Deprecate conda_build.conda_interface.reset_context function --- conda_build/conda_interface.py | 8 ++++++++ news/5222-deprecating-conda_interface | 1 + 2 files changed, 9 insertions(+) diff --git a/conda_build/conda_interface.py b/conda_build/conda_interface.py index 4b6130ead3..bb92f6b8b3 100644 --- a/conda_build/conda_interface.py +++ b/conda_build/conda_interface.py @@ -10,6 +10,7 @@ from conda import __version__ from conda.base.context import context, determine_target_prefix from conda.base.context import non_x86_machines as non_x86_linux_machines # noqa: F401 +from conda.base.context import reset_context as _reset_context from conda.core.package_cache import ProgressiveFetchExtract # noqa: F401 from conda.exceptions import ( # noqa: F401 CondaError, @@ -65,6 +66,13 @@ from .deprecations import deprecated deprecated.constant("24.1.0", "24.5.0", "get_index", _get_index) +deprecated.constant( + "24.5", + "24.7", + "reset_context", + _reset_context, + addendum="Use `conda.base.context.reset_context` instead.", +) deprecated.constant( "24.5", "24.7", diff --git a/news/5222-deprecating-conda_interface b/news/5222-deprecating-conda_interface index 451fcf06d4..288f24474b 100644 --- a/news/5222-deprecating-conda_interface +++ b/news/5222-deprecating-conda_interface @@ -21,6 +21,7 @@ * Deprecate `conda_build.conda_interface.get_rc_urls` function. Use `conda.base.context.context.channels` instead. (#5222) * Deprecate `conda_build.conda_interface.get_prefix` function. Use `conda.base.context.context.target_prefix` instead. (#5222) * Deprecate `conda_build.conda_interface.get_conda_channel` function. Use `conda.models.channel.Channel.from_value` instead. (#5222) +* Deprecate `conda_build.conda_interface.reset_context` function. Use `conda.base.context.reset_context` instead. (#5222) ### Docs From 60e4a34491d92e5cd2a5fa8ac5c27642815d3d90 Mon Sep 17 00:00:00 2001 From: Bianca Henderson Date: Wed, 13 Mar 2024 15:13:28 -0400 Subject: [PATCH 19/20] Wrap CONDA_ALLOW_SOFTLINKS in try-except for docs --- conda_build/__init__.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/conda_build/__init__.py b/conda_build/__init__.py index d5f1ff38d9..a8c7e5d3d5 100644 --- a/conda_build/__init__.py +++ b/conda_build/__init__.py @@ -1,8 +1,5 @@ # Copyright (C) 2014 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause -import os - -from conda.base.context import reset_context from .__version__ import __version__ @@ -20,6 +17,15 @@ "skeleton", ] -# Disallow softlinks. This avoids a lot of dumb issues, at the potential cost of disk space. -os.environ["CONDA_ALLOW_SOFTLINKS"] = "false" -reset_context() +# Skip context logic for docs since we don't install all dependencies +try: + import os + + from conda.base.context import reset_context + + # Disallow softlinks. This avoids a lot of dumb issues, at the potential cost of disk space. + os.environ["CONDA_ALLOW_SOFTLINKS"] = "false" + reset_context() + +except ImportError: + pass From c8c9bf7347c964b81cbcd7c5ca40022150b133fa Mon Sep 17 00:00:00 2001 From: Bianca Henderson Date: Thu, 14 Mar 2024 15:48:09 -0400 Subject: [PATCH 20/20] Update conda_build/__init__.py --- conda_build/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/conda_build/__init__.py b/conda_build/__init__.py index a8c7e5d3d5..6b43ca6180 100644 --- a/conda_build/__init__.py +++ b/conda_build/__init__.py @@ -17,7 +17,8 @@ "skeleton", ] -# Skip context logic for docs since we don't install all dependencies +# Skip context logic for doc generation since we don't install all dependencies in the CI doc build environment, +# see .readthedocs.yml file try: import os