Got a conceptual question. I've got two packages A...
# general
b
Got a conceptual question. I've got two packages A and B. Before the migration to pants these were separate repositories so they had fully separate requirements. Now I'm trying to define more narrow resolves, but I'm getting stuck at tests. My plan was to have a dedicated resolve for packages that are only used in tests (e.g.
pytest
,
moto
). But some of my tests import
pytest
, so I'm getting warnings about unowned imports. • Does that even make sense as a general approach? Should I keep such packages in the resolve of each package? • Should I explicitly ignore such imports in each test file that it occurs? • Is there a better way of managing this?
s
For a green field mono repo (5 or 6 apps) we: • use a single resolve (shared between all apps) • have our test dependencies (
pytest
,
pytest-asyncio
, etc.) inside that single resolve, plus all our regular dependencies • package our app with Pants/PEX Because we're using Pants/PEX to package: • our final packaged apps only include what they
import
• our test dependencies like
pytest
don't get packaged in to our final apps (because we don't
import pytest
anywhere in app code)
h
You want as few resolves as possible, ideally just 1 if you can get away with it. Multiple resolves are useful when different parts of the codebase have conflicting requirements. Is that your case? I don't think it makes sense to have a resolve just for test packages, because eventually those are going to have to run in the same process as the code they test, meaning they need to share a resolve...
b
Multiple resolves are useful when different parts of the codebase have conflicting requirements. Is that your case?
For now we can potentially get away by using a single resolve for both parts. But what would be the way forward if packages A and B are incompatible for a common resolve? • have pytest + plugins in both resolves? • pytest has the option
install_from_resolve
in
pants.toml
, what to do with that? Thank you both for the feedback 🙇
s
correct, both resolves would need to contain all deps required to build/test that resolve's package