gorgeous-cat-15662
05/27/2025, 3:07 PMpyproject
files. I have generated the BUILD files which contain the poetry_requirements
statement. However, when I run pants test
it fails due to missing dependencies. These dependencies are defined and installed in the venv ( poetry run pytest
works fine) but pants test
is obviously not picking them up. Can someone advise on how best to approach this?gorgeous-winter-99296
05/27/2025, 3:16 PMpoetry_requirements
doesn't use the poetry lockfile or venv; it just reads the dependencies from it. From there on out it's dependent on your Pants setup. https://www.pantsbuild.org/stable/docs/python/overview/third-party-dependencies is a good starting point for reading, and after that we can maybe help if you share some more info about your setup.gorgeous-cat-15662
05/27/2025, 3:24 PMpants generate-lockfiles
and it exits without outputting anything. So, I'm not sure if it has generated a lockfile outside of the project or if it just hasn't done anything. But in any case, pants test ::
doesn't have access to the dependencies.gorgeous-cat-15662
05/27/2025, 3:31 PMpants dependencies
doesn't seem to pick up on the dependencies. Given a file with import pandas as pd
, running pants dependencies FILE
returns nothing.gorgeous-cat-15662
05/27/2025, 3:56 PMenable_resolves
option in my pants.toml. So, now it tries to generate a lockfile (it would be nice if I got a warning when this is missing). But unfortunately, it manages to concoct a versioning clash for itself. This is most peculiar as there is no such clash in our pyproject.toml files, but I guess it resolves a more permissive version requirement first (resolving to the latest), then clashes with a more restrictive version pinning. Altogether very odd behaviour. I'm unfortunately coming to the conclusion that pants
is not the right fit for our project. The Poetry integration still seems only partially complete and I don't have the stomach for migrating away from poetry on top of everything else.gorgeous-cat-15662
05/28/2025, 6:43 AMpyproject.toml
. It looks like there is a way to generate each lockfile separately that requires manual configuration. In our case, we have 76 pyproject.toml
files so I'd rather not go down that road.gorgeous-winter-99296
05/28/2025, 2:09 PMBut unfortunately, it manages to concoct a versioning clash for itself. This is most peculiar as there is no such clash in our pyproject.toml files, but I guess it resolves a more permissive version requirement first (resolving to the latest), then clashes with a more restrictive version pinning. Altogether very odd behaviour.A few corrections are warranted here. Pants does most of its heavy lifting when it comes Python through Pex, for example generating a lockfile. This happens across the whole closure of your dependencies -- there's no permissive resolve etc, it'll pick your dependencies, and then all of those dependencies dependencies, and so on. It is not unlikely that with 76 pyproject.toml files and god knows how many direct and transitive dependencies that contains, that there is a conflict. If poetry can resolve all of those into one lockfile one of two tools have a bug or the setup is different.
I'm unfortunately coming to the conclusion that pants is not the right fit for our project. The Poetry integration still seems only partially complete and I don't have the stomach for migrating away from poetry on top of everything else.That's a fine conclusion of course, and one I can understand with a codebase your size. I want to be clear that Pants does not integrate Poetry any more than it integrates PDM, hatch, or anything else. The only Poetry specific support I'm aware of is that we consume the poetry-specific additions to pyproject.toml.
If I'm understanding correctly, part of the problem is that pants is generating a unified lockfile for the whole project. This might save some disk space, but is not a good fit for a large monorepo consisting of many deployables. Instead, it'd be better if it created a single lockfile for each pyproject.toml. It looks like there is a way to generate each lockfile separately that requires manual configuration. In our case, we have 76 pyproject.toml files so I'd rather not go down that road.Your understanding is correct here; this is the suggested way of working. It ensures all your libraries and all your entrypoints are compatible with each other. It's not a matter of disk space, it's easier and more correct. Pants will flat out not work if you were to have a resolve for a library and a different resolve for an executable using that library, since those lockfiles could have conflicting requirements. See this blog post, f.ex: https://www.pantsbuild.org/blog/2022/05/25/multiple-lockfiles-python.
gorgeous-cat-15662
06/02/2025, 6:32 AM>= 1.01
. I'm not saying that Pants is being permissive, rather that some of our dependencies are specified in a permissive fashion.
What I saw was there was no conflict in all of our 76 pyprojects for the dependency in question. However, there were both permissive and restrictive versioning requirements mixed across our subprojects (not ideal), so I think Pants resolved to the latest version permitted before running into the restrictive requirement. That's my assessment anyway, I could be wrong.
> That's a fine conclusion of course, and one I can understand with a codebase your size.
I think I'm confused by the Pants use case after reading your reply. My understanding was that it was built as a better Bazel for Python, i.e. one of the primary usecases is large heterogenous codebases. Is that incorrect?
I'm still in love with its automatic dependency inferral and I'd love to be able to do conditional tests based on that. I think I'm going to have to set aside some more time soon to really dig in.
Thanks again for your response and apologies for the delay, we had a public holiday here in Denmark.gorgeous-winter-99296
06/02/2025, 10:18 AMgorgeous-winter-99296
06/02/2025, 10:28 AMgorgeous-cat-15662
06/02/2025, 11:10 AM