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
2 changes: 1 addition & 1 deletion src/manage/scriptutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def _find_shebang_command(cmd, full_cmd, *, windowed=None):
return cmd.get_install_to_run(f"PythonCore/{tag}", windowed=True)
if sh_cmd.match("python*.exe"):
tag = sh_cmd.name[6:-4]
return cmd.get_install_to_run(f"PythonCore/{tag}")
return cmd.get_install_to_run(f"PythonCore/{tag}", windowed=windowed)

raise LookupError

Expand Down
8 changes: 5 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,10 @@ def __init__(self, global_dir, installs=[]):
self.shebang_can_run_anything_silently = False
self.scratch = {}

def get_installs(self, *, include_unmanaged=True, set_default=True):
return self.installs
def get_installs(self, *, include_unmanaged=False, set_default=True):
if include_unmanaged:
return self.installs
return [i for i in self.installs if not i.get("unmanaged", 0)]

def get_install_to_run(self, tag, *, windowed=False):
if windowed:
Expand All @@ -171,7 +173,7 @@ def get_install_to_run(self, tag, *, windowed=False):

company, _, tag = tag.replace("/", "\\").rpartition("\\")
return [i for i in self.installs
if i["tag"] == tag and (not company or i["company"] == company)][0]
if (not tag or i["tag"] == tag) and (not company or i["company"] == company)][0]


@pytest.fixture
Expand Down
2 changes: 1 addition & 1 deletion tests/test_install_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def get_log_file(self):
def get_installs(self):
return self.installs

def get_install_to_run(self, tag):
def get_install_to_run(self, tag=None, script=None, *, windowed=False):
for i in self.installs:
if i["tag"] == tag or f"{i['company']}/{i['tag']}" == tag:
return i
Expand Down
19 changes: 19 additions & 0 deletions tests/test_scriptutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,25 @@ def t(n):
assert t("pythonw1.0")["executable"].match("pythonw.exe")


def test_unmanaged_py_shebang(fake_config, tmp_path):
inst = _fake_install("1.0", company="PythonCore", prefix=PurePath("C:\\TestRoot"))
inst["unmanaged"] = 1
inst["run-for"] = [
dict(name="python.exe", target=".\\python.exe"),
dict(name="pythonw.exe", target=".\\pythonw.exe", windowed=1),
]
fake_config.installs[:] = [inst]

def t(n):
return _find_shebang_command(fake_config, n, windowed=False)

# Finds the install's default executable
assert t("python")["executable"].match("test-binary-1.0.exe")
assert t("python1.0")["executable"].match("test-binary-1.0.exe")
# Finds the install's run-for executable with windowed=1
assert t("pythonw")["executable"].match("pythonw.exe")
assert t("pythonw1.0")["executable"].match("pythonw.exe")


@pytest.mark.parametrize("script, expect", [
("# not a coding comment", None),
Expand Down
Loading