Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finish conda_build.conda_interface deprecations #5276

Merged
merged 34 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
6daac58
Deprecate ArgumentParser
kenodegard Apr 10, 2024
44947f0
Deprecate add_parser_*
kenodegard Apr 10, 2024
add5e6d
Deprecate Channel
kenodegard Apr 10, 2024
23b3fe8
Deprecate EntityEncoder
kenodegard Apr 10, 2024
07098f8
Deprecate FileMode & PathType
kenodegard Apr 10, 2024
4da7609
Deprecate MatchSpec
kenodegard Apr 10, 2024
24ea84d
Deprecate PackageRecord
kenodegard Apr 10, 2024
24d21a5
Deprecate Resolve
kenodegard Apr 10, 2024
e82dfe2
Deprecate StringIO
kenodegard Apr 10, 2024
07c3a70
Deprecate TemporaryDirectory
kenodegard Apr 10, 2024
80752b6
Deprecate TmpDownload
kenodegard Apr 10, 2024
60df4dd
Deprecate download
kenodegard Apr 10, 2024
f155125
Deprecate VersionOrder
kenodegard Apr 10, 2024
29a4294
Deprecate _toposort
kenodegard Apr 10, 2024
07816b5
Deprecate human_bytes
kenodegard Apr 10, 2024
7c100a0
Deprecate input
kenodegard Apr 10, 2024
8e28526
Deprecate lchmod
kenodegard Apr 10, 2024
ce49bdc
Deprecate normalized_version
kenodegard Apr 10, 2024
3e0aefb
Deprecate prefix_placeholder
kenodegard Apr 10, 2024
ed4427f
Deprecate rm_rf
kenodegard Apr 11, 2024
43b3ee7
Deprecate spec[s]_from_*
kenodegard Apr 11, 2024
611538b
Deprecate unix_path_to_win
kenodegard Apr 11, 2024
6211c68
Deprecate untracked
kenodegard Apr 11, 2024
c944714
Deprecate url_path
kenodegard Apr 11, 2024
9fa6346
Deprecate walk_prefix
kenodegard Apr 11, 2024
d0cb53a
Deprecate win_path_to_unix
kenodegard Apr 11, 2024
ec0feeb
Deprecate unused
kenodegard Apr 11, 2024
81be10d
Deprecate cc_conda_build
kenodegard Apr 11, 2024
d90c037
Deprecate env_path_backup_var_exists
kenodegard Apr 11, 2024
7e11f11
Add news
kenodegard Apr 11, 2024
301f761
Fix
kenodegard Apr 11, 2024
cfc9682
Fallback import for conda<23.11
kenodegard Apr 11, 2024
57ed64f
Merge remote-tracking branch 'upstream/main' into finish-conda_interf…
kenodegard Apr 17, 2024
61bb12f
Merge remote-tracking branch 'upstream/main' into finish-conda_interf…
kenodegard Apr 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion conda_build/bdist_conda.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
import sys
import time
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 StringIO, spec_from_line
from .config import Config
from .deprecations import deprecated
from .metadata import MetaData
Expand Down
34 changes: 11 additions & 23 deletions conda_build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,19 @@
import yaml
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
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
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 (
EntityEncoder,
FileMode,
MatchSpec,
PathType,
TemporaryDirectory,
env_path_backup_var_exists,
prefix_placeholder,
url_path,
)
from .config import Config
from .create_test import create_all_test_files
from .deprecations import deprecated
Expand Down Expand Up @@ -195,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
Expand All @@ -206,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.
Expand Down Expand Up @@ -1149,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"("
Expand Down Expand Up @@ -2351,8 +2347,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")
Expand Down Expand Up @@ -2416,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:
Expand Down Expand Up @@ -3447,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
Expand Down Expand Up @@ -3531,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
Expand Down
71 changes: 39 additions & 32 deletions conda_build/cli/main_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from conda.common.io import dashlist

from .. import api, build, source, utils
from ..conda_interface import add_parser_channels, cc_conda_build
from ..config import (
get_channel_urls,
get_or_merge_config,
Expand All @@ -27,12 +26,16 @@
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 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()
Expand Down Expand Up @@ -70,7 +73,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",
Expand Down Expand Up @@ -125,7 +128,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",
Expand All @@ -145,7 +148,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",
Expand All @@ -155,12 +158,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",
Expand All @@ -185,7 +188,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
),
)
Expand All @@ -210,23 +213,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",
Expand All @@ -237,7 +240,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",
Expand All @@ -246,7 +249,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",
Expand All @@ -259,29 +262,30 @@ 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",
help=(
"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",
Expand Down Expand Up @@ -350,7 +354,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",
Expand All @@ -361,7 +365,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",
Expand All @@ -372,7 +376,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",
Expand All @@ -383,7 +388,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",
Expand All @@ -393,7 +399,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",
Expand All @@ -403,7 +409,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",
Expand All @@ -420,16 +426,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 "
Expand All @@ -445,7 +452,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",
Expand Down
5 changes: 3 additions & 2 deletions conda_build/cli/main_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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="""
Expand Down
Loading
Loading