Skip to content

Commit 73dc6fb

Browse files
committed
This updates WORKSPACE to the latest subpar, and ./update_tools.sh.
This also fixes a couple bugs I hit after regenerating piptool.par: - os.environ['PYTHONPATH'] may result in a KeyError - The cert expansion logic was removed, but things fail without it (after I ./update_tools.sh). I thought this was intentional (should the PAR changes have fixes this?), but I'm restoring for now to keep HEAD in a good state.
1 parent e003509 commit 73dc6fb

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

WORKSPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ _piptool_install()
5252
git_repository(
5353
name = "subpar",
5454
remote = "https://github.com/google/subpar",
55-
tag = "1.0.0",
55+
tag = "1.1.0",
5656
)
5757

5858
# Test data for WHL tool testing.

rules_python/piptool.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,10 @@ def extract_packages(package_names):
4848
# Add extracted directories to import path ahead of their zip file
4949
# counterparts.
5050
sys.path[0:0] = dirs_to_add
51-
existing_pythonpath = os.environ['PYTHONPATH'].split(':')
52-
os.environ['PYTHONPATH'] = ':'.join(dirs_to_add + existing_pythonpath)
51+
existing_pythonpath = os.environ.get('PYTHONPATH')
52+
if existing_pythonpath:
53+
dirs_to_add.extend(existing_pythonpath.split(':'))
54+
os.environ['PYTHONPATH'] = ':'.join(dirs_to_add)
5355

5456

5557
# Wheel, pip, and setuptools are much happier running from actual
@@ -68,7 +70,12 @@ def extract_packages(package_names):
6870

6971

7072
def pip_main(argv):
71-
argv = ["--disable-pip-version-check"] + argv
73+
# Extract the certificates from the PAR following the example of get-pip.py
74+
# https://github.com/pypa/get-pip/blob/430ba37776ae2ad89/template.py#L164-L168
75+
cert_path = os.path.join(tempfile.mkdtemp(), "cacert.pem")
76+
with open(cert_path, "wb") as cert:
77+
cert.write(pkgutil.get_data("pip._vendor.requests", "cacert.pem"))
78+
argv = ["--disable-pip-version-check", "--cert", cert_path] + argv
7279
return pip.main(argv)
7380

7481

tools/piptool.par

2.7 KB
Binary file not shown.

0 commit comments

Comments
 (0)