Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

Hi David,

Thanks for the different talks and templates, I've been "playing" with it for a while now for personal use and introduced to my company recently (only in talks).

I started with the uv template, and am using the uv sync --all-packages command to create my env and get it synced.
Doing so, I also realized that it would install all dependencies within my projects which is great because I typically add my dependencies there when I create/update a component or base.
So I decided to actually keep the dependencies at the root pyproject toml empty.
It would also mean I don't have to keep track of multiple different pyproject toml dependencies.

What do you think of this pattern?
I am not really finding disadvantages myself so far!

Greg

You must be logged in to vote

I think that will work! One reason to have the dependencies in the root project file is when you develop things without the need to define a project. You can start coding on your features and think about how it should be deployed later on. When you are ready, then you can create a new project in the Polylith workspace. But that's optional, and I think your solution will work well.

Another possibility is to have the specific dependency versions only defined in the root project file, and have the project specific ones without a version. That's also optional, and can be convenient to avoid having each project define its version:

dependencies = [
    "sqlalchemy"
]

Replies: 1 comment · 7 replies

Comment options

I think that will work! One reason to have the dependencies in the root project file is when you develop things without the need to define a project. You can start coding on your features and think about how it should be deployed later on. When you are ready, then you can create a new project in the Polylith workspace. But that's optional, and I think your solution will work well.

Another possibility is to have the specific dependency versions only defined in the root project file, and have the project specific ones without a version. That's also optional, and can be convenient to avoid having each project define its version:

dependencies = [
    "sqlalchemy"
]
You must be logged in to vote
7 replies
@DavidVujic
Comment options

Oh, so the other way around than today. Sounds like a good idea! I'll give that a try.

@fraser-langton
Comment options

@DavidVujic this could maybe be the reccomended way, and give example for uv docs - it ensures consistency of package version between projects and local

./pyproject.toml

[tool.uv.sources]
    project_a              = {workspace = true}
    project_b              = {workspace = true}

[tool.uv.workspace]
    members = [ "projects/*" ]

./projects/project_a/pyproject.toml

[project]
    dependencies = [
        "fastapi",
        "sqlmodel",
    ]

./projects/project_b/pyproject.toml

[project]
    dependencies = [
        "pydantic",
    ]
@DavidVujic
Comment options

I agree! Is the tool.uv.sources in the top-level pyproject.toml needed? I think that you would want to set the version somewhere.

I have made an example setup for deployment with description here: https://github.com/DavidVujic/python-polylith-example-uv/tree/main/projects/my_fastapi_project#example-usage

The dockerfile is minimalistic, without any other dependencies than Python. You can of course do this in several ways, and it is not required to create wheels (but I think it is very convenient).

@fraser-langton
Comment options

yep tool.uv.sources tells uv to sync with the pyprojects there - if you wanted to pin versions you can do so in the root and it would be pinned everywhere.

I used your example uv project to start mine off I have some potential improvements to use more uv features that I can send you!

@DavidVujic
Comment options

Ok, thanks! I thought it was enough to have this in the root pyproject.toml:

[tool.uv.workspace]
members = [ "projects/*" ]
Answer selected by gregunz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #383 on October 29, 2025 18:20.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.