https://pantsbuild.org/ logo
#general
Title
# general
s

swift-river-73520

03/27/2023, 6:21 PM
feels like I'm still adapting to the pants way of thinking regarding source file dependencies and could use a little help. if I'd like to make a wheel artifact which represents an API library I'd like to publish, how do I ensure all the sources from a set of folders end up in there? right now I seem to be only packaging files that are referenced directly or transitively from the top-level
__init__.py
file for example, given a project layout like this:
Copy code
src/python/pylibrary/sub1/*.py. # also has BUILD 
src/python/pylibrary/sub2/*.py. # also has BUILD
src/python/pylibrary/__init__.py  # <- has some imports from sub2
src/python/BUILD
one way I thought I'd be able to force pants to include all the files in
pylibrary
was to explicitly list the target dependencies
Copy code
python_distribution(
    dependencies=["pylibrary/sub1:src", "pylibrary/sub2:src"]
)
but this seems to still only include files referenced directly or transitively from
src/python/pylibrary/___init___.py
so what's the canonical way to build a wheel distribution which includes all files in a subpackage, with the goal of being able to install this library in a consumer's environment? right now it feels like the only way would be to specify a public API in the
src/python/pylibrary/__init__.py
(which maybe I should be doing anyway)
e

enough-analyst-54434

03/27/2023, 6:42 PM
The algorithm should be
pants filedeps <dependencies targets>
- that list of files goes in the dist. If that list of files does not go in dist , that's a bug. If the list is too small, you're failing to glob all the files you mean and need to fix `sources=...`globs.
Ah, rather:
pants filedeps --transitive <dependencies targets>
s

swift-river-73520

03/27/2023, 8:17 PM
okay, thank you lots
pants filedeps --transitive
was helpful and I figured out my issue for wheel archives. still working through some seemingly related issues with building pex binaries so I might reach out again about that soon
2 Views