Skip to content

Comments

Prefer running executables in the environment with <name> over <name>/__main__.py#11431

Merged
zanieb merged 2 commits intomainfrom
zb/run-module
Feb 12, 2025
Merged

Prefer running executables in the environment with <name> over <name>/__main__.py#11431
zanieb merged 2 commits intomainfrom
zb/run-module

Conversation

@zanieb
Copy link
Member

@zanieb zanieb commented Feb 11, 2025

Closes #11423
Closes #9167
Closes #9722

c23fc40 demonstrates the behavior.

@zanieb zanieb added the bug Something isn't working label Feb 11, 2025
@zanieb zanieb force-pushed the zb/run-module branch 2 times, most recently from 8de505b to a84bc01 Compare February 11, 2025 22:15
Comment on lines +1213 to +1215
Self::PythonPackage(target, path, args) => {
let name = PathBuf::from(target).with_extension(std::env::consts::EXE_EXTENSION);
let entrypoint = interpreter.scripts().join(name);
Copy link
Member Author

@zanieb zanieb Feb 11, 2025

Choose a reason for hiding this comment

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

#9722 implements an alternative approach using more types. I think that's nice in theory, but once I reviewed it and attempted to implemented it, it didn't feel worth the indirection cost. This issue is relatively specific — let's deal with it here for now.

@@ -1462,7 +1485,11 @@ impl RunCommand {
{
Ok(Self::PythonGuiScript(target_path, args.to_vec()))
} else if is_dir && target_path.join("__main__.py").is_file() {
Copy link
Member

Choose a reason for hiding this comment

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

What happens if an entrypoint exists, but there is no __main__.py file? Do we still run the entrypoint as expected?

Copy link
Member Author

Choose a reason for hiding this comment

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

If I follow what you're saying here, yes this is covered in the first snapshot of the test case. The only behavior that's changing here is when a __main__.py file is present.

@zanieb zanieb requested a review from charliermarsh February 12, 2025 15:59
@zanieb zanieb merged commit 3f6a7f9 into main Feb 12, 2025
73 checks passed
@zanieb zanieb deleted the zb/run-module branch February 12, 2025 18:08
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Feb 13, 2025
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [astral-sh/uv](https://github.com/astral-sh/uv) | patch | `0.5.30` -> `0.5.31` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>astral-sh/uv (astral-sh/uv)</summary>

### [`v0.5.31`](https://github.com/astral-sh/uv/blob/HEAD/CHANGELOG.md#0531)

[Compare Source](astral-sh/uv@0.5.30...0.5.31)

##### Enhancements

-   Add `uv sync --script` ([#&#8203;11361](astral-sh/uv#11361))
-   Allow PEP 508 requirements in tool requests ([#&#8203;11337](astral-sh/uv#11337))
-   Allow source distributions to produce wheels with `+local` suffixes ([#&#8203;11429](astral-sh/uv#11429))
-   Bring parity to `uvx` and `uv tool install` requests ([#&#8203;11345](astral-sh/uv#11345))
-   Use a stable directory for local, remote, and stdin script virtual environments ([#&#8203;11347](astral-sh/uv#11347), [#&#8203;11364](astral-sh/uv#11364))
-   Detect infinite recursion in `uv run` ([#&#8203;11386](astral-sh/uv#11386))

##### Python

The managed Python distributions have been updated, including:

-   CPython 3.14.0a5, which includes a new [tail calling interpreter](https://docs.python.org/3.14/whatsnew/3.14.html#whatsnew314-tail-call) for a significant performance improvement
-   The bundled OpenSSL version was updated from 3.0.15 to 3.0.16 which fixes a [security advisory](https://openssl-library.org/news/secadv/20241016.txt)

See the [`python-build-standalone` release notes](https://github.com/astral-sh/python-build-standalone/releases/tag/20250212) for more details.

##### Bug fixes

-   Fix cross-drive script installation ([#&#8203;11167](astral-sh/uv#11167))
-   Add indexes in priority order ([#&#8203;11451](astral-sh/uv#11451))
-   Allow `--python <dir>` requests to match existing environments if `sys.executable` is the same file ([#&#8203;11290](astral-sh/uv#11290))
-   Avoid comparing to system site packages in `--dry-run` mode ([#&#8203;11427](astral-sh/uv#11427))
-   Prefer running executables in the environment with `<name>` over `<name>/__main__.py` ([#&#8203;11431](astral-sh/uv#11431))
-   Retry local clones without hardlinks if they fail ([#&#8203;11421](astral-sh/uv#11421))

##### Documentation

-   Update alternative-indexes.md to use `UV_INDEX` instead of `UV_EXTRA_INDEX_URL` ([#&#8203;11381](astral-sh/uv#11381))
-   Update scripts guide to include using package indexes ([#&#8203;11443](astral-sh/uv#11443))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4xNjYuMSIsInVwZGF0ZWRJblZlciI6IjM5LjE2Ni4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
loic-lescoat pushed a commit to loic-lescoat/uv that referenced this pull request Mar 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

uv run seems to add package directory to sys.path Modules override [project.scripts] for uv run

2 participants