mirror of
https://github.com/certbot/certbot.git
synced 2025-08-08 04:02:10 +03:00
Write a replacement for pipstrap (#8401)
* Add a new, simplified version of pipstrap. * Use tools/pipstrap.py * Uncomment code * Refactor pip_install.py and provide hashes. * Fix test_sdists.sh. * Make code work on Python 2. * Call strip_hashes.py using Python 3. * Pin the oldest version of httplib2 used in distros * Strip enum34 dependency. * Remove pip pinnings from dev_constraints.txt * Correct pipstrap docstring. * Don't set working_dir twice. * Add comments
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import print_function
|
||||
|
||||
import contextlib
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
@@ -23,6 +24,17 @@ import readlink
|
||||
import strip_hashes
|
||||
|
||||
|
||||
# Once this code doesn't need to support Python 2, we can simply use
|
||||
# tempfile.TemporaryDirectory.
|
||||
@contextlib.contextmanager
|
||||
def temporary_directory():
|
||||
dirpath = tempfile.mkdtemp()
|
||||
try:
|
||||
yield dirpath
|
||||
finally:
|
||||
shutil.rmtree(dirpath)
|
||||
|
||||
|
||||
def find_tools_path():
|
||||
return os.path.dirname(readlink.main(__file__))
|
||||
|
||||
@@ -75,22 +87,18 @@ def call_with_print(command):
|
||||
subprocess.check_call(command, shell=True)
|
||||
|
||||
|
||||
def pip_install_with_print(args_str):
|
||||
command = '"{0}" -m pip install --disable-pip-version-check {1}'.format(sys.executable,
|
||||
args_str)
|
||||
call_with_print(command)
|
||||
def pip_install_with_print(args_str, disable_build_isolation=True):
|
||||
command = ['"', sys.executable, '" -m pip install --disable-pip-version-check ']
|
||||
if disable_build_isolation:
|
||||
command.append('--no-build-isolation ')
|
||||
command.append(args_str)
|
||||
call_with_print(''.join(command))
|
||||
|
||||
|
||||
def main(args):
|
||||
tools_path = find_tools_path()
|
||||
working_dir = tempfile.mkdtemp()
|
||||
|
||||
if os.environ.get('TRAVIS'):
|
||||
# When this script is executed on Travis, the following print will make the log
|
||||
# be folded until the end command is printed (see finally section).
|
||||
print('travis_fold:start:install_certbot_deps')
|
||||
|
||||
try:
|
||||
with temporary_directory() as working_dir:
|
||||
test_constraints = os.path.join(working_dir, 'test_constraints.txt')
|
||||
all_constraints = os.path.join(working_dir, 'all_constraints.txt')
|
||||
|
||||
@@ -119,10 +127,6 @@ def main(args):
|
||||
|
||||
pip_install_with_print('--constraint "{0}" {1}'.format(
|
||||
all_constraints, ' '.join(args)))
|
||||
finally:
|
||||
if os.environ.get('TRAVIS'):
|
||||
print('travis_fold:end:install_certbot_deps')
|
||||
shutil.rmtree(working_dir)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
Reference in New Issue
Block a user