Skip to content

Commit 593c7d3

Browse files
zsimicZoran Simic
andauthored
Corrected parent python determination for package subcommand (#51)
Co-authored-by: Zoran Simic <zsimic@netflix.com>
1 parent 016a965 commit 593c7d3

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["setuptools", "wheel"]
2+
requires = ["setuptools"]
33
build-backend = "setuptools.build_meta"
44

55
[tool.ruff]

src/pickley/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ def __init__(self, given_package_spec: str, authoritative=False, settings=None):
385385
self.auto_upgrade_spec = given_package_spec
386386
runez.log.trace(f"Authoritative auto-upgrade spec '{self.auto_upgrade_spec}'")
387387

388-
else:
388+
elif self._canonical_name:
389389
# Non-authoritative specs are necessarily canonical names (since only authoritative specs can refer to git urls, etc.)
390390
manifest = self.manifest
391391
if manifest and manifest.settings and manifest.settings.auto_upgrade_spec:
@@ -398,6 +398,10 @@ def __init__(self, given_package_spec: str, authoritative=False, settings=None):
398398
runez.log.trace(f"Assuming auto-upgrade spec '{self._canonical_name}'")
399399
self.auto_upgrade_spec = self._canonical_name
400400

401+
else:
402+
# Should not be reachable, unless we are given a non-authoritative spec that is not a canonical name
403+
self.auto_upgrade_spec = given_package_spec
404+
401405
cache_file_name = self.auto_upgrade_spec
402406
if PypiStd.std_package_name(cache_file_name) != cache_file_name:
403407
# If package spec is not a canonical name, use md5 hash of it as filename
@@ -501,7 +505,7 @@ def target_installation_folder(self):
501505
def upgrade_reason(self):
502506
"""Reason this package spec needs an upgrade (if any)"""
503507
if self.currently_installed_version != self.target_version:
504-
return "new version available"
508+
return f"new version available, current version is {self.currently_installed_version}"
505509

506510
manifest = self.manifest
507511
if not manifest:

src/pickley/package.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import logging
12
import os
23
from pathlib import Path
34
from typing import List, TYPE_CHECKING
@@ -11,6 +12,8 @@
1112
if TYPE_CHECKING:
1213
from pickley.cli import Requirements
1314

15+
LOG = logging.getLogger(__name__)
16+
1417

1518
class PythonVenv:
1619
"""Python virtual environment as seen by pickley, typically in <base>/.pk/<package>-<version>/"""
@@ -138,13 +141,19 @@ def find_symbolic_invoker() -> str:
138141
"""Symbolic major/minor symlink to invoker, when applicable"""
139142
invoker = runez.SYS_INFO.invoker_python
140143
folder = invoker.real_exe.parent.parent
144+
LOG.info("Invoker python: %s", invoker)
141145
v = Version.extracted_from_text(folder.name)
142146
found = invoker.executable
143147
if v and v.given_components_count == 3:
144148
# For setups that provide a <folder>/pythonM.m -> <folder>/pythonM.m.p symlink, prefer the major/minor variant
145-
candidates = [folder.parent / folder.name.replace(v.text, v.mm), folder.parent / f"python{v.mm}"]
149+
candidates = []
150+
for candidate in (folder.name.replace(v.text, v.mm), f"python{v.mm}"):
151+
candidates.append(folder.parent / candidate)
152+
candidates.append(folder.parent / candidate / "bin" / f"python{v.mm}")
153+
146154
for path in candidates:
147155
if runez.is_executable(path):
156+
LOG.info("Found symbolic invoker: %s", path)
148157
found = path
149158
break
150159

0 commit comments

Comments
 (0)