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
|
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):
|
def read_comments(fobj):
|
||||||
"""Find special comments in the config.
|
"""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')):
|
for filename in glob.glob(os.path.join(REQ_DIR, 'requirements-*.txt-raw')):
|
||||||
basename = os.path.basename(filename)
|
basename = os.path.basename(filename)
|
||||||
yield basename[len('requirements-'):-len('.txt-raw')]
|
yield basename[len('requirements-'):-len('.txt-raw')]
|
||||||
yield 'pip'
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Re-compile the given (or all) requirement files."""
|
"""Re-compile the given (or all) requirement files."""
|
||||||
names = sys.argv[1:] if len(sys.argv) > 1 else sorted(get_all_names())
|
names = sys.argv[1:] if len(sys.argv) > 1 else get_all_names()
|
||||||
|
|
||||||
utils.print_title('pip')
|
|
||||||
pip_requirements = get_requirements(None)
|
|
||||||
|
|
||||||
for name in names:
|
for name in names:
|
||||||
utils.print_title(name)
|
utils.print_title(name)
|
||||||
|
filename = os.path.join(REQ_DIR,
|
||||||
|
'requirements-{}.txt-raw'.format(name))
|
||||||
if name == 'qutebrowser':
|
if name == 'qutebrowser':
|
||||||
outfile = os.path.join(REPO_DIR, 'requirements.txt')
|
outfile = os.path.join(REPO_DIR, 'requirements.txt')
|
||||||
else:
|
else:
|
||||||
outfile = os.path.join(REQ_DIR, 'requirements-{}.txt'.format(name))
|
outfile = os.path.join(REQ_DIR, 'requirements-{}.txt'.format(name))
|
||||||
|
|
||||||
if name == 'pip':
|
with tempfile.TemporaryDirectory() as tmpdir:
|
||||||
requirements = [req for req in pip_requirements
|
pip_bin = os.path.join(tmpdir, 'bin', 'pip')
|
||||||
if not req.startswith('pip==')]
|
subprocess.check_call(['virtualenv', tmpdir])
|
||||||
comments = {
|
subprocess.check_call([pip_bin, 'install', '-r', filename])
|
||||||
'filter': {},
|
reqs = subprocess.check_output([pip_bin, 'freeze']).decode('utf-8')
|
||||||
'comment': {},
|
|
||||||
'ignore': [],
|
|
||||||
'replace': {},
|
|
||||||
}
|
|
||||||
else:
|
|
||||||
filename = os.path.join(REQ_DIR,
|
|
||||||
'requirements-{}.txt-raw'.format(name))
|
|
||||||
requirements = get_requirements(filename, exclude=pip_requirements)
|
|
||||||
|
|
||||||
with open(filename, 'r', encoding='utf-8') as f:
|
with open(filename, 'r', encoding='utf-8') as f:
|
||||||
comments = read_comments(f)
|
comments = read_comments(f)
|
||||||
|
|
||||||
with open(outfile, 'w', encoding='utf-8') as f:
|
with open(outfile, 'w', encoding='utf-8') as f:
|
||||||
f.write("# This file is automatically generated by "
|
f.write("# This file is automatically generated by "
|
||||||
"scripts/dev/recompile_requirements.py\n\n")
|
"scripts/dev/recompile_requirements.py\n\n")
|
||||||
for line in requirements:
|
for line in reqs.splitlines():
|
||||||
converted = convert_line(line, comments)
|
f.write(convert_line(line, comments) + '\n')
|
||||||
f.write(converted + '\n')
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
Reference in New Issue
Block a user