From a7143d564937b1a44a5730f4a12e36b4198f84ae Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 1 Jun 2017 16:16:04 +0200 Subject: [PATCH] Revert "Update recompile_requirements for newer pips" This reverts commit 8afc215c3d299140e0b5f50b1c638987a36c59f9. Since setuptools 36, it now vendors its dependencies again, as the vendoring has lead to various issues. --- scripts/dev/recompile_requirements.py | 50 +++++++-------------------- 1 file changed, 12 insertions(+), 38 deletions(-) diff --git a/scripts/dev/recompile_requirements.py b/scripts/dev/recompile_requirements.py index 52351de56..41cf22250 100644 --- a/scripts/dev/recompile_requirements.py +++ b/scripts/dev/recompile_requirements.py @@ -60,20 +60,6 @@ def convert_line(line, comments): return line -def get_requirements(requirements_file, exclude=()): - """Get the requirements after freezing with the given file.""" - with tempfile.TemporaryDirectory() as tmpdir: - pip_bin = os.path.join(tmpdir, 'bin', 'pip') - subprocess.check_call(['virtualenv', tmpdir]) - if requirements_file is not None: - subprocess.check_call([pip_bin, 'install', '-r', - requirements_file]) - out = subprocess.check_output([pip_bin, 'freeze', '--all'], - universal_newlines=True) - - return [line for line in out.splitlines() if line not in exclude] - - def read_comments(fobj): """Find special comments in the config. @@ -113,47 +99,35 @@ def get_all_names(): for filename in glob.glob(os.path.join(REQ_DIR, 'requirements-*.txt-raw')): basename = os.path.basename(filename) yield basename[len('requirements-'):-len('.txt-raw')] - yield 'pip' def main(): """Re-compile the given (or all) requirement files.""" - names = sys.argv[1:] if len(sys.argv) > 1 else sorted(get_all_names()) - - utils.print_title('pip') - pip_requirements = get_requirements(None) + names = sys.argv[1:] if len(sys.argv) > 1 else get_all_names() for name in names: utils.print_title(name) - + filename = os.path.join(REQ_DIR, + 'requirements-{}.txt-raw'.format(name)) if name == 'qutebrowser': outfile = os.path.join(REPO_DIR, 'requirements.txt') else: outfile = os.path.join(REQ_DIR, 'requirements-{}.txt'.format(name)) - if name == 'pip': - requirements = [req for req in pip_requirements - if not req.startswith('pip==')] - comments = { - 'filter': {}, - 'comment': {}, - 'ignore': [], - 'replace': {}, - } - else: - filename = os.path.join(REQ_DIR, - 'requirements-{}.txt-raw'.format(name)) - requirements = get_requirements(filename, exclude=pip_requirements) + with tempfile.TemporaryDirectory() as tmpdir: + pip_bin = os.path.join(tmpdir, 'bin', 'pip') + subprocess.check_call(['virtualenv', tmpdir]) + subprocess.check_call([pip_bin, 'install', '-r', filename]) + reqs = subprocess.check_output([pip_bin, 'freeze']).decode('utf-8') - with open(filename, 'r', encoding='utf-8') as f: - comments = read_comments(f) + with open(filename, 'r', encoding='utf-8') as f: + comments = read_comments(f) with open(outfile, 'w', encoding='utf-8') as f: f.write("# This file is automatically generated by " "scripts/dev/recompile_requirements.py\n\n") - for line in requirements: - converted = convert_line(line, comments) - f.write(converted + '\n') + for line in reqs.splitlines(): + f.write(convert_line(line, comments) + '\n') if __name__ == '__main__':