Skip to content

Fix editable installs for project GUI scripts - #10973

Merged
radoering merged 3 commits into
python-poetry:mainfrom
ychampion:fix-editable-gui-scripts
Aug 1, 2026
Merged

radoering merged 3 commits into
python-poetry:mainfrom
ychampion:fix-editable-gui-scripts

Conversation

@ychampion

Copy link
Copy Markdown
Contributor

Resolves: #10481

Summary

  • Install gui_scripts entry points during editable installs, alongside console_scripts.
  • Add a regression for [project.gui-scripts], including the Windows .cmd wrapper path.

Validation

  • . .venv/bin/activate && pytest tests/masonry/builders/test_editable_builder.py -q — passed

  • . .venv/bin/activate && ruff format --check src/poetry/masonry/builders/editable.py tests/masonry/builders/test_editable_builder.py — passed

  • . .venv/bin/activate && ruff check src/poetry/masonry/builders/editable.py tests/masonry/builders/test_editable_builder.py — passed

  • . .venv/bin/activate && mypy src/poetry/masonry/builders/editable.py tests/masonry/builders/test_editable_builder.py — passed

  • git diff --check — passed

  • Added tests for changed code.

  • Updated documentation for changed code. Existing docs already say to run poetry install after adding GUI scripts.

Copilot AI review requested due to automatic review settings July 8, 2026 20:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="tests/masonry/builders/test_editable_builder.py" line_range="268-277" />
<code_context>
+def test_builder_installs_project_gui_scripts(
</code_context>
<issue_to_address>
**suggestion (testing):** Add a complementary test for non-Windows behavior of `project.gui-scripts`.

This test only covers the Windows branch by forcing `WINDOWS = True` and checking the `.cmd` wrapper. Please also cover the non-Windows branch (e.g., via a second test or parametrization with `WINDOWS = False`) and assert that the `foo-gui` script is created and recorded in `RECORD`, and that no `.cmd` file is created. That way both platform branches of `_add_scripts` for `gui_scripts` are exercised.

Suggested implementation:

```python
@pytest.mark.parametrize("windows", (True, False))
def test_builder_installs_project_gui_scripts(
    tmp_path: Path, fixture_dir: FixtureDirGetter, mocker: MockerFixture, windows: bool
) -> None:

```

To fully implement the requested behavior, you should also:

1. Ensure `pytest` is imported at the top of the file if it is not already:
   - Add `import pytest` alongside the other imports.

2. Inside `test_builder_installs_project_gui_scripts`, after constructing `poetry` and before running the builder, patch the `WINDOWS` flag used by the editable builder:
   - Example:
     ```python
     mocker.patch("poetry.masonry.builders.editable.WINDOWS", windows)
     ```
   - If the module path differs, patch the correct module where `WINDOWS` is defined.

3. After running the builder (whatever code currently triggers script installation), add assertions that depend on `windows`:
   - For both branches:
     - Assert that the `foo-gui` script is recorded in `RECORD` (likely by inspecting the wheel or record file the test is already checking).
   - For `windows is True`:
     - Assert that a `foo-gui.cmd` file exists in the venv’s `bin`/`Scripts` directory.
   - For `windows is False`:
     - Assert that a `foo-gui` script exists (no `.cmd` suffix).
     - Assert that no `foo-gui.cmd` file is created.

4. Reuse whatever helpers/fixtures the existing test uses to locate the `bin` directory and `RECORD` file, following the established conventions in this file (e.g., `tmp_venv._bin_dir`, existing assertions from the script test just above).
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Comment thread tests/masonry/builders/test_editable_builder.py
Comment thread src/poetry/masonry/builders/editable.py Outdated
Constraint: Preserve the existing console-script wrapper behavior on Windows

Confidence: high

Scope-risk: narrow

Tested: editable builder tests; Ruff format/check; mypy

Not-tested: Native Windows process launch
@radoering
radoering force-pushed the fix-editable-gui-scripts branch from 7d19e64 to cd2abd6 Compare August 1, 2026 05:34

@radoering radoering left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution and @Sanjays2402 thanks for the review. I would have probably miss this one.

@radoering
radoering merged commit 3a95c37 into python-poetry:main Aug 1, 2026
52 checks passed
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Sep 1, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

4 participants