Skip to content

Commit 730c8eb

Browse files
committed
fix: Resolve NameErrors in setup and bubble isolation logic
Core Setup: Restored the missing rebuild_cmd definition in _first_time_setup. This ensures the knowledge base is correctly initialized via omnipkg.cli reset without causing recursion crashes during the first-time configuration. Bubble Isolation: Added missing site module import (aliased as site_module) within _create_bubble_from_editable_install to resolve NameError when retrieving system site-packages. Implemented lazy import for requests (aliased as http_requests) in _try_pypi_api. This fixes the NameError for requests and ensures the manager doesn't crash on systems where the requests library is not installed. Modified: • src/omnipkg/core.py (+14/-3 lines) [gitship-generated]
1 parent 5e89cf2 commit 730c8eb

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

src/omnipkg/core.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2823,6 +2823,13 @@ def _first_time_setup(self, interactive=True) -> Dict:
28232823
safe_print(_(" 💡 Future startups will be instant!"))
28242824

28252825
# Initialize knowledge base
2826+
rebuild_cmd = [
2827+
str(final_config["python_executable"]),
2828+
"-m",
2829+
"omnipkg.cli",
2830+
"reset",
2831+
"-y",
2832+
]
28262833
is_windows = platform.system() == "Windows"
28272834
creationflags = subprocess.CREATE_NO_WINDOW if is_windows else 0
28282835
win_env = {**os.environ, "PYTHONIOENCODING": "utf-8", "PYTHONUTF8": "1"}
@@ -4240,6 +4247,9 @@ def _create_bubble_from_editable_install(
42404247
source_path: str,
42414248
python_context_version: str,
42424249
) -> bool:
4250+
# --- ADD THIS LINE HERE ---
4251+
import site as site_module
4252+
42434253
"""
42444254
Creates a bubble from an editable install by copying files from the live source.
42454255
This preserves the current dev version WITH ALL DEPENDENCIES as a fallback.
@@ -4478,6 +4488,7 @@ def _try_pip_dry_run(self, package_name: str, version: str) -> Optional[List[str
44784488
pass
44794489

44804490
def _try_pypi_api(self, package_name: str, version: str) -> Optional[List[str]]:
4491+
import requests as http_requests
44814492
try:
44824493
pass
44834494
except ImportError:
@@ -4490,11 +4501,11 @@ def _try_pypi_api(self, package_name: str, version: str) -> Optional[List[str]]:
44904501
"User-Agent": "omnipkg-package-manager/1.0",
44914502
"Accept": "application/json",
44924503
}
4493-
response = requests.get(url, timeout=10, headers=headers)
4504+
response = http_requests.get(url, timeout=10, headers=headers)
44944505
if response.status_code == 404:
44954506
if clean_version != version:
44964507
url = f"https://pypi.org/pypi/{package_name}/{version}/json"
4497-
response = requests.get(url, timeout=10, headers=headers)
4508+
response = http_requests.get(url, timeout=10, headers=headers)
44984509
if response.status_code != 200:
44994510
return None
45004511
if not response.text.strip():
@@ -4521,7 +4532,7 @@ def _try_pypi_api(self, package_name: str, version: str) -> Optional[List[str]]:
45214532
version_spec = match.group(2) or ""
45224533
dependencies.append(_("{}{}").format(dep_name, version_spec))
45234534
return dependencies
4524-
except requests.exceptions.RequestException:
4535+
except http_requests.exceptions.RequestException:
45254536
return None
45264537
except Exception:
45274538
return None

0 commit comments

Comments
 (0)