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

uv does not recognize __main__.py? #7275

Closed
seppzer0 opened this issue Sep 10, 2024 · 3 comments · Fixed by #7281
Closed

uv does not recognize __main__.py? #7275

seppzer0 opened this issue Sep 10, 2024 · 3 comments · Fixed by #7281
Labels
enhancement New feature or request

Comments

@seppzer0
Copy link

I have a Python project that I run directly from source. Dependencies are stored within a uv-managed .venv in the project directory.

When I attempt to launch it as I normally would with PYTHONPATH=$(pwd) python3 builder/ via my system installation, I get an error:

$ PYTHONPATH=$(pwd) uv run ./builder
error: Failed to spawn: `./builder`
  Caused by: Access is denied. (os error 5)

However, if I just add the __main__.py in my command:

$ PYTHONPATH=$(pwd) uv run ./builder/__main__.py 
usage: __main__.py [-h] [--clean] {kernel,assets,bundle} ...

A custom builder for the zero kernel.

positional arguments:
  {kernel,assets,bundle}
    kernel              build the kernel
    assets              collect assets
    bundle              build the kernel + collect assets

options:
  -h, --help            show this help message and exit
  --clean               clean the root directory

..it runs successfully.

Would this be an intended behaviour or is this a bug?

@charliermarsh
Copy link
Member

Does uv run python ./builder work as expected?

@seppzer0
Copy link
Author

Interestingly, it does. I don't understand the difference yet, but adding python works.

@zanieb
Copy link
Member

zanieb commented Sep 10, 2024

In the error case, we've attempted to run a directory as though it were an executable. In the latter, you've invoked Python to run the module.

We should probably special case directories with __main__.py though (and support what you attempted to do)

@zanieb zanieb added the enhancement New feature or request label Sep 10, 2024
zanieb pushed a commit that referenced this issue Sep 11, 2024
## Summary

Allow `uv run ./package` runs a Python package with a `__main__.py`
script.

Resolves #7275
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants