Skip to content

Commit 35a9ec7

Browse files
authored
Add configuration setting to disable entrypoint generation. (#256)
Fixes #255
1 parent 802b8e0 commit 35a9ec7

File tree

4 files changed

+37
-0
lines changed

4 files changed

+37
-0
lines changed

src/manage/aliasutils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,9 @@ def calculate_aliases(cmd, install, *, _scan=_scan):
289289
if default_alias_w:
290290
yield default_alias_w.replace(name="pythonw", windowed=1)
291291

292+
if not cmd.enable_entrypoints:
293+
return
294+
292295
site_dirs = DEFAULT_SITE_DIRS
293296
for s in install.get("shortcuts", ()):
294297
if s.get("kind") == "site-dirs":

src/manage/commands.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ def execute(self):
257257
"disable_shortcut_kinds": (str, config_split_append),
258258
"default_install_tag": (str, None),
259259
"preserve_site_on_upgrade": (config_bool, None),
260+
"enable_entrypoints": (config_bool, None),
260261
},
261262

262263
"first_run": {
@@ -821,6 +822,7 @@ class InstallCommand(BaseCommand):
821822
disable_shortcut_kinds = None
822823
default_install_tag = None
823824
preserve_site_on_upgrade = True
825+
enable_entrypoints = True
824826

825827
def __init__(self, args, root=None):
826828
super().__init__(args, root)

tests/test_alias.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ def test_parse_entrypoint_line():
240240

241241

242242
def test_scan_entrypoints(fake_config, tmp_path):
243+
fake_config.enable_entrypoints = True
243244
root = tmp_path / "test_install"
244245
site = root / "site-packages"
245246
A = site / "A.dist-info"
@@ -268,6 +269,36 @@ def test_scan_entrypoints(fake_config, tmp_path):
268269
assert [None, None, None, "main", "main"] == [a.func for a in actual]
269270

270271

272+
def test_scan_entrypoints_disabled(fake_config, tmp_path):
273+
fake_config.enable_entrypoints = False
274+
root = tmp_path / "test_install"
275+
site = root / "site-packages"
276+
A = site / "A.dist-info"
277+
A.mkdir(parents=True, exist_ok=True)
278+
(root / "target.exe").write_bytes(b"")
279+
(A / "entry_points.txt").write_text("""[console_scripts]
280+
a = a:main
281+
282+
[gui_scripts]
283+
aw = a:main
284+
""")
285+
286+
install = dict(
287+
prefix=root,
288+
id="test",
289+
default=1,
290+
alias=[dict(name="target", target="target.exe")],
291+
shortcuts=[dict(kind="site-dirs", dirs=["site-packages"])],
292+
)
293+
294+
actual = list(AU.calculate_aliases(fake_config, install))
295+
296+
assert ["target", "python", "pythonw"] == [a.name for a in actual]
297+
assert [0, 0, 1] == [a.windowed for a in actual]
298+
assert [None, None, None] == [a.mod for a in actual]
299+
assert [None, None, None] == [a.func for a in actual]
300+
301+
271302
def test_create_aliases(fake_config, tmp_path):
272303
target = tmp_path / "target.exe"
273304
target.write_bytes(b"")

tests/test_install_command.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ class Cmd:
173173
launcher_exe = None
174174
scratch = {}
175175
enable_shortcut_kinds = disable_shortcut_kinds = None
176+
enable_entrypoints = True
176177
def get_installs(self):
177178
return [
178179
{

0 commit comments

Comments
 (0)