I really have a weird issue I'm trying to better u...
# general
g
I really have a weird issue I'm trying to better understand. I have a monorepo with a bunch of modules that are packaged up using python_distribution targets. Those targets have pretty broad sources, i.e.
Copy code
resources("dist_files", sources=["module_name/**/*", "README.md"])

python_distribution(
    name="dist",
    dependencies=[":dist_files"],
    ...
)
As a result, when a developer creates a new sub-directory somewhere in the module, when they run
pants tailor ::
, it isn't generating the
python_sources
for what I assume is because pants is detecting the files being owned by a target already. So the question is, is this a bug or is there some feature I'm unaware of and should be doing this differently? I'm working around it by commenting out the resources, re-running pants tailor and then uncommenting.
n
I'm pretty sure it's a feature that it won't tailor for already owned targets.
The behaviour is not exclusive to the python tailoring.
Well, maybe not feature, but working as intended 😛
g
I know prescribed thing to do here is use actual existing python sources in the deps for the python_dist, but for various reasons that's a relatively high cost. I wish there was a macro that could dynamically find targets and then provide those, i.e.
Copy code
python_distribution(
    name="dist",
    dependencies=recursive_python_source_targets(),
    ...
)
Otherwise I need to tell my developers to do something like this:
Copy code
# Find all python sources
pants --filter-target-type=python_sources list path/to/dir::

# Shove into dependencies
python_distribution(
    name="dist",
    dependencies=[<shove-here>],
    ...
)
Which is complicated when they create a new directory.
This isn't an application with a single entry point. It's a library with a crapton of classes that are fairly independent.
n
I suppose you could do
python_sources(sources="module_name/**/*.py")
and depend on that only, and then, if you still want your resources(), do an ignore selector that removes .py from it.
g
yeah, I think you're right. Would that have any negative side-effects, i.e. worse test caching, etc.?
Because python_sources just creates a bunch of python_source targets I would think the answer is no, but I want to double check.
c
If you have set https://www.pantsbuild.org/2.19/reference/subsystems/python-infer#imports to
false
it would mean that all sources depend on all other sources grouped together by that generator. But the default is
true
which means pants looks at imports to build the dependency graph.