Find unused dependencies
Project description
py-unused-deps
Find unused dependencies in your Python projects.
This application works by inspecting the metadata of your distribution and its
dependencies. This means the current project must be installed and
py-unused-deps
must be run from within the same environment as the project,
and its dependencies, are installed within. For example using setuptools
:
$ python -m venv .venv
$ source .venv/bin/activate
$ pip install --editable .
$ pip install unused-deps
$ py-unused-deps
Usage
usage: py-unused-deps [-h] [-d DISTRIBUTION] [-v] [-i IGNORE] [-s SOURCE] [-e EXTRA] [-r REQUIREMENT]
options:
-h, --help show this help message and exit
-d DISTRIBUTION, --distribution DISTRIBUTION
The distribution to scan for unused dependencies
-v, --verbose
-i IGNORE, --ignore IGNORE
Dependencies to ignore when scanning for usage. For example, you might want to ignore a linter that you run but
don't import
-s SOURCE, --source SOURCE
Extra directories to scan for python files to check for dependency usage
-e EXTRA, --extra EXTRA
Extra environment to consider when loading dependencies
-r REQUIREMENT, --requirement REQUIREMENT
File listing extra requirements to scan for
Distribution detection
By default py-unused-deps
will scan any pyproject.toml
or
setup.cfg/setup.py
file to try and detect a distribution. This may not always
be accurate, so you can specify a distribution to scan with --distribution
Extra dependencies
You distribution may contain extra optional dependencies to be installed like
pip install --editable .[tests]
. To also scan these you can use the --extra
flag. This can be used multiple times:
$ pip install --editable .[tests,security]
$ py-unused-deps --extra tests --extra security
Requirements File
Similar to above, you may have a distribution with some dev-only dependencies
that you want to ensure you're using, e.g. for tests. If these dependencies are
in a file you can include them with the --requirement
flag:
$ pip install --editable .
$ pip install --requirement requirements-tests.txt
$ py-unused-deps --requirement requirements-test.txt
Note: this flag does not support the full requirements spec as defined by pip but just comments and requirement specifications.
For example, each of the following requirements would be included:
pytest
pytest-cov
beautifulsoup4
docopt == 0.6.1
requests [security] >= 2.8.1, == 2.8.* ; python_version < "2.7"
urllib3 @ https://github.com/urllib3/urllib3/archive/refs/tags/1.26.8.zip
But all of the following would be skipped:
# unsupported: pip specific flags
-r other-requirements.txt
-c constraints.txt
# unsupported: paths
./downloads/numpy-1.9.2-cp34-none-win32.whl
# unsupported: plain URL
http://wxpython.org/Phoenix/snapshot-builds/wxPython_Phoenix-3.0.3.dev1820+49a8884-cp34-none-win_amd64.whl
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file py-unused-deps-0.1.0.tar.gz
.
File metadata
- Download URL: py-unused-deps-0.1.0.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7566dc38c751f06fd53c07490b0789ee01947b9137b16b99fc6629aab7b57b28 |
|
MD5 | 0963016452ab07c6d65e3a9f43a56faa |
|
BLAKE2b-256 | 2c57339a44afaebf95ff37ea4d3329fb5df1e81263fe93bb320cc863b04252db |
File details
Details for the file py_unused_deps-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: py_unused_deps-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8de5361bbc15c09a0b373a06af6347c71fb5a1920055d662aa0156244eb15026 |
|
MD5 | f92cded927d1df0b465e2b600d633961 |
|
BLAKE2b-256 | 8a45fbf38c3a8c5de73a9ab8ef2ea5d3792abb0f012b71381728dbf1227ffadd |