Skip to content

Instantly share code, notes, and snippets.

@liquidcarbon
Last active August 25, 2023 23:56
Show Gist options
  • Save liquidcarbon/50961257bcff4c0e93d2783ea8ee9ab7 to your computer and use it in GitHub Desktop.
Save liquidcarbon/50961257bcff4c0e93d2783ea8ee9ab7 to your computer and use it in GitHub Desktop.
Size of Python packages
#!/bin/bash
# this script will install a single package into a virtual environment using poetry,
# check the size of the installed dependencies, and clean up.
#
# usage:
# ./poetry_package_sizer.sh "notebook pandas polars altair bokeh matplotlib panel plotly streamlit fastapi flask django rdkit torch"
# Poetry version: 1.5.1
# Python version (change to yours)
PYTHON=python3.10
PWD=$(pwd)
for PKG in $1
do
echo -e "\n================================================================================================\n"
NAME="size$PKG"
poetry new $NAME
cd $NAME
poetry config virtualenvs.in-project true --local
poetry add $PKG
cd .venv/lib/$PYTHON/site-packages/
du -d1 | grep -Ev "pycache|dist-info" | \
sed -e 's/\.$/TOTAL/g' | sed 's/\.\///g' | sort -nk1 | \
awk '{printf "%32s", $2}{printf "%12s\n", $1}'
cd $PWD
rm -rf $NAME
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment