From a7ad636dab4930e83487055e3a73571e65652848 Mon Sep 17 00:00:00 2001 From: yonatanp Date: Fri, 5 Jan 2018 11:33:47 +0200 Subject: [PATCH 01/16] bugfix: f.close() only required if open succeeded when open fails, instead of raising the original error, the "f.close()" was erroring in the final clause. --- pipreqs/pipreqs.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/pipreqs/pipreqs.py b/pipreqs/pipreqs.py index 0186832..36b0c42 100755 --- a/pipreqs/pipreqs.py +++ b/pipreqs/pipreqs.py @@ -309,9 +309,10 @@ def parse_requirements(file_): logging.error("Failed on file: {}".format(file_)) raise else: - data = [x.strip() for x in f.readlines() if x != "\n"] - finally: - f.close() + try: + data = [x.strip() for x in f.readlines() if x != "\n"] + finally: + f.close() data = [x for x in data if x[0].isalpha()] @@ -375,16 +376,17 @@ def clean(file_, imports): logging.error("Failed on file: {}".format(file_)) raise else: - for i in f.readlines(): - if re_remove.match(i) is None: - to_write.append(i) - f.seek(0) - f.truncate() + try: + for i in f.readlines(): + if re_remove.match(i) is None: + to_write.append(i) + f.seek(0) + f.truncate() - for i in to_write: - f.write(i) - finally: - f.close() + for i in to_write: + f.write(i) + finally: + f.close() logging.info("Successfully cleaned up requirements in " + file_) From 3daaebfa17a266cbe14870c55079ed612f56de68 Mon Sep 17 00:00:00 2001 From: Andrew Vant Date: Tue, 20 Nov 2018 15:20:12 -0500 Subject: [PATCH 02/16] Add patricia-trie mapping For this package: https://pypi.org/project/patricia-trie/. Old, but I think it's the only pure-python trie implementation on pypi. --- pipreqs/mapping | 1 + 1 file changed, 1 insertion(+) diff --git a/pipreqs/mapping b/pipreqs/mapping index 4c72ea8..77eddaa 100644 --- a/pipreqs/mapping +++ b/pipreqs/mapping @@ -822,6 +822,7 @@ past:future paste:PasteScript path:forked_path path:path.py +patricia:patricia-trie paver:Paver peak:ProxyTypes picasso:anderson.picasso From 8cc70869b0fff5f4aedea4017b2d0520ad1ec5fa Mon Sep 17 00:00:00 2001 From: Aymon Fournier Date: Mon, 28 Jan 2019 17:51:33 -0500 Subject: [PATCH 03/16] deduped, sorted, and added typing package to standard library file --- pipreqs/stdlib | 707 +++++-------------------------------------------- 1 file changed, 62 insertions(+), 645 deletions(-) diff --git a/pipreqs/stdlib b/pipreqs/stdlib index 71edcc8..dc8a799 100644 --- a/pipreqs/stdlib +++ b/pipreqs/stdlib @@ -1,6 +1,8 @@ __builtin__ __future__ __main__ +_dummy_thread +_thread _winreg abc aepack @@ -15,6 +17,7 @@ argparse array ast asynchat +asyncio asyncore atexit audioop @@ -28,6 +31,7 @@ binhex bisect bsddb buildtools +builtins bz2 calendar Carbon @@ -101,6 +105,7 @@ code codecs codeop collections +collections.abc ColorPicker colorsys commands @@ -108,12 +113,16 @@ compileall compiler compiler.ast compiler.visitor +concurrent +concurrent.futures ConfigParser +configparser contextlib Cookie cookielib copy copy_reg +copyreg cPickle cProfile crypt @@ -127,6 +136,9 @@ curses.textpad datetime dbhash dbm +dbm.dumb +dbm.gnu +dbm.ndbm decimal DEVICE difflib @@ -188,21 +200,27 @@ dummy_threading EasyDialogs email email.charset +email.contentmanager email.encoders email.errors email.generator email.header +email.headerregistry email.iterators email.message email.mime email.parser +email.policy email.utils encodings encodings.idna +encodings.mbcs encodings.utf_8_sig ensurepip +enum errno exceptions +faulthandler fcntl filecmp fileinput @@ -226,8 +244,8 @@ gensuitemodule getopt getpass gettext -gl GL +gl glob grp gzip @@ -236,9 +254,17 @@ heapq hmac hotshot hotshot.stats +html +html.entities +html.parser htmlentitydefs htmllib HTMLParser +http +http.client +http.cookiejar +http.cookies +http.server httplib ic icopen @@ -248,12 +274,17 @@ imgfile imghdr imp importlib +importlib.abc +importlib.machinery +importlib.util imputil inspect io +ipaddress itertools jpeg json +json.tool keyword lib2to3 linecache @@ -261,6 +292,7 @@ locale logging logging.config logging.handlers +lzma macerrors MacOS macostools @@ -301,6 +333,7 @@ os os.path ossaudiodev parser +pathlib pdb pickle pickletools @@ -322,10 +355,12 @@ py_compile pyclbr pydoc Queue +queue quopri random re readline +reprlib resource rexec rfc822 @@ -335,6 +370,7 @@ runpy sched ScrolledText select +selectors sets sgmllib sha @@ -350,10 +386,12 @@ smtplib sndhdr socket SocketServer +socketserver spwd sqlite3 ssl stat +statistics statvfs string StringIO @@ -361,8 +399,8 @@ stringprep struct subprocess sunau -sunaudiodev SUNAUDIODEV +sunaudiodev symbol symtable sys @@ -374,6 +412,7 @@ telnetlib tempfile termios test +test.support test.test_support textwrap thread @@ -382,17 +421,30 @@ time timeit Tix Tkinter +tkinter +tkinter.scrolledtext +tkinter.tix +tkinter.ttk token tokenize trace traceback +tracemalloc ttk tty turtle +turtledemo types +typing unicodedata unittest +unittest.mock urllib +urllib.error +urllib.parse +urllib.request +urllib.response +urllib.robotparser urllib2 urlparse user @@ -401,6 +453,7 @@ UserList UserString uu uuid +venv videoreader W warnings @@ -408,6 +461,7 @@ wave weakref webbrowser whichdb +winreg winsound wsgiref wsgiref.handlers @@ -422,654 +476,17 @@ xml.dom.minidom xml.dom.pulldom xml.etree.ElementTree xml.parsers.expat +xml.parsers.expat.errors +xml.parsers.expat.model xml.sax xml.sax.handler xml.sax.saxutils xml.sax.xmlreader +xmlrpc +xmlrpc.client +xmlrpc.server xmlrpclib -zipfile -zipimport -zlib -__future__ -__main__ -_dummy_thread -_thread -abc -aifc -argparse -array -ast -asynchat -asyncio -asyncore -atexit -audioop -base64 -bdb -binascii -binhex -bisect -builtins -bz2 -calendar -cgi -cgitb -chunk -cmath -cmd -code -codecs -codeop -collections -collections.abc -colorsys -compileall -concurrent -concurrent.futures -configparser -contextlib -copy -copyreg -cProfile -crypt -csv -ctypes -curses -curses.ascii -curses.panel -curses.textpad -datetime -dbm -dbm.dumb -dbm.gnu -dbm.ndbm -decimal -difflib -dis -distutils -distutils.archive_util -distutils.bcppcompiler -distutils.ccompiler -distutils.cmd -distutils.command -distutils.command.bdist -distutils.command.bdist_dumb -distutils.command.bdist_msi -distutils.command.bdist_packager -distutils.command.bdist_rpm -distutils.command.bdist_wininst -distutils.command.build -distutils.command.build_clib -distutils.command.build_ext -distutils.command.build_py -distutils.command.build_scripts -distutils.command.check -distutils.command.clean -distutils.command.config -distutils.command.install -distutils.command.install_data -distutils.command.install_headers -distutils.command.install_lib -distutils.command.install_scripts -distutils.command.register -distutils.command.sdist -distutils.core -distutils.cygwinccompiler -distutils.debug -distutils.dep_util -distutils.dir_util -distutils.dist -distutils.errors -distutils.extension -distutils.fancy_getopt -distutils.file_util -distutils.filelist -distutils.log -distutils.msvccompiler -distutils.spawn -distutils.sysconfig -distutils.text_file -distutils.unixccompiler -distutils.util -distutils.version -doctest -dummy_threading -email -email.charset -email.contentmanager -email.encoders -email.errors -email.generator -email.header -email.headerregistry -email.iterators -email.message -email.mime -email.parser -email.policy -email.utils -encodings -encodings.idna -encodings.mbcs -encodings.utf_8_sig -ensurepip -enum -errno -faulthandler -fcntl -filecmp -fileinput -fnmatch -formatter -fpectl -fractions -ftplib -functools -gc -getopt -getpass -gettext -glob -grp -gzip -hashlib -heapq -hmac -html -html.entities -html.parser -http -http.client -http.cookiejar -http.cookies -http.server -imaplib -imghdr -imp -importlib -importlib.abc -importlib.machinery -importlib.util -inspect -io -ipaddress -itertools -json -keyword -lib2to3 -linecache -locale -logging -logging.config -logging.handlers -lzma -macpath -mailbox -mailcap -marshal -math -mimetypes -mmap -modulefinder -msilib -msvcrt -multiprocessing -multiprocessing.connection -multiprocessing.dummy -multiprocessing.managers -multiprocessing.pool -multiprocessing.sharedctypes -netrc -nis -nntplib -numbers -operator -optparse -os -os.path -ossaudiodev -parser -pathlib -pdb -pickle -pickletools -pipes -pkgutil -platform -plistlib -poplib -posix -pprint -profile -pstats -pty -pwd -py_compile -pyclbr -pydoc -queue -quopri -random -re -readline -reprlib -resource -rlcompleter -runpy -sched -select -selectors -shelve -shlex -shutil -signal -site -smtpd -smtplib -sndhdr -socket -socketserver -spwd -sqlite3 -ssl -stat -statistics -string -stringprep -struct -subprocess -sunau -symbol -symtable -sys -sysconfig -syslog -tabnanny -tarfile -telnetlib -tempfile -termios -test -test.support -textwrap -threading -time -timeit -tkinter -tkinter.scrolledtext -tkinter.tix -tkinter.ttk -token -tokenize -trace -traceback -tracemalloc -tty -turtle -turtledemo -types -unicodedata -unittest -unittest.mock -urllib -urllib.error -urllib.parse -urllib.request -urllib.response -urllib.robotparser -uu -uuid -venv -warnings -wave -weakref -webbrowser -winreg -winsound -wsgiref -wsgiref.handlers -wsgiref.headers -wsgiref.simple_server -wsgiref.util -wsgiref.validate -xdrlib -xml -xml.dom -xml.dom.minidom -xml.dom.pulldom -xml.etree.ElementTree -xml.parsers.expat -xml.parsers.expat.errors -xml.parsers.expat.model -xml.sax -xml.sax.handler -xml.sax.saxutils -xml.sax.xmlreader -xmlrpc -xmlrpc.client -xmlrpc.server -zipfile -zipimport -zlib -__future__ -__main__ -_dummy_thread -_thread -abc -aifc -argparse -array -ast -asynchat -asyncio -asyncore -atexit -audioop -base64 -bdb -binascii -binhex -bisect -builtins -bz2 -calendar -cgi -cgitb -chunk -cmath -cmd -code -codecs -codeop -collections -collections.abc -colorsys -compileall -concurrent -concurrent.futures -configparser -contextlib -copy -copyreg -cProfile -crypt -csv -ctypes -curses -curses.ascii -curses.panel -curses.textpad -datetime -dbm -dbm.dumb -dbm.gnu -dbm.ndbm -decimal -difflib -dis -distutils -distutils.archive_util -distutils.bcppcompiler -distutils.ccompiler -distutils.cmd -distutils.command -distutils.command.bdist -distutils.command.bdist_dumb -distutils.command.bdist_msi -distutils.command.bdist_packager -distutils.command.bdist_rpm -distutils.command.bdist_wininst -distutils.command.build -distutils.command.build_clib -distutils.command.build_ext -distutils.command.build_py -distutils.command.build_scripts -distutils.command.check -distutils.command.clean -distutils.command.config -distutils.command.install -distutils.command.install_data -distutils.command.install_headers -distutils.command.install_lib -distutils.command.install_scripts -distutils.command.register -distutils.command.sdist -distutils.core -distutils.cygwinccompiler -distutils.debug -distutils.dep_util -distutils.dir_util -distutils.dist -distutils.errors -distutils.extension -distutils.fancy_getopt -distutils.file_util -distutils.filelist -distutils.log -distutils.msvccompiler -distutils.spawn -distutils.sysconfig -distutils.text_file -distutils.unixccompiler -distutils.util -distutils.version -doctest -dummy_threading -email -email.charset -email.contentmanager -email.encoders -email.errors -email.generator -email.header -email.headerregistry -email.iterators -email.message -email.mime -email.parser -email.policy -email.utils -encodings -encodings.idna -encodings.mbcs -encodings.utf_8_sig -ensurepip -enum -errno -faulthandler -fcntl -filecmp -fileinput -fnmatch -formatter -fpectl -fractions -ftplib -functools -gc -getopt -getpass -gettext -glob -grp -gzip -hashlib -heapq -hmac -html -html.entities -html.parser -http -http.client -http.cookiejar -http.cookies -http.server -imaplib -imghdr -imp -importlib -importlib.abc -importlib.machinery -importlib.util -inspect -io -ipaddress -itertools -json -json.tool -keyword -lib2to3 -linecache -locale -logging -logging.config -logging.handlers -lzma -macpath -mailbox -mailcap -marshal -math -mimetypes -mmap -modulefinder -msilib -msvcrt -multiprocessing -multiprocessing.connection -multiprocessing.dummy -multiprocessing.managers -multiprocessing.pool -multiprocessing.sharedctypes -netrc -nis -nntplib -numbers -operator -optparse -os -os.path -ossaudiodev -parser -pathlib -pdb -pickle -pickletools -pipes -pkgutil -platform -plistlib -poplib -posix -pprint -profile -pstats -pty -pwd -py_compile -pyclbr -pydoc -queue -quopri -random -re -readline -reprlib -resource -rlcompleter -runpy -sched -select -selectors -shelve -shlex -shutil -signal -site -smtpd -smtplib -sndhdr -socket -socketserver -spwd -sqlite3 -ssl -stat -statistics -string -stringprep -struct -subprocess -sunau -symbol -symtable -sys -sysconfig -syslog -tabnanny -tarfile -telnetlib -tempfile -termios -test -test.support -textwrap -threading -time -timeit -tkinter -tkinter.scrolledtext -tkinter.tix -tkinter.ttk -token -tokenize -trace -traceback -tracemalloc -tty -turtle -turtledemo -types -unicodedata -unittest -unittest.mock -urllib -urllib.error -urllib.parse -urllib.request -urllib.response -urllib.robotparser -uu -uuid -venv -warnings -wave -weakref -webbrowser -winreg -winsound -wsgiref -wsgiref.handlers -wsgiref.headers -wsgiref.simple_server -wsgiref.util -wsgiref.validate -xdrlib -xml -xml.dom -xml.dom.minidom -xml.dom.pulldom -xml.etree.ElementTree -xml.parsers.expat -xml.parsers.expat.errors -xml.parsers.expat.model -xml.sax -xml.sax.handler -xml.sax.saxutils -xml.sax.xmlreader -xmlrpc -xmlrpc.client -xmlrpc.server +yp zipapp zipfile zipimport From 21cac5723baacd3b3c113ba4d638167775e25c86 Mon Sep 17 00:00:00 2001 From: Radon Rosborough Date: Fri, 2 Aug 2019 14:30:48 -0700 Subject: [PATCH 04/16] Add mappings for PySynth and slackclient --- pipreqs/mapping | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/pipreqs/mapping b/pipreqs/mapping index 4c72ea8..b73f645 100644 --- a/pipreqs/mapping +++ b/pipreqs/mapping @@ -580,10 +580,11 @@ daemon:python_daemon dare:DARE dateutil:python_dateutil dawg:DAWG -decouple:python-decouple deb822:python_debian debian:python_debian +decouple:python-decouple demo:webunit +demosongs:PySynth deployer:juju_deployer depot:filedepot devtools:tg.devtools @@ -772,6 +773,8 @@ mimeparse:python_mimeparse minitage:minitage.paste minitage:minitage.recipe.common missingdrawables:android_missingdrawables +mixfiles:PySynth +mkfreq:PySynth mkrst_themes:2lazy2rest mockredis:mockredispy modargs:python_modargs @@ -828,6 +831,7 @@ picasso:anderson.picasso picklefield:django-picklefield pilot:BigJob pivotal:pivotal_py +play_wav:PySynth playhouse:peewee plivoxml:plivo plone:plone.alterego @@ -949,6 +953,14 @@ pyrimaa:AEI pysideuic:PySide pysqlite2:adhocracy_pysqlite pysqlite2:pysqlite +pysynth_b:PySynth +pysynth_beeper:PySynth +pysynth_c:PySynth +pysynth_d:PySynth +pysynth_e:PySynth +pysynth_p:PySynth +pysynth_s:PySynth +pysynth_samp:PySynth pythongettext:python_gettext pythonjsonlogger:python_json_logger pyutilib:PyUtilib @@ -1006,6 +1018,7 @@ singleton:pysingleton sittercommon:cerebrod skbio:scikit_bio sklearn:scikit_learn +slack:slackclient slugify:unicode_slugify smarkets:smk_python_sdk snappy:ctypes_snappy From 1753e1ff41d67be949221baf4a3920bb89f7e096 Mon Sep 17 00:00:00 2001 From: Radon Rosborough Date: Thu, 8 Aug 2019 11:16:10 -0700 Subject: [PATCH 05/16] Fix mappings for python-mpv and portalocker --- pipreqs/mapping | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipreqs/mapping b/pipreqs/mapping index 4c72ea8..b955b3e 100644 --- a/pipreqs/mapping +++ b/pipreqs/mapping @@ -787,6 +787,7 @@ monthdelta:MonthDelta mopidy:Mopidy mopytools:MoPyTools mptt:django_mptt +mpv:python-mpv mrbob:mr.bob msgpack:msgpack_python mutations:aino_mutations @@ -911,7 +912,6 @@ plone:plone.z3cform plonetheme:plonetheme.barceloneta png:pypng polymorphic:django_polymorphic -portalocker:ConcurrentLogHandler postmark:python_postmark powerprompt:bash_powerprompt prefetch:django-prefetch From 443d9e595b7e73d3bdf594df0b850c3bcf873db1 Mon Sep 17 00:00:00 2001 From: Radon Rosborough Date: Thu, 8 Aug 2019 11:24:17 -0700 Subject: [PATCH 06/16] Add setuptools to stdlib --- pipreqs/stdlib | 1 + 1 file changed, 1 insertion(+) diff --git a/pipreqs/stdlib b/pipreqs/stdlib index 71edcc8..c8961ce 100644 --- a/pipreqs/stdlib +++ b/pipreqs/stdlib @@ -336,6 +336,7 @@ sched ScrolledText select sets +setuptools sgmllib sha shelve From d0d9fe58e2f2001e58e1ade07aa898cea8d89bc9 Mon Sep 17 00:00:00 2001 From: Radon Rosborough Date: Thu, 8 Aug 2019 14:51:27 -0700 Subject: [PATCH 07/16] Also add pkg_resources --- pipreqs/stdlib | 1 + 1 file changed, 1 insertion(+) diff --git a/pipreqs/stdlib b/pipreqs/stdlib index c8961ce..faa8a2a 100644 --- a/pipreqs/stdlib +++ b/pipreqs/stdlib @@ -306,6 +306,7 @@ pickle pickletools pipes PixMapWrapper +pkg_resources pkgutil platform plistlib From 71fc2dc90c9f494b8d474c94fba34e95ded61151 Mon Sep 17 00:00:00 2001 From: Niti Santikul Date: Mon, 21 Oct 2019 00:53:03 +0700 Subject: [PATCH 08/16] support omit package output version --- README.rst | 1 + pipreqs/pipreqs.py | 4 ++++ tests/test_pipreqs.py | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/README.rst b/README.rst index b6cbd30..139fa7d 100644 --- a/README.rst +++ b/README.rst @@ -49,6 +49,7 @@ Usage --force Overwrite existing requirements.txt --diff Compare modules in requirements.txt to project imports. --clean Clean up requirements.txt by removing modules that are not imported in project. + --no-pin Omit version of output packages. Example ------- diff --git a/pipreqs/pipreqs.py b/pipreqs/pipreqs.py index 4e7b39f..b921d6e 100755 --- a/pipreqs/pipreqs.py +++ b/pipreqs/pipreqs.py @@ -31,6 +31,7 @@ Options: imports. --clean Clean up requirements.txt by removing modules that are not imported in project. + --no-pin Omit version of output packages. """ from __future__ import print_function, absolute_import from contextlib import contextmanager @@ -447,6 +448,9 @@ def init(args): "use --force to overwrite it") return + if args.get('--no-pin'): + imports = [{'name': item["name"], 'version': ''} for item in imports] + if args["--print"]: output_requirements(imports) logging.info("Successfully output requirements") diff --git a/tests/test_pipreqs.py b/tests/test_pipreqs.py index a020fab..dcd75c5 100755 --- a/tests/test_pipreqs.py +++ b/tests/test_pipreqs.py @@ -181,6 +181,24 @@ class TestPipreqs(unittest.TestCase): for item in ['click', 'getpass']: self.assertFalse(item.lower() in data) + def test_omit_version(self): + """ + Test --no-pin parameter + """ + pipreqs.init( + {'': 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): """ From a11aa924b324083a98b0553f22ad4873f3369c9e Mon Sep 17 00:00:00 2001 From: Pat Myron Date: Sun, 3 Nov 2019 11:22:32 -0800 Subject: [PATCH 09/16] mapping cfn-lint https://github.com/aws-cloudformation/cfn-python-lint/ --- pipreqs/mapping | 1 + 1 file changed, 1 insertion(+) diff --git a/pipreqs/mapping b/pipreqs/mapping index 4c72ea8..1e0f6c0 100644 --- a/pipreqs/mapping +++ b/pipreqs/mapping @@ -536,6 +536,7 @@ cassandra:cassandra_driver cassandralauncher:CassandraLauncher cc42:42qucc cerberus:Cerberus +cfnlint:cfn-lint chameleon:Chameleon charmtools:charm_tools chef:PyChef From 7b2b5e9e5880cde1922c0b9c7ac238247f3850f4 Mon Sep 17 00:00:00 2001 From: Pat Myron Date: Tue, 21 Apr 2020 11:17:49 -0700 Subject: [PATCH 10/16] mapping aws-sam-translator https://pypi.org/project/aws-sam-translator/ https://github.com/awslabs/serverless-application-model --- pipreqs/mapping | 1 + 1 file changed, 1 insertion(+) diff --git a/pipreqs/mapping b/pipreqs/mapping index 6f5a469..26b83cb 100644 --- a/pipreqs/mapping +++ b/pipreqs/mapping @@ -999,6 +999,7 @@ ruamel:ruamel.base s2repoze:pysaml2 saga:saga_python saml2:pysaml2 +samtranslator:aws-sam-translator sass:libsass sassc:libsass sasstests:libsass From 3f06f4375a0ac37a6ffb46edabdfa51aa16f0d11 Mon Sep 17 00:00:00 2001 From: Jon Banafato Date: Mon, 18 May 2020 19:21:05 -0400 Subject: [PATCH 11/16] Fix flake8 error for latest release --- pipreqs/pipreqs.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pipreqs/pipreqs.py b/pipreqs/pipreqs.py index 4b817c3..57147e2 100755 --- a/pipreqs/pipreqs.py +++ b/pipreqs/pipreqs.py @@ -157,8 +157,8 @@ def get_all_imports( return list(packages - data) -def filter_line(l): - return len(l) > 0 and l[0] != "#" +def filter_line(line): + return len(line) > 0 and line[0] != "#" def generate_requirements_file(path, imports): From fc720f18bb5e1689d05ae4f83f4bfef5d173e704 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Singh Date: Thu, 10 Oct 2019 18:34:59 +0530 Subject: [PATCH 12/16] Fixed#133 Sorted `imports` based on `lowercase` package's `name`, similar to `pip freeze`. --- pipreqs/pipreqs.py | 2 ++ tests/test_pipreqs.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/pipreqs/pipreqs.py b/pipreqs/pipreqs.py index 57147e2..42a4e45 100755 --- a/pipreqs/pipreqs.py +++ b/pipreqs/pipreqs.py @@ -430,6 +430,8 @@ def init(args): imports = local + get_imports_info(difference, proxy=proxy, pypi_server=pypi_server) + # sort imports based on lowercase name of package, similar to `pip freeze`. + imports = sorted(imports, key=lambda x: x['name'].lower()) path = (args["--savepath"] if args["--savepath"] else os.path.join(input_path, "requirements.txt")) diff --git a/tests/test_pipreqs.py b/tests/test_pipreqs.py index dcd75c5..68f7249 100755 --- a/tests/test_pipreqs.py +++ b/tests/test_pipreqs.py @@ -99,6 +99,9 @@ class TestPipreqs(unittest.TestCase): data = f.read().lower() for item in self.modules[:-3]: self.assertTrue(item.lower() in data) + # It should be sorted based on names. + data = data.strip().split('\n') + self.assertEqual(data, sorted(data)) def test_init_local_only(self): """ From bd88dd85cdfc647dcfa6ba1fb234ed80a03b5ded Mon Sep 17 00:00:00 2001 From: Ben Bodenmiller Date: Thu, 9 Jul 2020 16:11:56 -0700 Subject: [PATCH 13/16] Tweak formatting --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 139fa7d..2a33b60 100644 --- a/README.rst +++ b/README.rst @@ -70,5 +70,5 @@ Why not pip freeze? ------------------- - ``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) -- and sometimes you just need to create requirements.txt for a new project without installing modules. +- ``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. From 30d8fab76c41b79652b1b7632c7041fe60339c94 Mon Sep 17 00:00:00 2001 From: John Kruper <36000@users.noreply.github.com> Date: Tue, 10 Nov 2020 10:27:02 -0800 Subject: [PATCH 14/16] Add pyAFQ Mapping --- pipreqs/mapping | 1 + 1 file changed, 1 insertion(+) diff --git a/pipreqs/mapping b/pipreqs/mapping index 6f5a469..77c2ed0 100644 --- a/pipreqs/mapping +++ b/pipreqs/mapping @@ -1,3 +1,4 @@ +AFQ:pyAFQ AG_fft_tools:agpy ANSI:pexpect Adafruit:Adafruit_Libraries From 469baefc1e7219c02f1dfe343e5a3bfbc66603c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Kalemba?= <5924586+pkalemba@users.noreply.github.com> Date: Thu, 10 Dec 2020 10:04:17 +0100 Subject: [PATCH 15/16] Add discord mapping Map discord to discord.py --- pipreqs/mapping | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pipreqs/mapping b/pipreqs/mapping index 6f5a469..e4be845 100644 --- a/pipreqs/mapping +++ b/pipreqs/mapping @@ -22,6 +22,7 @@ Kittens:astro_kittens Levenshtein:python_Levenshtein Lifetime:Zope2 MethodObject:ExtensionClass +MySQL-python:MySQLdb OFS:Zope2 OpenGL:PyOpenGL OpenSSL:pyOpenSSL @@ -592,6 +593,7 @@ devtools:tg.devtools dgis:2gis dhtmlparser:pyDHTMLParser digitalocean:python_digitalocean +discord:discord.py distribute_setup:ez_setup distutils2:Distutils2 django:Django @@ -701,7 +703,6 @@ html:pies2overrides htmloutput:nosehtmloutput http:pies2overrides hvad:django_hvad -krbV:krbv i99fix:199Fix igraph:python_igraph imdb:IMDbPY @@ -727,6 +728,7 @@ keyczar:python_keyczar keyedcache:django_keyedcache keystoneclient:python_keystoneclient kickstarter:kickstart +krbV:krbv kss:kss.core kuyruk:Kuyruk langconv:AdvancedLangConv @@ -798,7 +800,6 @@ msgpack:msgpack_python mutations:aino_mutations mws:amazon_mws mysql:mysql_connector_repackaged -MySQL-python:MySQLdb native_tags:django_native_tags ndg:ndg_httpsclient nereid:trytond_nereid From bcd0be47d0f90e9cf47ed8d19392e56817fc220f Mon Sep 17 00:00:00 2001 From: SwiftWinds <12981958+SwiftWinds@users.noreply.github.com> Date: Sat, 13 Mar 2021 14:46:02 -0800 Subject: [PATCH 16/16] Add PyFunctional mapping Maps `functional` to `pyfunctional`. Fixes #232. --- pipreqs/mapping | 1 + 1 file changed, 1 insertion(+) diff --git a/pipreqs/mapping b/pipreqs/mapping index 6f5a469..7eb67dc 100644 --- a/pipreqs/mapping +++ b/pipreqs/mapping @@ -13,6 +13,7 @@ Crypto:pycryptodome Cryptodome:pycryptodomex FSM:pexpect FiftyOneDegrees:51degrees_mobile_detector_v3_wrapper +functional:pyfunctional GeoBaseMain:GeoBasesDev GeoBases:GeoBasesDev Globals:Zope2