Skip to content

Commit 7913dc8

Browse files
committed
FIX: Resolve subprocess NameError in live package scanner
This crucial fix addresses a recurring `NameError: name 'safe_print' is not defined` error that occurred during the subprocess-based scan for live package files (`_get_file_list_for_packages_live`). The root cause was the use of the `-I` (isolated mode) flag, which is necessary for context integrity but prevents the subprocess from accessing omnipkg's utility functions. The scriptlet being executed was calling `safe_print` without a definition. The fix replaces the call to `safe_print` within the subprocess scriptlet with the standard built-in `print()`, as its only job is to dump a JSON string to stdout. This resolves the error while preserving the essential isolation provided by the `-I` flag. With this change, the fast-path for building the main environment's file hash index now works correctly, significantly speeding up the initial run of bubble creation and improving overall performance and robustness.
1 parent 64d0f0c commit 7913dc8

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

omnipkg/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4349,7 +4349,7 @@ def _get_file_list_for_packages_live(self, package_names: List[str]) -> Dict[str
43494349
if not package_names:
43504350
return {}
43514351
python_exe = self.config.get('python_executable', sys.executable)
4352-
script = f'\nimport sys, json, importlib.metadata\nresults = {{}}\nfor pkg_name in {package_names!r}:\n try:\n dist = importlib.metadata.distribution(pkg_name)\n if dist.files:\n results[pkg_name] = [str(dist.locate_file(f)) for f in dist.files if dist.locate_file(f).is_file()]\n except Exception:\n results[pkg_name] = []\nsafe_print(json.dumps(results))\n'
4352+
script = f'\nimport sys, json, importlib.metadata\nresults = {{}}\nfor pkg_name in {package_names!r}:\n try:\n dist = importlib.metadata.distribution(pkg_name)\n if dist.files:\n results[pkg_name] = [str(dist.locate_file(f)) for f in dist.files if dist.locate_file(f).is_file()]\n except Exception:\n results[pkg_name] = []\nprint(json.dumps(results))\n'
43534353
try:
43544354
cmd = [python_exe, '-I', '-c', script]
43554355
result = subprocess.run(cmd, capture_output=True, text=True, check=True, timeout=120)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "omnipkg"
7-
version = "1.4.6"
7+
version = "1.4.7"
88
authors = [
99
{ name = "1minds3t", email = "[email protected]" },
1010
]

0 commit comments

Comments
 (0)