mirror of
https://github.com/bndr/pipreqs.git
synced 2025-06-06 03:25:21 +00:00
Merge pull request #171 from kanoonsantikul/feature/omit-version
support omit package output version
This commit is contained in:
commit
480ec3ab9a
@ -49,6 +49,7 @@ Usage
|
|||||||
--force Overwrite existing requirements.txt
|
--force Overwrite existing requirements.txt
|
||||||
--diff <file> Compare modules in requirements.txt to project imports.
|
--diff <file> Compare modules in requirements.txt to project imports.
|
||||||
--clean <file> Clean up requirements.txt by removing modules that are not imported in project.
|
--clean <file> Clean up requirements.txt by removing modules that are not imported in project.
|
||||||
|
--no-pin Omit version of output packages.
|
||||||
Example
|
Example
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@ Options:
|
|||||||
imports.
|
imports.
|
||||||
--clean <file> Clean up requirements.txt by removing modules
|
--clean <file> Clean up requirements.txt by removing modules
|
||||||
that are not imported in project.
|
that are not imported in project.
|
||||||
|
--no-pin Omit version of output packages.
|
||||||
"""
|
"""
|
||||||
from __future__ import print_function, absolute_import
|
from __future__ import print_function, absolute_import
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
@ -447,6 +448,9 @@ def init(args):
|
|||||||
"use --force to overwrite it")
|
"use --force to overwrite it")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if args.get('--no-pin'):
|
||||||
|
imports = [{'name': item["name"], 'version': ''} for item in imports]
|
||||||
|
|
||||||
if args["--print"]:
|
if args["--print"]:
|
||||||
output_requirements(imports)
|
output_requirements(imports)
|
||||||
logging.info("Successfully output requirements")
|
logging.info("Successfully output requirements")
|
||||||
|
@ -181,6 +181,24 @@ class TestPipreqs(unittest.TestCase):
|
|||||||
for item in ['click', 'getpass']:
|
for item in ['click', 'getpass']:
|
||||||
self.assertFalse(item.lower() in data)
|
self.assertFalse(item.lower() in data)
|
||||||
|
|
||||||
|
def test_omit_version(self):
|
||||||
|
"""
|
||||||
|
Test --no-pin parameter
|
||||||
|
"""
|
||||||
|
pipreqs.init(
|
||||||
|
{'<path>': self.project_with_ignore_directory, '--savepath': None, '--print': False,
|
||||||
|
'--use-local': None, '--force': True,
|
||||||
|
'--proxy': None,
|
||||||
|
'--pypi-server': None,
|
||||||
|
'--diff': None,
|
||||||
|
'--clean': None,
|
||||||
|
'--no-pin': True
|
||||||
|
}
|
||||||
|
)
|
||||||
|
with open(os.path.join(self.project_with_ignore_directory, "requirements.txt"), "r") as f:
|
||||||
|
data = f.read().lower()
|
||||||
|
for item in ['beautifulsoup4==4.8.1', 'boto==2.49.0']:
|
||||||
|
self.assertFalse(item.lower() in data)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user