Skip to main content

Find packages that should be in requirements for a project

Project description

pip-missing-reqs
================

It happens: you start using a module in your project and it works and you
don't realise that it's only being included in your `virtualenv`_ because
it's a dependency of a package you're using. This tool finds those modules so
you can include them in the `requirements.txt`_ for the project.

.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/
.. _`requirements.txt`: https://pip.pypa.io/en/latest/user_guide.html#requirements-files

Assuming your project follows a layout like the suggested `sample project`_::

setup.py
setup.cfg
requirements.txt
sample/__init__.py
sample/sample.py
sample/tests/test_sample.py

.. _`sample project`: https://packaging.python.org/en/latest/tutorial.html#creating-your-own-project

Basic usage, running in your project directory::

<activate virtualenv for your project>
pip-missing-reqs --ignore-files=sample/tests/* sample

This will find all imports in the code in "sample" and check that the
packages those modules belong to are in the requirements.txt file.


Sample tox.ini configuration
----------------------------

To make your life easier, copy something like this into your tox.ini::

[pip-missing-reqs]
deps=-rrequirements.txt
commands=pip-missing-reqs --ignore-files=sample/tests/* sample


Excluding test files (or others) from this check
------------------------------------------------

Your test files will sometimes be present in the same directory as your
application source ("sample" in the above examples). The requirements for
those tests generally should not be in the requirements.txt file, and you
don't want this tool to generate false hits for those.

You may exclude those test files from your check using the --ignore-files
option.


Excluding modules from the check
--------------------------------

If your project has modules which are conditionally imported, or requirements
which are conditionally included, you may exclude certain modules from the
check by name (or glob pattern) using --ignore-mods::

# ignore the module spam
pip-missing-reqs --ignore-mods=spam sample
# ignore the whole package spam as well
pip-missing-reqs --ignore-mods=spam --ignore-mods=spam.* sample
Release History
---------------

1.1.2
- corrected version of vendored search_packages_info() from pip
- handle relative imports

1.1.1
- fixed handling of import from __future__
- self-tested and added own requirements.txt
- cleaned up usage to require a file or directory to scan (rather than
defaulting to ".")
- vendored code from pip 1.6dev which fixes bug in search_packages_info
until pip 1.6 is released

1.1.0
- implemented --ignore-module

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

pip_missing_reqs-1.1.2.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

pip_missing_reqs-1.1.2-py2.py3-none-any.whl (20.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pip_missing_reqs-1.1.2.tar.gz.

File metadata

File hashes

Hashes for pip_missing_reqs-1.1.2.tar.gz
Algorithm Hash digest
SHA256 64c42a289bb6f12b1fe9c76da90a9e89f06b434b00662fe2ee52a978c695f6f6
MD5 70e0dff62eda4e180732de8246473722
BLAKE2b-256 fe89ddc6e9e5333ea82f68d786b07f3e7f4ea9164f0a0d0dc75906f99389baf3

See more details on using hashes here.

File details

Details for the file pip_missing_reqs-1.1.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pip_missing_reqs-1.1.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 88f21393beac43af50f0340de2993d0530d453df728e1f59570f0811bfe0f2b6
MD5 b21ab2e4b72ce0c39d9c003ff516a3bb
BLAKE2b-256 87e1c76fa66d3a019160d8868250f5db7f825746b02eee6ad7340f05a836dbdc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page