Pulling out strip_hashes and add --no-deps flag

This commit is contained in:
sydneyli 2019-02-04 13:07:24 -08:00
parent 7e6db28001
commit ca8276ca58
4 changed files with 25 additions and 42 deletions

View file

@ -8,11 +8,10 @@ WORKDIR /opt/certbot
COPY CHANGELOG.md README.rst setup.py src/
# Generate constraints file to pin dependency versions
COPY letsencrypt-auto-source/pieces/dependency-requirements.txt hashed_requirements.txt
COPY letsencrypt-auto-source/pieces/dependency-requirements.txt .
COPY tools /opt/certbot/tools
RUN /opt/certbot/tools/docker_constraints.py \
hashed_requirements.txt unhashed_requirements.txt \
tools/dev_constraints.txt docker_constraints.txt
RUN sh -c 'cat dependency-requirements.txt | /opt/certbot/tools/strip_hashes.py > unhashed_requirements.txt'
RUN sh -c 'cat tools/dev_constraints.txt unhashed_requirements.txt | /opt/certbot/tools/merge_requirements.py > docker_constraints.txt'
COPY acme src/acme
COPY certbot src/certbot
@ -29,9 +28,8 @@ RUN apk add --no-cache --virtual .build-deps \
openssl-dev \
musl-dev \
libffi-dev \
&& pip install --no-cache-dir \
--requirement /opt/certbot/unhashed_requirements.txt \
--constraint /opt/certbot/docker_constraints.txt \
&& pip install -r /opt/certbot/dependency-requirements.txt \
&& pip install --no-cache-dir --no-deps \
--editable /opt/certbot/src/acme \
--editable /opt/certbot/src \
&& apk del .build-deps

View file

@ -1,23 +0,0 @@
#!/usr/bin/env python
"""Generates constraints file to pin dependency versions in Docker images.
Removes hashes from supplied requirements file and merges it with existing
constraints file. Versions in requirements take precedence over constraints.
Generates interstitial with hashes stripped from requirements.
"""
import sys
import pip_install
import merge_requirements
def main(hashed_reqs_in, unhashed_reqs_out,
constraints_in, constraints_out):
with open(unhashed_reqs_out, 'w') as fd:
fd.write(pip_install.remove_requirements_hashes(hashed_reqs_in))
with open(constraints_out, 'w') as fd:
fd.write(merge_requirements.main(constraints_in, unhashed_reqs_out))
if __name__ == '__main__':
main(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4])

View file

@ -19,6 +19,7 @@ import tempfile
import merge_requirements as merge_module
import readlink
import strip_hashes
def find_tools_path():
@ -40,23 +41,14 @@ def certbot_oldest_processing(tools_path, args, test_constraints):
return requirements
def remove_requirements_hashes(filename):
out_lines = []
with open(filename, 'r') as fd:
in_data = fd.readlines()
for line in in_data:
search = re.search(r'^(\S*==\S*).*$', line)
if search:
out_lines.append(search.group(1))
return os.linesep.join(out_lines)
def certbot_normal_processing(tools_path, test_constraints):
repo_path = os.path.dirname(tools_path)
certbot_requirements = os.path.normpath(os.path.join(
repo_path, 'letsencrypt-auto-source/pieces/dependency-requirements.txt'))
with open(certbot_requirements, 'r') as fd:
data = fd.readlines()
with open(test_constraints, 'w') as fd:
fd.write(remove_requirements_hashes(certbot_requirements))
fd.write(strip_hashes.main(data))
def merge_requirements(tools_path, requirements, test_constraints, all_constraints):

16
tools/strip_hashes.py Executable file
View file

@ -0,0 +1,16 @@
#!/usr/bin/env python
import os
import re
import sys
def main(args):
out_lines = []
for line in args:
search = re.search(r'^(\S*==\S*).*$', line)
if search:
out_lines.append(search.group(1))
return os.linesep.join(out_lines)
if __name__ == '__main__':
print(main(sys.argv[1:]))