Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions archaeology/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def demo(project_name, force, build_db):
cmd = [sys.executable, "-m", "archaeology.db.builder", "--project-root", str(project_root)]
_env = os.environ.copy()
_pkg_root = str(Path(__file__).parent.parent)
_env["PYTHONPATH"] = _pkg_root + ((":" + _env["PYTHONPATH"]) if _env.get("PYTHONPATH") else "")
_env["PYTHONPATH"] = _pkg_root + ((os.pathsep + _env["PYTHONPATH"]) if _env.get("PYTHONPATH") else "")
result = subprocess.run(cmd, check=True, timeout=300, env=_env)
if result.returncode != 0:
raise click.exceptions.Exit(result.returncode)
Expand Down Expand Up @@ -143,7 +143,7 @@ def build_db(project_name, verbose):

_env = os.environ.copy()
_pkg_root = str(Path(__file__).parent.parent)
_env["PYTHONPATH"] = _pkg_root + ((":" + _env["PYTHONPATH"]) if _env.get("PYTHONPATH") else "")
_env["PYTHONPATH"] = _pkg_root + ((os.pathsep + _env["PYTHONPATH"]) if _env.get("PYTHONPATH") else "")
result = subprocess.run(cmd, check=True, timeout=300, env=_env)
if result.returncode == 0 and os.path.exists(db_path):
click.echo(f"Database built at {db_path}")
Expand Down Expand Up @@ -658,7 +658,7 @@ def cascade(project_name, dry_run, skip_mine):
"--project-root", str(project_dir)]
_env = os.environ.copy()
_pkg_root = str(Path(__file__).parent.parent)
_env["PYTHONPATH"] = _pkg_root + ((":" + _env["PYTHONPATH"]) if _env.get("PYTHONPATH") else "")
_env["PYTHONPATH"] = _pkg_root + ((os.pathsep + _env["PYTHONPATH"]) if _env.get("PYTHONPATH") else "")
result = subprocess.run(cmd, capture_output=True, text=True, timeout=300, env=_env)
if result.returncode == 0:
click.echo(f" Database built ({db_path})")
Expand Down Expand Up @@ -993,7 +993,7 @@ def sync(projects, skip_mine, skip_signals, verbose):

_env = os.environ.copy()
_pkg_root = str(Path(__file__).parent.parent)
_env["PYTHONPATH"] = _pkg_root + ((":" + _env["PYTHONPATH"]) if _env.get("PYTHONPATH") else "")
_env["PYTHONPATH"] = _pkg_root + ((os.pathsep + _env["PYTHONPATH"]) if _env.get("PYTHONPATH") else "")
result = subprocess.run(cmd, capture_output=not verbose, check=True, timeout=300, env=_env)
if result.returncode == 0 and os.path.exists(db_path):
click.echo(f" DB built")
Expand Down
11 changes: 5 additions & 6 deletions tests/test_cli_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import pytest
from click.testing import CliRunner

import archaeology.cli as cli
from archaeology.cli import main


Expand Down Expand Up @@ -397,13 +398,11 @@ def fake_run(cmd, **kwargs):
assert db_builder_calls, "db.builder was never invoked"
env = db_builder_calls[0]["env"]
assert "PYTHONPATH" in env
# PYTHONPATH is set to the package root (Path(__file__).parent.parent)
# which varies by checkout name — verify it's an absolute path containing
# the archaeology package directory, not a hardcoded repo name.
# PYTHONPATH is set to the package root (Path(__file__).parent.parent).
# Verify that exact path without relying on checkout-specific repo names.
pp = env["PYTHONPATH"]
assert os.path.isabs(pp.split(os.pathsep)[0]), (
f"PYTHONPATH should start with an absolute path, got: {pp}"
)
expected_pkg_root = str(Path(cli.__file__).parent.parent)
assert pp.split(os.pathsep)[0] == expected_pkg_root
Comment thread
coderabbitai[bot] marked this conversation as resolved.


# ── analyze (unknown vector) ──────────────────────────────────────────────────
Expand Down
Loading