Revert "Update recompile_requirements for newer pips"
This reverts commit 8afc215c3d
.
Since setuptools 36, it now vendors its dependencies again, as the vendoring has
lead to various issues.
This commit is contained in:
parent
a690d242a4
commit
a7143d5649
@ -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__':
|
||||
|
Loading…
Reference in New Issue
Block a user