Skip to content

Fix editable installs for project GUI scripts#10973

Open
ychampion wants to merge 2 commits into
python-poetry:mainfrom
ychampion:fix-editable-gui-scripts
Open

Fix editable installs for project GUI scripts#10973
ychampion wants to merge 2 commits into
python-poetry:mainfrom
ychampion:fix-editable-gui-scripts

Conversation

@ychampion

Copy link
Copy Markdown

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scripts defined in [project.gui-scripts] are not made available by poetry install

2 participants