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

clean-night-52582

04/22/2021, 9:58 PM
Is there a good way to see orphaned files in pants? basically files that only end up in lib and test targets but are never put into a binary
actually this would break a little bit if you have test libs that shouldn't be in any production code.
h

hundreds-father-404

04/22/2021, 10:02 PM
Interesting. I think you can pipe together a few commands to get this. Something like this to first get all your package targets, then to find their dependees + those package targets
Copy code
./pants filter --target-type=pex_binary,python_distribution,archive :: | xargs ./pants dependees --transitive --closed
Now, find the set difference of something like
./pants list ::
or
./pants filter --targget-type=python_library ::
, then subtract the previous result. Then on those remaining targets,
./pants filedeps
to see which files they correspond to
e

enough-analyst-54434

04/22/2021, 10:04 PM
comm
is magic for stuff like this.
💯 1
1
h

hundreds-father-404

04/22/2021, 10:06 PM
Personally, I do the very verbose thing of using Python and
subprocess.run()
+ its
set
data type, but yeah
comm
allows you to stick to bash
c

clean-night-52582

04/22/2021, 10:32 PM
Oh that's awesome. I'll give that a shot.
I think my project has a bunch of files we don't need anymore so this will help us clean them up
💯 1
h

hundreds-father-404

04/22/2021, 10:33 PM
./pants dependees
is one of my fav features of Pants for that exact reason, I love deleting code
c

clean-night-52582

04/23/2021, 12:12 AM
Would pants consider adding a
test
argument to the targets that are
python_library
that would block them from being imported into nontest root targets? It could make this a little easier. I'm currently adding
tags = {'test-only'}
to those libs.
h

hundreds-father-404

04/23/2021, 12:13 AM
Probably before adding that would be adding more general support for visibility. Pants atm has no support for limiting imports, and you could for example import files from a
python_tests
target from a
python_library
target
c

clean-night-52582

04/23/2021, 12:24 AM
I would love that feature. I find it very helpful for enforcing what the directory structure means.
2
4 Views