Created
March 8, 2021 18:41
-
-
Save kaos/1481cef9a6742654274c32b11c8e55ac to your computer and use it in GitHub Desktop.
Print a list of all packages with "non standard" top level modules
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# Outputs package info (in yaml format) for all installed packages | |
# with non-standard or additional top level modules. | |
# | |
# Usage: ./build-support/python/find_module_mappings.sh [.../site-packages] | |
# | |
# Will look up default site packages for current python unless | |
# provided. | |
site_packages="${1:-`python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"`}" | |
function extra_top_levels { | |
for module in $(cat "$2"); do | |
case "${module,,}" in | |
$1|tests|_*) ;; | |
*) echo " - $module" ;; | |
esac | |
done | |
} | |
for top_level in $(find "$site_packages" -name top_level.txt | sort); do | |
package=${top_level#$site_packages/} | |
package=${package%%-*} | |
package=${package,,} | |
case "$package" in | |
*/*) ;; # skip if there is / in package name | |
*) | |
top_levels=$(extra_top_levels "$package" "$top_level") | |
[ -z "$top_levels" ] || cat <<EOF | |
$package: | |
$top_levels | |
EOF | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment