I'd like to set up a `python_distribution` with al...
# general
f
I'd like to set up a
python_distribution
with all the files (recursively) in a directory as contents. Is there a more maintainable way to do that than just injecting the contents of
pants list dir::
into the
dependencies
field?
w
f
Ok. I can go that route. Is there a reason wildcards are not allowed in dependency lists (ie
package_directory::
)?
w
it’s mostly historical? the argument was always that globbing isn’t very specific, and so is very likely to lead to depending on more than you actually need.
back before dependency inference, explicit dependencies were much, much more common (…i.e., almost every
import
statement might be duplicated), and so the temptation to just say “i depend on a whole swathe of things” was very high
now that you very rarely need to explicitly declare a dependency, it’s possible that not supporting globs in
dependencies
lists is the wrong tradeoff.
@freezing-vegetable-92896: if you have a use case that might be a useful example of where explicitly listing the root dependencies wouldn’t be great, please feel free to open a ticket about it.
f
@witty-crayon-22786 I think this is what you’re asking… I have a case where I have a library of interfaces. A good portion of the code in the package is not used in the package, it’s providing an interface which is consumed by downstream packages. In this case, I think the dependency inference fails because there aren’t the import statements tying everything together. I resorted to having a
python_sources(sources=["**/*.py"])
in the root of the module as the “gotta get this done” solution, but I’m interested if there’s a more idiomatic way to approach that
f
I've got a similar situation where we have some modules of related code in a directory structure with no one file that depends on everything else but that we would like to package into a single python package. Explicitly listing root dependencies risks missing newly added files that people who are as not into the intricacies of pants might be surprised were not in the package. It could be that this is a different version of legacy thinking and we should more be moving towards only packaging things that something explicitly depends on