Configure resolves/lockfiles via targets(?) Hello,...
# general
s
Configure resolves/lockfiles via targets(?) Hello, would it make sense to configure resolves via targets, rather than pants.toml? i.e.
Copy code
resolve(name="res1", lockfile="pants.lock")
python_requirements(resolve=":res1")
I'm curious if there are any blockers before trying to implement this. i.e. is order of parsing build files an issue, given that resolves need to be evaluated before any other targets? It seems a bit similar to
environments()
.
And a follow up Q: It would be amazing to support listing/filtering targets in BUILD files. Maybe like programmatically calling introspection goals like list, i.e.:
Copy code
python_sources(resolve=list(path="//", filter_target_type="resolve"))
c
A lot of pants assumes that resolves come from the
PythonSetup
subsystem. I'm not sure if anything requires it. There is more complexity around the options to resolves, but I don't think it's insurmountable. Resolves are also implemented per-language.
This would be a good idea to discuss in the New Python Backend wishlist
s
Yea this kinda is part of the bigger discussions of "pants configuration per directory" discussion
h
I suspect this will be a lot easier to do in the new backend than trying to retcon it into the existing one
What would the benefit of this
resolve()
target be over the named one in the config?
s
In my case specifically, I'm trying to create a macro which makes setting up a new module in our monorepo easier. This is all the boilerplate needed just to get close to the default poetry-ish experience 😕:
Copy code
def python_module(
    name: str, tests: bool = True, test_fixtures: bool = True, typed: bool = True, **kwargs
):
    __defaults__(all=dict(resolve=parametrize(*MODULES), **kwargs))
    resolve(name=name)
    poetry_requirements(name="poetry")
    python_sources(
        name="sources", sources=["**/*.py", "**/*.pyi", "!**/*_test.py", "!**/conftest.py"]
    )
    if typed:
        resources(name="py_typed", sources=["**/py.typed"])
    if tests:
        python_tests(name="tests", resolve=name, sources=["**/*_test.py"])
    if test_fixtures:
        python_test_utils(name="conftest", resolve=name, sources=["**/conftest.py"])
h
Ah, I see
s
But speaking more generally, it seems inconsistent that resolves are defined in the pants.toml file, when other "objects" in the pants-world are defined in BUILD files.
h
Yeah, that dichotomy has always been annoying
In the new backend I want to have just one type of config
The distinction between “metadata that belongs to your build graph” vs “config” is fuzzy at best
💯 1
Ideally I want to get rid of ~all BUILD boilerplate
And see how far we can go
Feels like most things can be inferred from structure and/or convention
1
For posterity