pip-check-reqs


Namepip-check-reqs JSON
Version 2.5.3 PyPI version JSON
download
home_pagehttps://github.com/r1chardj0n3s/pip-check-reqs
SummaryFind packages that should or should not be in requirements for a project
upload_time2023-09-12 12:27:53
maintainerAdam Dangoor
docs_urlNone
authorRichard Jones
requires_python>=3.9.0
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            |Build Status| |codecov| |PyPI|

.. |Build Status| image:: https://github.com/r1chardj0n3s/pip-check-reqs/workflows/CI/badge.svg
   :target: https://github.com/r1chardj0n3s/pip-check-reqs/actions
.. |codecov| image:: https://codecov.io/gh/r1chardj0n3s/pip-check-reqs/branch/master/graph/badge.svg
   :target: https://codecov.io/gh/r1chardj0n3s/pip-check-reqs
.. |PyPI| image:: https://badge.fury.io/py/pip-check-reqs.svg
   :target: https://badge.fury.io/py/pip-check-reqs

pip-check-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. pip-missing-reqs finds those
modules so you can include them in the `requirements.txt`_ for the project.

Alternatively, you have a long-running project that has some packages in
requirements.txt that are no longer actively used in the codebase. The
pip-extra-reqs tool will find those modules so you can remove them.

.. _`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

Basic usage, running in your project directory::

    <activate virtualenv for your project>
    pip-missing-reqs --ignore-file=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.

Additionally it is possible to check that there are no dependencies in
requirements.txt that are then unused in the project::

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

This would find anything that is listed in requirements.txt but that is not
imported by sample.

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

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

    [testenv:pip-check-reqs]
    deps=-rrequirements.txt
    commands=
        pip-missing-reqs --ignore-file=sample/tests/* sample
        pip-extra-reqs --ignore-file=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-file`
option (shorthand is `-f`). Multiple instances of the option are allowed.


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-module` (shorthand is `-m`)::

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


Using pyproject.toml instead of requirements.txt
------------------------------------------------

If your project uses `pyproject.toml` instead of `requirements.txt`, you can
use an external tool like `pdm` to convert it to `requirements.txt`::

    # requires `pip install pdm`
    pdm export --pyproject > requirements.txt

Then you can use `pip-missing-reqs` and `pip-extra-reqs` as usual.

With Thanks To
--------------

Josh Hesketh -- who refactored code and contributed the pip-extra-reqs tool.

Wil Cooley -- who handled the removal of normalize_name and fixed some bugs.



Release History
---------------

2.5.2

- Performance improvements.
- Add preliminary support for Windows.

2.5.1

- Fix an issue with importing `__main__`.
- Fix an issue with importing packages with periods in their names.

2.5.0

- Support Python 3.10.
- Remove support for Python 3.8.
- Bump `pip` requirement to 23.2.

2.4.4

- Bump `packaging` requirement to >= 20.5. Older versions of `pip-check-reqs` may be broken with the previously-specified version requirements.

2.4.3

- Improves performance on Python 3.11.

2.4.2

- Added support for Python 3.11.
- Added `python_requires` to metadata; from now on, releases of
  `pip-check-reqs` are marked as compatible with Python 3.8.0 and up.
- Made `--version` flag show interpretter version and path to the package which
  pip-check-reqs is running from, similar to information shown by `pip
  --version`.
- `-V` is now an alias of `--version`.

2.3.2

- Fixed support for pip < 21.3

2.3.1

- Fixed `--skip-incompatible` skipping other requirements too.
- Support pip >= 21.3

2.3.0

- Support pip >= 21.2.1

2.2.2

- AST parsing failures will now report tracebacks with a proper filename for
  the parsed frame, instead of `<unknown>`.

2.2.1

- Python source is now always read using utf-8, even if default encoding for
  reading files is set otherwise.

2.2.0

- Added `--skip-incompatible` flag to `pip-extra-reqs`, which makes it ignore
  requirements with environment markers that are incompatible with the current
  environment.
- Added `--requirements-file` flag to `pip-extra-reqs` and `pip-missing-reqs`
  commands. This flag makes it possible to specify a path to the requirements
  file. Previously, `"requirements.txt"` was always used.
- Fixed some of the logs not being visible with `-d` and `-v` flags.

2.1.1

- Bug fix: Though Python 2 support was removed from the source code, the published wheel was still universal.
  The published wheel now explicitly does not support Python 2.
  Please use version 2.0.4 for Python 2.

2.1.0

- Remove support for Python 2.
  Please use an older version of this tool if you require that support.
- Remove requirement for setuptools.
- Support newer versions of pip, including the current version, for more features (20.1.1).
  Thanks to @Czaki for important parts of this change.

2.0.1

- handled removal of normalize_name from pip.utils
- handle packages with no files

2.0 **renamed package to pip_check_reqs**

- added tool pip-extra-reqs to find packages installed but not used
  (contributed by Josh Hesketh)

1.2.1

- relax requirement to 6.0+

1.2.0

- bumped pip requirement to 6.0.8+
- updated use of pip internals to match that version

1.1.9

- test fixes and cleanup
- remove hard-coded simplejson debugging behaviour

1.1.8

- use os.path.realpath to avoid symlink craziness on debian/ubuntu

1.1.7

- tweak to debug output

1.1.6

- add debug (very verbose) run output

1.1.5

- add header to output to make it clearer when in a larger test run
- fix tests and self-test

1.1.4

- add --version
- remove debug print from released code lol

1.1.3

- fix program to generate exit code useful for testing

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

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/r1chardj0n3s/pip-check-reqs",
    "name": "pip-check-reqs",
    "maintainer": "Adam Dangoor",
    "docs_url": null,
    "requires_python": ">=3.9.0",
    "maintainer_email": "adamdangoor@gmail.com",
    "keywords": "",
    "author": "Richard Jones",
    "author_email": "r1chardj0n3s@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/46/8d/0dea2eff162944c72fb8b779c970828c7dc304843b4a4ef9bde217eb16ef/pip_check_reqs-2.5.3.tar.gz",
    "platform": null,
    "description": "|Build Status| |codecov| |PyPI|\n\n.. |Build Status| image:: https://github.com/r1chardj0n3s/pip-check-reqs/workflows/CI/badge.svg\n   :target: https://github.com/r1chardj0n3s/pip-check-reqs/actions\n.. |codecov| image:: https://codecov.io/gh/r1chardj0n3s/pip-check-reqs/branch/master/graph/badge.svg\n   :target: https://codecov.io/gh/r1chardj0n3s/pip-check-reqs\n.. |PyPI| image:: https://badge.fury.io/py/pip-check-reqs.svg\n   :target: https://badge.fury.io/py/pip-check-reqs\n\npip-check-reqs\n==============\n\nIt happens: you start using a module in your project and it works and you\ndon't realise that it's only being included in your `virtualenv`_ because\nit's a dependency of a package you're using. pip-missing-reqs finds those\nmodules so you can include them in the `requirements.txt`_ for the project.\n\nAlternatively, you have a long-running project that has some packages in\nrequirements.txt that are no longer actively used in the codebase. The\npip-extra-reqs tool will find those modules so you can remove them.\n\n.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/\n.. _`requirements.txt`: https://pip.pypa.io/en/latest/user_guide.html#requirements-files\n\nAssuming your project follows a layout like the suggested sample project::\n\n    setup.py\n    setup.cfg\n    requirements.txt\n    sample/__init__.py\n    sample/sample.py\n    sample/tests/test_sample.py\n\nBasic usage, running in your project directory::\n\n    <activate virtualenv for your project>\n    pip-missing-reqs --ignore-file=sample/tests/* sample\n\nThis will find all imports in the code in \"sample\" and check that the\npackages those modules belong to are in the requirements.txt file.\n\nAdditionally it is possible to check that there are no dependencies in\nrequirements.txt that are then unused in the project::\n\n    <activate virtualenv for your project>\n    pip-extra-reqs --ignore-file=sample/tests/* sample\n\nThis would find anything that is listed in requirements.txt but that is not\nimported by sample.\n\nSample tox.ini configuration\n----------------------------\n\nTo make your life easier, copy something like this into your tox.ini::\n\n    [testenv:pip-check-reqs]\n    deps=-rrequirements.txt\n    commands=\n        pip-missing-reqs --ignore-file=sample/tests/* sample\n        pip-extra-reqs --ignore-file=sample/tests/* sample\n\n\nExcluding test files (or others) from this check\n------------------------------------------------\n\nYour test files will sometimes be present in the same directory as your\napplication source (\"sample\" in the above examples). The requirements for\nthose tests generally should not be in the requirements.txt file, and you\ndon't want this tool to generate false hits for those.\n\nYou may exclude those test files from your check using the `--ignore-file`\noption (shorthand is `-f`). Multiple instances of the option are allowed.\n\n\nExcluding modules from the check\n--------------------------------\n\nIf your project has modules which are conditionally imported, or requirements\nwhich are conditionally included, you may exclude certain modules from the\ncheck by name (or glob pattern) using `--ignore-module` (shorthand is `-m`)::\n\n    # ignore the module spam\n    pip-missing-reqs --ignore-module=spam sample\n    # ignore the whole package spam as well\n    pip-missing-reqs --ignore-module=spam --ignore-module=spam.* sample\n\n\nUsing pyproject.toml instead of requirements.txt\n------------------------------------------------\n\nIf your project uses `pyproject.toml` instead of `requirements.txt`, you can\nuse an external tool like `pdm` to convert it to `requirements.txt`::\n\n    # requires `pip install pdm`\n    pdm export --pyproject > requirements.txt\n\nThen you can use `pip-missing-reqs` and `pip-extra-reqs` as usual.\n\nWith Thanks To\n--------------\n\nJosh Hesketh -- who refactored code and contributed the pip-extra-reqs tool.\n\nWil Cooley -- who handled the removal of normalize_name and fixed some bugs.\n\n\n\nRelease History\n---------------\n\n2.5.2\n\n- Performance improvements.\n- Add preliminary support for Windows.\n\n2.5.1\n\n- Fix an issue with importing `__main__`.\n- Fix an issue with importing packages with periods in their names.\n\n2.5.0\n\n- Support Python 3.10.\n- Remove support for Python 3.8.\n- Bump `pip` requirement to 23.2.\n\n2.4.4\n\n- Bump `packaging` requirement to >= 20.5. Older versions of `pip-check-reqs` may be broken with the previously-specified version requirements.\n\n2.4.3\n\n- Improves performance on Python 3.11.\n\n2.4.2\n\n- Added support for Python 3.11.\n- Added `python_requires` to metadata; from now on, releases of\n  `pip-check-reqs` are marked as compatible with Python 3.8.0 and up.\n- Made `--version` flag show interpretter version and path to the package which\n  pip-check-reqs is running from, similar to information shown by `pip\n  --version`.\n- `-V` is now an alias of `--version`.\n\n2.3.2\n\n- Fixed support for pip < 21.3\n\n2.3.1\n\n- Fixed `--skip-incompatible` skipping other requirements too.\n- Support pip >= 21.3\n\n2.3.0\n\n- Support pip >= 21.2.1\n\n2.2.2\n\n- AST parsing failures will now report tracebacks with a proper filename for\n  the parsed frame, instead of `<unknown>`.\n\n2.2.1\n\n- Python source is now always read using utf-8, even if default encoding for\n  reading files is set otherwise.\n\n2.2.0\n\n- Added `--skip-incompatible` flag to `pip-extra-reqs`, which makes it ignore\n  requirements with environment markers that are incompatible with the current\n  environment.\n- Added `--requirements-file` flag to `pip-extra-reqs` and `pip-missing-reqs`\n  commands. This flag makes it possible to specify a path to the requirements\n  file. Previously, `\"requirements.txt\"` was always used.\n- Fixed some of the logs not being visible with `-d` and `-v` flags.\n\n2.1.1\n\n- Bug fix: Though Python 2 support was removed from the source code, the published wheel was still universal.\n  The published wheel now explicitly does not support Python 2.\n  Please use version 2.0.4 for Python 2.\n\n2.1.0\n\n- Remove support for Python 2.\n  Please use an older version of this tool if you require that support.\n- Remove requirement for setuptools.\n- Support newer versions of pip, including the current version, for more features (20.1.1).\n  Thanks to @Czaki for important parts of this change.\n\n2.0.1\n\n- handled removal of normalize_name from pip.utils\n- handle packages with no files\n\n2.0 **renamed package to pip_check_reqs**\n\n- added tool pip-extra-reqs to find packages installed but not used\n  (contributed by Josh Hesketh)\n\n1.2.1\n\n- relax requirement to 6.0+\n\n1.2.0\n\n- bumped pip requirement to 6.0.8+\n- updated use of pip internals to match that version\n\n1.1.9\n\n- test fixes and cleanup\n- remove hard-coded simplejson debugging behaviour\n\n1.1.8\n\n- use os.path.realpath to avoid symlink craziness on debian/ubuntu\n\n1.1.7\n\n- tweak to debug output\n\n1.1.6\n\n- add debug (very verbose) run output\n\n1.1.5\n\n- add header to output to make it clearer when in a larger test run\n- fix tests and self-test\n\n1.1.4\n\n- add --version\n- remove debug print from released code lol\n\n1.1.3\n\n- fix program to generate exit code useful for testing\n\n1.1.2\n\n- corrected version of vendored search_packages_info() from pip\n- handle relative imports\n\n1.1.1\n\n- fixed handling of import from __future__\n- self-tested and added own requirements.txt\n- cleaned up usage to require a file or directory to scan (rather than\n  defaulting to \".\")\n- vendored code from pip 1.6dev which fixes bug in search_packages_info\n  until pip 1.6 is released\n\n1.1.0\n\n- implemented --ignore-module\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Find packages that should or should not be in requirements for a project",
    "version": "2.5.3",
    "project_urls": {
        "Homepage": "https://github.com/r1chardj0n3s/pip-check-reqs"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0756935014260012a97f470ebbe2be815ff653028c2efc3370051e33824d637f",
                "md5": "235940ffb2565a3281cdaf5d18f0be04",
                "sha256": "692239e91fb1fa91052abd0db2887825d2c34593f99a6244eeadb188692a122b"
            },
            "downloads": -1,
            "filename": "pip_check_reqs-2.5.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "235940ffb2565a3281cdaf5d18f0be04",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9.0",
            "size": 13538,
            "upload_time": "2023-09-12T12:27:51",
            "upload_time_iso_8601": "2023-09-12T12:27:51.719675Z",
            "url": "https://files.pythonhosted.org/packages/07/56/935014260012a97f470ebbe2be815ff653028c2efc3370051e33824d637f/pip_check_reqs-2.5.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "468d0dea2eff162944c72fb8b779c970828c7dc304843b4a4ef9bde217eb16ef",
                "md5": "69a0606a0f7652e649a98d63fb771311",
                "sha256": "0b7ef9dfd6efc691164d991c961047dbd74a8609e2eb3e33c09b58f85d6cfa09"
            },
            "downloads": -1,
            "filename": "pip_check_reqs-2.5.3.tar.gz",
            "has_sig": false,
            "md5_digest": "69a0606a0f7652e649a98d63fb771311",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9.0",
            "size": 19586,
            "upload_time": "2023-09-12T12:27:53",
            "upload_time_iso_8601": "2023-09-12T12:27:53.438102Z",
            "url": "https://files.pythonhosted.org/packages/46/8d/0dea2eff162944c72fb8b779c970828c7dc304843b4a4ef9bde217eb16ef/pip_check_reqs-2.5.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-12 12:27:53",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "r1chardj0n3s",
    "github_project": "pip-check-reqs",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "pip-check-reqs"
}
        
Elapsed time: 0.13299s