Skip to content

Commit

Permalink
Make the paths in the command field for pyvenv.cfg use absolute, …
Browse files Browse the repository at this point in the history
…resolved paths (#22)
  • Loading branch information
brettcannon authored Mar 9, 2023
1 parent 2d70693 commit 486198d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
4 changes: 2 additions & 2 deletions microvenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ def create(venv_dir):
try:
script_path = pathlib.Path(__file__).resolve()
except NameError:
command = f"{sys.executable} -c '...'"
command = f"{EXECUTABLE} -c '...'"
else:
command = f"{sys.executable} {script_path} {venv_dir}"
command = f"{EXECUTABLE} {script_path} {venv_dir.resolve()}"
(venv_dir / "pyvenv.cfg").write_text(
pyvenvcfg_template.format(venv_dir=venv_dir, command=command), encoding="utf-8"
)
Expand Down
14 changes: 13 additions & 1 deletion test_microvenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,19 @@ def test_pyvenvcfg_executable(full_venv, micro_venv):

def test_pyvenvfg_command(micro_venv):
config = pyvenvcfg(micro_venv)
assert config["command"] == f"{sys.executable} {microvenv.__file__} {micro_venv}"
executable = pathlib.Path(sys.executable).resolve()
script_path = pathlib.Path(microvenv.__file__).resolve()
assert config["command"] == f"{executable} {script_path} {micro_venv.resolve()}"


def test_pyvencfg_command_relative(monkeypatch, tmp_path):
monkeypatch.chdir(tmp_path)
venv_path = tmp_path / "venv"
microvenv.create(pathlib.Path(venv_path.name))
executable = pathlib.Path(sys.executable).resolve()
script_path = pathlib.Path(microvenv.__file__).resolve()
config = pyvenvcfg(venv_path)
assert config["command"] == f"{executable} {script_path} {venv_path.resolve()}"


def test_code_size(monkeypatch, tmp_path):
Expand Down

0 comments on commit 486198d

Please sign in to comment.