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

A uv run subcommand #1207

Closed
konstin opened this issue Jan 31, 2024 · 6 comments
Closed

A uv run subcommand #1207

konstin opened this issue Jan 31, 2024 · 6 comments
Assignees
Labels
enhancement New feature or improvement to existing functionality

Comments

@konstin
Copy link
Member

konstin commented Jan 31, 2024

In the initial implementation, the puffin run subcommand looks for a venv in .venv in the current or any parent directory, activates it by setting VIRTUAL_ENV and PATH and then replaces itself with the python interpreter with the trailing args (on unix, it might be faster to not spawn a new process but load libpython and run Py_Main).

In further steps we can extend this to read pyproject.toml, create a venv if none exists, install all (missing) dependencies and run. This enables a "git clone and puffin run" workflow where the user does not need to manually handle venvs and dependency installation anymore. puffin run could replace python as batteries-included entrypoint for running python code.

@konstin konstin added the enhancement New feature or improvement to existing functionality label Jan 31, 2024
@zanieb zanieb changed the title A puffin run subcommand A uv run subcommand Feb 15, 2024
@zanieb
Copy link
Member

zanieb commented Feb 15, 2024

xref #1173

@henryiii
Copy link
Contributor

This would support PEP 721? One issue with pipx run is it prioritizes classic PyPI apps, so pipx run file.py will look for a file-py on PyPI. So uv run file.py could run a local file, wile uv pipx run could be the PyPI one.

@konstin
Copy link
Member Author

konstin commented Feb 20, 2024

Good question! I'm wondering how to handle conflicts. If a file contains a PEP 723 comment and exists in a uv workspace (with a pyproject.toml with uv configuration), should uv run use the inline metadata or the workspace metadata?

@henryiii
Copy link
Contributor

I believe the inline metadata should override the more general config. It’s the same way I’d hope Ruff support for PEP 723 would work, it’s a way to put per file config in the files. Like the matching feature in Rust (that partially inspired the PEP).

@pfmoore
Copy link
Contributor

pfmoore commented Mar 19, 2024

I agree that PEP 723 metadata should take precedence. An obvious use case I would have for a feature like this would be to write small "workflow support" scripts in my project directory. These would have their own dependencies, and could very easily not share any dependencies with the project itself (imagine, for example, a make_docs.py script that depended on Sphinx). Such scripts would be a lightweight alternative to a tool like nox.

@zanieb zanieb self-assigned this Apr 14, 2024
@zanieb
Copy link
Member

zanieb commented May 13, 2024

See #3074 for the initial implementation of this.

#3096 tracks PEP 723 support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement to existing functionality
Projects
None yet
Development

No branches or pull requests

4 participants