pythonuv

How do I make a script accessible across all directories within a python monorepo using uv?


I have a python monorepo with a top-level pyproject.toml. The monorepo contains a projects directory each with its own python package and pyproject.toml file. Some of these projects define scripts:

[project.script]
aaa = "aaa.something:main"

Within the project directory, I can run the script with uv run aaa. Outside of the project directory the script cannot be found.

What can I do to make the project script accessible with uv run across the workspace?


Solution

  • You can pass --project with every command. This option specifies a "project root" directory within which the command will be run.

    Assuming the project with aaa is at has_aaa, and you are at a sibling of has_aaa, the command would look like this:

    $ uv run --project ../has_aaa aaa