Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI reported by uv run on Windows is not found on invocation #8770

Closed
kdeldycke opened this issue Nov 3, 2024 · 10 comments · Fixed by #9099
Closed

CLI reported by uv run on Windows is not found on invocation #8770

kdeldycke opened this issue Nov 3, 2024 · 10 comments · Fixed by #9099
Labels
bug Something isn't working

Comments

@kdeldycke
Copy link

Tl;Dr: On Windows nuitka is reported as an available CLI in a uv venv:

$ uv run
Provide a command or script to invoke with `uv run <command>` or `uv run <script>.py`.

The following commands are available in the environment:

- nuitka
- nuitka-run
- pydoc
- python
- pythonw

See `uv run --help` for more information.

But its invocation fails:

$ uv --no-progress run --frozen -- nuitka --version
error: Failed to spawn: `nuitka`
  Caused by: program not found

Context

This happened in a GitHub action runner on windows-2022. But the exact same sequence and invocation works perfectly on macos-15, macos-13 or ubuntu-24.04.

Fix

To fix the issue, I have to use an indirect call to the Python interpreter on windows-2022:

$ uv --no-progress run --frozen -- python -m nuitka --version

Reproduction

To reproduce the issue, on Windows:

$ python -m pip install uv
$ uv venv
$ uv pip install nuitka
$ uv run -- nuitka --version

This issue has been reported and being discussed in Nuitka project at: Nuitka/Nuitka#3173

@kayhayen
Copy link

kayhayen commented Nov 3, 2024

Just to provide you with what you are lacking there. Nuitka is providing its own scripts for Windows, these are cmd files, passed as scripts to setup() and not use entry points. The point being, that Nuitka wants a clean Python interpreter, so those scripts effectively only do python -m nuitka for the user.

It seems, as an incompatibility to normal pip/setuptools, you don't copy them. They need no treatment at all, just plain copy.

@bluss
Copy link
Contributor

bluss commented Nov 3, 2024

The output of 'The following commands are available in the environment' is based on listing the scripts path in the virtual environment, so something is definitely installed there as nuitka expects (listing explicitly and verbose output might be good for the bug report), but it might be a matter of the extension and that uv run doesn't dispatch that executable or script correctly.

@charliermarsh
Copy link
Member

@zanieb -- Didn't we have some change that looks at the .exe here?

@zanieb
Copy link
Member

zanieb commented Nov 3, 2024

Are you thinking of #6683? I don't think that would help here.

How are we suppose to execute .cmd files?

For reference, the script looks like this: https://github.com/Nuitka/Nuitka/blob/ff030b7ad508a1773c2d2563b55fee4b5e3eac9a/misc/nuitka.cmd

@zanieb zanieb added the bug Something isn't working label Nov 3, 2024
@samypr100
Copy link
Collaborator

samypr100 commented Nov 3, 2024

I believe the recommendation is to use the formalized executable entrypoints.
Legacy setup.py scripts are not recommended as stated below by PyPA.

Although setup() supports a scripts keyword for pointing to pre-made scripts to install, the recommended approach to achieve cross-platform compatibility is to use Creating executable scripts entry points (see below).

@kayhayen
Copy link

kayhayen commented Nov 11, 2024

Yes, I am sure that's the recommendation, however, with Nuitka supporting a wide range of Python versions, some of which predate these things being any good, I really don't want to deal with making the move like that. Do you consider to become compatible by placing the said scripts unchanged to where they belong, even though packagers should (generally) not do it?

And if that's not the case, is there a way for me to detect installation by uv pip so I can inform the users, that they should use standard pip instead, and alternatively how to invoke it, or maybe install a nuitka console script on Windows, that does only that?

@kdeldycke
Copy link
Author

I just updated my test case with uv == 0.5.2.

uv reports the following commands on Windows:

> uv run
Provide a command or script to invoke with `uv run <command>` or `uv run <script>.py`.

The following commands are available in the environment:

- nuitka-run.cmd
- nuitka.cmd
- pydoc.bat
- python
- pythonw

See `uv run --help` for more information.

So off course calling nuitka as-is works on all platforms but Windows:

> uv --no-progress run --frozen -- nuitka --version
error: Failed to spawn: `nuitka`
  Caused by: program not found

Instead, calling nuitka.cmd on Windows works:

> uv --no-progress run --frozen -- nuitka.cmd --version
2.4.11
Commercial: None
Python: 3.12.7 (tags/v3.12.7:0b05ead, Oct  1 2024, 03:06:41) [MSC v.1941 64 bit (AMD64)]
Flavor: CPython Official
Executable: D:\a\nuitka-issue-3173\nuitka-issue-3173\.venv\Scripts\python.exe
OS: Windows
Arch: x86_64
WindowsRelease: 10
Version C compiler: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.41.34120\bin\Hostx64\x64\cl.exe (cl 14.3).

kdeldycke added a commit to kdeldycke/workflows that referenced this issue Nov 15, 2024
@zanieb
Copy link
Member

zanieb commented Nov 15, 2024

Sweet, thank you for testing it.

That seems reasonable to me. We could special case .cmd and add it automatically, but that seems different than the standard Windows behavior.

@jenshnielsen
Copy link

That seems reasonable to me. We could special case .cmd and add it automatically, but that seems different than the standard Windows behavior.

I would not say so. In both powershell and cmd on windows you can execute a .cmd and a .ps1 file without the extension.

E.g. the following would work assuming nuitka is installed in the venv .venv

.venv\Scripts\activate
nuitka

Infact the same would also work in nu-shell on windows

It is however different from the behaviour of Rust's std lib Spawn

@zanieb
Copy link
Member

zanieb commented Nov 15, 2024

Oh, I see. Hm. Thanks for that additional context.

We can track in #9151

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 a pull request may close this issue.

7 participants