From c9ede252a3ac463e8d8a1c13f4e37294260ce6ae Mon Sep 17 00:00:00 2001 From: hueseyincelik <104273133+hueseyincelik@users.noreply.github.com> Date: Sat, 26 Nov 2022 22:22:36 +0100 Subject: [PATCH 1/3] implement --freeze-outdated-packages argument --- pip_review/__main__.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/pip_review/__main__.py b/pip_review/__main__.py index 5347ae359..da2ebb028 100755 --- a/pip_review/__main__.py +++ b/pip_review/__main__.py @@ -83,6 +83,9 @@ def parse_args(): parser.add_argument( '--continue-on-fail', '-C', action='store_true', default=False, help='Continue with other installs when one fails') + parser.add_argument( + '--freeze-outdated-packages', '-f', action='store_true', default=False, + help='Freeze all outdated packages to "requirements.txt" before upgrading them') return parser.parse_known_args() @@ -166,8 +169,14 @@ def ask(self, prompt): ask_to_install = partial(InteractiveAsker().ask, prompt='Upgrade now?') -def update_packages(packages, forwarded, continue_on_fail): +def update_packages(packages, forwarded, continue_on_fail, freeze_outdated_packages): upgrade_cmd = pip_cmd() + ['install', '-U'] + forwarded + + if freeze_outdated_packages: + with open('requirements.txt', 'w') as f: + for pkg in packages: + f.write('{0}=={1}\n'.format(pkg['name'], pkg['version'])) + if not continue_on_fail: upgrade_cmd += ['{0}'.format(pkg['name']) for pkg in packages] subprocess.call(upgrade_cmd, stdout=sys.stdout, stderr=sys.stderr) @@ -232,7 +241,7 @@ def main(): if not outdated and not args.raw: logger.info('Everything up-to-date') elif args.auto: - update_packages(outdated, install_args, args.continue_on_fail) + update_packages(outdated, install_args, args.continue_on_fail, args.freeze_outdated_packages) elif args.raw: for pkg in outdated: logger.info('{0}=={1}'.format(pkg['name'], pkg['latest_version'])) @@ -247,7 +256,7 @@ def main(): if answer in ['y', 'a']: selected.append(pkg) if selected: - update_packages(selected, install_args, args.continue_on_fail) + update_packages(selected, install_args, args.continue_on_fail, args.freeze_outdated_packages) if __name__ == '__main__': From f26dacb182f3be77747e263ac40340aaa57427e2 Mon Sep 17 00:00:00 2001 From: hueseyincelik <104273133+hueseyincelik@users.noreply.github.com> Date: Sun, 27 Nov 2022 21:59:22 +0100 Subject: [PATCH 2/3] remove -f short argument --- pip_review/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pip_review/__main__.py b/pip_review/__main__.py index da2ebb028..0992aa0d4 100755 --- a/pip_review/__main__.py +++ b/pip_review/__main__.py @@ -84,7 +84,7 @@ def parse_args(): '--continue-on-fail', '-C', action='store_true', default=False, help='Continue with other installs when one fails') parser.add_argument( - '--freeze-outdated-packages', '-f', action='store_true', default=False, + '--freeze-outdated-packages', action='store_true', default=False, help='Freeze all outdated packages to "requirements.txt" before upgrading them') return parser.parse_known_args() From f44d055790c7800d9fb88f6d7567cca4b1b0f28e Mon Sep 17 00:00:00 2001 From: Julian Gonggrijp Date: Tue, 29 Nov 2022 17:31:22 +0100 Subject: [PATCH 3/3] Bump the version to 1.3.0 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 23e0c648b..b698f3e8f 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setup( name='pip-review', - version='1.2.0', + version='1.3.0', url='https://github.com/jgonggrijp/pip-review', license='BSD', author='Julian Gonggrijp, Vincent Driessen',