Skip to content

Using script entry point with inline dependencies  #7032

@samsja

Description

@samsja

First thanks for the great work on uv !

I have a python script that need pytorch. The dependency is defined inside the python script using the inline uv [syntax](https://docs.astral.sh/uv/guides/scripts/?query=script+dependencies#declaring-script-dependencies. The problem is that my entry point to run my code is not python myscript.py but torchrun myscript.py where torchrun is a script entrypoint install with pytorch.

It's an egg and chicken problem because pytorch is not installed so the command will fail, but it won't install pytorch unless I can run the script ...

I would expect to do something like:

uv run --with -R myscript.py torchrun myscript.py

that would read and install the dependencies from myscript.py. I could eventually distribute a separate requirement.txt but It some much cleaner in some cases to only share one file.

Thanks in advance 🙏

Metadata

Metadata

Assignees

No one assigned

    Labels

    cliRelated to the command line interface

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions