mirror of
https://github.com/bndr/pipreqs.git
synced 2025-06-07 03:55:22 +00:00
Merge eb0276c3cb390976216c4a054d4b6769f67d53a7 into 90102acdbb23c09574d27df8bd1f568d34e0cfd3
This commit is contained in:
commit
898473aae7
@ -3,6 +3,11 @@
|
|||||||
History
|
History
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
0.4.9 (2018-03-14)
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
* Add to show imported but not declared requirements for '--diff' (spenly)
|
||||||
|
|
||||||
0.4.8 (2017-06-30)
|
0.4.8 (2017-06-30)
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
|
22
README.rst
22
README.rst
@ -4,27 +4,27 @@
|
|||||||
|
|
||||||
.. image:: https://img.shields.io/travis/bndr/pipreqs.svg
|
.. image:: https://img.shields.io/travis/bndr/pipreqs.svg
|
||||||
:target: https://travis-ci.org/bndr/pipreqs
|
:target: https://travis-ci.org/bndr/pipreqs
|
||||||
|
|
||||||
|
|
||||||
.. image:: https://img.shields.io/pypi/v/pipreqs.svg
|
.. image:: https://img.shields.io/pypi/v/pipreqs.svg
|
||||||
:target: https://pypi.python.org/pypi/pipreqs
|
:target: https://pypi.python.org/pypi/pipreqs
|
||||||
|
|
||||||
|
|
||||||
.. image:: https://img.shields.io/coveralls/bndr/pipreqs.svg
|
.. image:: https://img.shields.io/coveralls/bndr/pipreqs.svg
|
||||||
:target: https://coveralls.io/r/bndr/pipreqs
|
:target: https://coveralls.io/r/bndr/pipreqs
|
||||||
|
|
||||||
|
|
||||||
.. image:: https://img.shields.io/pypi/l/pipreqs.svg
|
.. image:: https://img.shields.io/pypi/l/pipreqs.svg
|
||||||
:target: https://pypi.python.org/pypi/pipreqs
|
:target: https://pypi.python.org/pypi/pipreqs
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Installation
|
Installation
|
||||||
------------
|
------------
|
||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
pip install pipreqs
|
pip install pipreqs-spenly
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
-----
|
-----
|
||||||
@ -65,10 +65,10 @@ Contents of requirements.txt
|
|||||||
wheel==0.23.0
|
wheel==0.23.0
|
||||||
Yarg==0.1.9
|
Yarg==0.1.9
|
||||||
docopt==0.6.2
|
docopt==0.6.2
|
||||||
|
|
||||||
Why not pip freeze?
|
Why not pip freeze?
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
- ``pip freeze`` only saves the packages that are installed with ``pip install`` in your environment.
|
- ``pip freeze`` only saves the packages that are installed with ``pip install`` in your environment.
|
||||||
- ``pip freeze`` saves all packages in the environment including those that you don't use in your current project. (if you don't have virtualenv)
|
- ``pip freeze`` saves all packages in the environment including those that you don't use in your current project. (if you don't have virtualenv)
|
||||||
- and sometimes you just need to create requirements.txt for a new project without installing modules.
|
- and sometimes you just need to create requirements.txt for a new project without installing modules.
|
||||||
|
@ -352,17 +352,26 @@ def compare_modules(file_, imports):
|
|||||||
imports = [imports[i]["name"] for i in range(len(imports))]
|
imports = [imports[i]["name"] for i in range(len(imports))]
|
||||||
modules = [modules[i]["name"] for i in range(len(modules))]
|
modules = [modules[i]["name"] for i in range(len(modules))]
|
||||||
modules_not_imported = set(modules) - set(imports)
|
modules_not_imported = set(modules) - set(imports)
|
||||||
|
modules_not_declared = set(imports) - set(modules)
|
||||||
return modules_not_imported
|
return modules_not_imported, modules_not_declared
|
||||||
|
|
||||||
|
|
||||||
def diff(file_, imports):
|
def diff(file_, imports):
|
||||||
"""Display the difference between modules in a file and imported modules.""" # NOQA
|
"""Display the difference between modules in a file and imported modules.""" # NOQA
|
||||||
modules_not_imported = compare_modules(file_, imports)
|
modules_not_imported, modules_not_declared = compare_modules(file_, imports)
|
||||||
|
if modules_not_imported:
|
||||||
|
logging.info(
|
||||||
|
"The following modules are in {} but do not seem to be imported: \n"
|
||||||
|
"{}".format(file_, ", ".join(x for x in modules_not_imported)))
|
||||||
|
else:
|
||||||
|
logging.info("No module is in {} but do not seem to be imported.".format(file_))
|
||||||
|
|
||||||
logging.info(
|
if modules_not_declared:
|
||||||
"The following modules are in {} but do not seem to be imported: "
|
logging.info(
|
||||||
"{}".format(file_, ", ".join(x for x in modules_not_imported)))
|
"The following modules are not in {} but seem to be imported: \n"
|
||||||
|
"{}".format(file_, ", ".join(x for x in modules_not_declared)))
|
||||||
|
else:
|
||||||
|
logging.info("No module is not in {} but seem to be imported:.".format(file_))
|
||||||
|
|
||||||
|
|
||||||
def clean(file_, imports):
|
def clean(file_, imports):
|
||||||
|
2
setup.py
2
setup.py
@ -21,7 +21,7 @@ requirements = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='pipreqs',
|
name='pipreqs-spenly',
|
||||||
version=__version__,
|
version=__version__,
|
||||||
description='Pip requirements.txt generator based on imports in project',
|
description='Pip requirements.txt generator based on imports in project',
|
||||||
long_description=readme + '\n\n' + history,
|
long_description=readme + '\n\n' + history,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user