Skip to content

Commit

Permalink
Remove unnecessary prec->dist_name conversions
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Bargull <marcel.bargull@udo.edu>
  • Loading branch information
mbargull committed Jan 19, 2024
1 parent d1d195e commit e451584
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 30 deletions.
7 changes: 2 additions & 5 deletions conda_build/environ.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
from .metadata import MetaData
from .os_utils import external
from .utils import (
dist_string_from_package_record,
dist_dep_string,
ensure_list,
env_var,
on_mac,
Expand Down Expand Up @@ -1238,8 +1238,5 @@ def get_pinned_deps(m, section):
output_folder=m.config.output_folder,
channel_urls=tuple(m.config.channel_urls),
)
runtime_deps = [
" ".join(dist_string_from_package_record(prec).rsplit("-", 2))
for prec in actions.get(LINK_ACTION, [])
]
runtime_deps = [dist_dep_string(prec) for prec in actions.get(LINK_ACTION, [])]
return runtime_deps
14 changes: 7 additions & 7 deletions conda_build/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

from . import environ, exceptions, source, utils
from .conda_interface import (
PackageRecord,
ProgressiveFetchExtract,
TemporaryDirectory,
UnsatisfiableError,
Expand All @@ -41,7 +42,7 @@
from .utils import (
CONDA_PACKAGE_EXTENSION_V1,
CONDA_PACKAGE_EXTENSION_V2,
dist_string_from_package_record,
dist_dep_string,
)
from .variants import (
filter_by_key_value,
Expand Down Expand Up @@ -91,10 +92,7 @@ def bldpkg_path(m):

def actions_to_pins(actions):
if LINK_ACTION in actions:
return [
" ".join(dist_string_from_package_record(prec).split()[0].rsplit("-", 2))
for prec in actions[LINK_ACTION]
]
return [dist_dep_string(prec) for prec in actions[LINK_ACTION]]
return []


Expand Down Expand Up @@ -373,7 +371,7 @@ def execute_download_actions(m, actions, env, package_subset=None, require_files
precs = selected_packages

for prec in precs:
pkg_dist = dist_string_from_package_record(prec)
pkg_dist = "-".join((prec.name, prec.version, prec.build))
pkg_loc = find_pkg_dir_or_file_in_pkgs_dirs(
pkg_dist, m, files_only=require_files
)
Expand All @@ -383,7 +381,9 @@ def execute_download_actions(m, actions, env, package_subset=None, require_files
# proper conda API when available.
if not pkg_loc:
link_prec = [
rec for rec in index if dist_string_from_package_record(rec) == pkg_dist
rec
for rec in index
if (rec.name, rec.version, rec.build) == (prec.name, prec.version, prec.build)
][0]
pfe = ProgressiveFetchExtract(link_prefs=(link_prec,))
with utils.LoggingContext():
Expand Down
20 changes: 2 additions & 18 deletions conda_build/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2180,21 +2180,5 @@ def samefile(path1: Path, path2: Path) -> bool:
return path1 == path2


def dist_string_from_package_record(prec):
string = prec.fn

if string.endswith("@"):
raise NotImplementedError()

REGEX_STR = (
r"(?:([^\s\[\]]+)::)?" # optional channel
r"([^\s\[\]]+)" # 3.x dist
r"(?:\[([a-zA-Z0-9_-]+)\])?" # with_features_depends
)
channel, original_dist, w_f_d = re.search(REGEX_STR, string).groups()

stripped = original_dist
for ext in CONDA_PACKAGE_EXTENSIONS:
if stripped.endswith(ext):
stripped = stripped[: -len(ext)]
return stripped
def dist_dep_string(prec: PackageRecord) -> str:
return " ".join((prec.name, prec.version, prec.build)).rstrip()

0 comments on commit e451584

Please sign in to comment.