flat-queen-95161
06/27/2022, 9:57 PMhappy-kitchen-89482
06/27/2022, 10:11 PM./pants filter and ./pants dependees, let me try somethinghappy-kitchen-89482
06/27/2022, 10:16 PM./pants filter --target-type=pex_binary :: | xargs ./pants dependencies --transitive will give you all the targets that all pex_binary targets transitively depend on, and ./pants list :: will give you all the targets in the repo, so then you'd just need to subtract the former from the latterflat-queen-95161
06/27/2022, 10:16 PMhappy-kitchen-89482
06/27/2022, 10:16 PMflat-queen-95161
06/27/2022, 10:17 PMflat-queen-95161
06/27/2022, 10:31 PM08:29 $ cat dead.sh
all=$(./pants list ::|grep -v tests | grep py$)
used=$(./pants filter --target-type=pex_binary :: | xargs ./pants dependencies --transitive|grep py$)
diff <(echo "$all" ) <(echo "$used") | grep "<"happy-kitchen-89482
06/27/2022, 11:28 PMfresh-cat-90827
07/01/2022, 2:35 PM$ find $(./pants roots --roots-sep=' ') -name \*.py
2. Get a list of all files that Pants is aware of (BUILD files, Python modules, test data and resources). The filedeps goal lists all source and BUILD files a target depends on.
$ ./pants filedeps ::
3. Compare these two lists to find files that are in the repository, but are not listed as file dependencies of Pants projects. All Python modules from the first command’s output should be in the output of the second command.
That’s what I do at my repofresh-cat-90827
07/01/2022, 2:36 PMtes_database.py — it’s not going to be picked up by pytestfresh-cat-90827
07/01/2022, 2:39 PM# find files that are in the repository, but are not listed as file dependencies of Pants projects
awk 'NR==FNR{a[$0]=1;next}!a[$0]' pants_files.txt repo_files.txt > orphan_python_modules.txt