0.1.0 |
|
---|
#34 in #unpack
490KB
1.5K
SLoC
Unpack
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.
- Collects all declared dependencies from the dependency specification file.
- Maps local environment site-packages 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 inpyproject.toml
orrequirements.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 inpyproject.toml
orrequirements.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 inpyproject.toml
orrequirements.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.
Dependencies
~20–31MB
~515K SLoC