Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 3 additions & 1 deletion src/poetry/masonry/builders/editable.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ def _add_scripts(self) -> list[Path]:
)
return []

scripts = entry_points.get("console_scripts", [])
scripts = entry_points.get("console_scripts", []) + entry_points.get(
"gui_scripts", []
)
for script in scripts:
name, script_with_extras = script.split(" = ")
script_without_extras = script_with_extras.split("[")[0]
Expand Down
3 changes: 3 additions & 0 deletions tests/fixtures/simple_project/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ foo = "foo:bar"
baz = "bar:baz.boom.bim"
fox = "fuz.foo:bar.baz"

[project.gui-scripts]
gui-foo = "foo:gui"

[tool.poetry]
classifiers = [
"Topic :: Software Development :: Build Tools",
Expand Down
29 changes: 27 additions & 2 deletions tests/masonry/builders/test_editable_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ def test_builder_installs_proper_files_for_standard_packages(
builder.build()

assert tmp_venv._bin_dir.joinpath("foo").exists()
# GUI scripts are only available via PEP 621 [project.gui-scripts];
# the legacy [tool.poetry] schema does not support a gui-scripts table.
if project == "simple_project":
assert tmp_venv._bin_dir.joinpath("gui-foo").exists()
pth_file = Path("simple_project.pth")
assert tmp_venv.site_packages.exists(pth_file)
assert (
Expand Down Expand Up @@ -176,10 +180,14 @@ def test_builder_installs_proper_files_for_standard_packages(
)

assert dist_info.joinpath("INSTALLER").read_text(encoding="utf-8") == "poetry"
expected_entry_points = (
"[console_scripts]\nbaz=bar:baz.boom.bim\nfoo=foo:bar\nfox=fuz.foo:bar.baz\n\n"
)
if project == "simple_project":
expected_entry_points += "[gui_scripts]\ngui-foo=foo:gui\n\n"
assert (
dist_info.joinpath("entry_points.txt").read_text(encoding="utf-8")
== "[console_scripts]\nbaz=bar:baz.boom.bim\nfoo=foo:bar\n"
"fox=fuz.foo:bar.baz\n\n"
== expected_entry_points
)
metadata = f"""\
Metadata-Version: {expected_metadata_version()}
Expand Down Expand Up @@ -264,6 +272,23 @@ def test_builder_installs_proper_files_for_standard_packages(

assert tmp_venv._bin_dir.joinpath("fox").read_text(encoding="utf-8") == fox_script

if project == "simple_project":
assert str(tmp_venv._bin_dir.joinpath("gui-foo")) in record_entries

gui_foo_script = f"""\
#!{tmp_venv.python}
import sys
from foo import gui

if __name__ == '__main__':
sys.exit(gui())
"""

assert (
tmp_venv._bin_dir.joinpath("gui-foo").read_text(encoding="utf-8")
== gui_foo_script
)


def test_builder_falls_back_on_setup_and_pip_for_packages_with_build_scripts(
mocker: MockerFixture, extended_poetry: Poetry, tmp_path: Path
Expand Down
Loading