Uv managed Plone project and dependency constraints

I'm currently managing my Plone python environments with uv pip commands, but I don't have a fully managed uv project where I can run uv sync, uv add, etc. I also looked at how cookieplone creates a backend addon and it looks like it doesn't bother with making it uv managed at all - it sets [tool.uv] managed=false.

I'm wondering if there is some roadmap or discussion with regards to uv and Plone? It seems to be doable, to an extent, but the support for constraints is where I run into a major issue. You can add -c constraints.txt on uv add, but not on uv sync. There is some discussion on the astral project here Allow `--constraints` in `uv sync` · Issue #12490 · astral-sh/uv · GitHub. Whatever Airflow is seems to be similar to Plone in that there a huge number of dependencies that the community would pip install with -c to some url.

What you can do is add a constraints-dependencies section

[tool.uv]
constraint-dependencies = [
    "idna==3.18"
]

But that requires converting e.g. https://dist.plone.org/release/6.2.0/constraints.txt to this format for every pin. I thought maybe I could create a stub project that just maintains a constraint-dependencies section and then use it for all of my Plone site projects (or plone itself could do it), but this doesn't work - as far as I can tell this setting is ignored for dependencies and only works if you put it on the top level project. That sucks - I don't want to have to pin 100+ version constraints on every Plone site project I have. I believe this comment to be expressing the same frustration: Allow `--constraints` in `uv sync` · Issue #12490 · astral-sh/uv · GitHub

Curious to know how others are managing Plone deps with uv.

1 Like

We have a PR to modernize the templates in cookieplone-templates that includes setting the project as uv managed project:

1 Like

I’m also looking forward to that, as we are still on stone age good old zc.buildout :sweat_smile: which is interesting how some things seem still nowadays simpler to manage with it, while others are really outdated :upside_down_face:

Cool! Could I trouble you for a brief description of how you see a uv managed project working with regard to constraints? There's quite a lot of changes here, I'm not sure where to look

@ericof came up with the idea of adding a feature to repoplone that collects Plone's requirements file as constraints file, mixes everything with the current projects dependencies (listed in pyproject.toml) and produces the constraint-dependencies section for pyproject.toml

We have also documentation for this, here:

1 Like

I confess, I was still running Volto 18 and didn't realize this already got updated in 19. repoplone deps constraint seems to be what I was thinking of.