Logos logo # Unpack [![CI](https://github.com/bnkc/unpack/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/bnkc/unpack/actions/workflows/ci.yml) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) _Unpack python packages from your project and more._ **Unpack** has a few goals: + To easily navigate and remove used, unused, and untracked python packages. + To quickly identify disk usage of packages in the above categories. + To view the relationship between various packages and their dependencies. To achieve those, **Unpack**: + Collects all project imports by walking the [abstract syntax tree](https://en.wikipedia.org/wiki/Abstract_syntax_tree). + Collects all declared dependencies from the [dependency specification file](https://peps.python.org/pep-0508/). + Maps local environment [site-packages](https://ffy00.github.io/blog/02-python-debian-and-the-install-locations/) to resolve dependencies and the imports they expose. + Identifies local site-package dependencies as to not accidently remove actively used dependencies of other packages. + Calculates package(s) size, and total disk usage. ### Package States + `-used` is when the package is locally installed, one of it's aliases is actively used in the project, and a corresponding dependency is declared in `pyproject.toml` or `requirements.txt`. This state indicates a fully integrated and properly managed package. + `-unused` is when the package is locally installed, and a corresponding dependency is declared in `pyproject.toml` or `requirements.txt`, but is not actively used in the project. **Caveat:** This package must not be a dependency of any actively `-used` package to be considered unused. + `-untracked` is when the package is installed, and one of it's aliases is actively used in the project, but is not declared in `pyproject.toml` or `requirements.txt`. This highlights packages that are implicitly used but not formally declared, which may lead to inconsistencies or issues in dependency management and deployment. ## Demo ``` 📦 Unused Packages package | version | size --------------+--------------+---------- scikit-learn | ^1.4.1.post1 | 46.9 MiB keras | ^3.0.5 | 8.8 MiB pydantic | ^1.9.0 | 3.1 MiB 💽 Total disk space: 58.9 MiB Note: There might be false-positives. For example, unpack cannot detect usage of packages that are not imported under `[tool.poetry.*]`. Similarly, it can only detect declared packages in requirements.txt or pyproject.toml. ```