Skip to content
Open
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
3 changes: 3 additions & 0 deletions src/manage/aliasutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,9 @@ def calculate_aliases(cmd, install, *, _scan=_scan):
if default_alias_w:
yield default_alias_w.replace(name="pythonw", windowed=1)

if not cmd.enable_entrypoints:
return

site_dirs = DEFAULT_SITE_DIRS
for s in install.get("shortcuts", ()):
if s.get("kind") == "site-dirs":
Expand Down
2 changes: 2 additions & 0 deletions src/manage/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ def execute(self):
"disable_shortcut_kinds": (str, config_split_append),
"default_install_tag": (str, None),
"preserve_site_on_upgrade": (config_bool, None),
"enable_entrypoints": (config_bool, None),
},

"first_run": {
Expand Down Expand Up @@ -821,6 +822,7 @@ class InstallCommand(BaseCommand):
disable_shortcut_kinds = None
default_install_tag = None
preserve_site_on_upgrade = True
enable_entrypoints = True

def __init__(self, args, root=None):
super().__init__(args, root)
Expand Down
31 changes: 31 additions & 0 deletions tests/test_alias.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ def test_parse_entrypoint_line():


def test_scan_entrypoints(fake_config, tmp_path):
fake_config.enable_entrypoints = True
root = tmp_path / "test_install"
site = root / "site-packages"
A = site / "A.dist-info"
Expand Down Expand Up @@ -268,6 +269,36 @@ def test_scan_entrypoints(fake_config, tmp_path):
assert [None, None, None, "main", "main"] == [a.func for a in actual]


def test_scan_entrypoints_disabled(fake_config, tmp_path):
fake_config.enable_entrypoints = False
root = tmp_path / "test_install"
site = root / "site-packages"
A = site / "A.dist-info"
A.mkdir(parents=True, exist_ok=True)
(root / "target.exe").write_bytes(b"")
(A / "entry_points.txt").write_text("""[console_scripts]
a = a:main

[gui_scripts]
aw = a:main
""")

install = dict(
prefix=root,
id="test",
default=1,
alias=[dict(name="target", target="target.exe")],
shortcuts=[dict(kind="site-dirs", dirs=["site-packages"])],
)

actual = list(AU.calculate_aliases(fake_config, install))

assert ["target", "python", "pythonw"] == [a.name for a in actual]
assert [0, 0, 1] == [a.windowed for a in actual]
assert [None, None, None] == [a.mod for a in actual]
assert [None, None, None] == [a.func for a in actual]


def test_create_aliases(fake_config, tmp_path):
target = tmp_path / "target.exe"
target.write_bytes(b"")
Expand Down
1 change: 1 addition & 0 deletions tests/test_install_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ class Cmd:
launcher_exe = None
scratch = {}
enable_shortcut_kinds = disable_shortcut_kinds = None
enable_entrypoints = True
def get_installs(self):
return [
{
Expand Down