Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions scripts/curl_install_pypi/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,27 @@ def is_valid_sha256sum(a_file, expected_sum):
return expected_sum == computed_hash


import ssl
from urllib.request import urlopen, Request

def _get_urlopen_with_context():
try:
# Create an SSL context that uses the system's default CA bundle
context = ssl.create_default_context()
return lambda url: urlopen(url, context=context)
except Exception:
# Fallback to default urlopen if context creation fails
return urlopen

def create_virtualenv(tmp_dir, install_dir):
download_location = os.path.join(tmp_dir, VIRTUALENV_ARCHIVE)
print_status('Downloading virtualenv package from {}.'.format(VIRTUALENV_DOWNLOAD_URL))
response = urlopen(VIRTUALENV_DOWNLOAD_URL)
opener = _get_urlopen_with_context()
response = opener(VIRTUALENV_DOWNLOAD_URL)
with open(download_location, 'wb') as f: f.write(response.read())
print_status("Downloaded virtualenv package to {}.".format(download_location))
if is_valid_sha256sum(download_location, VIRTUALENV_ARCHIVE_SHA256):
print_status("Checksum of {} OK.".format(download_location))
print_status("Checksum of {} OK.".format(download_location))ad_location))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is ad_location?

else:
raise CLIInstallError("The checksum of the downloaded virtualenv package does not match.")
print_status("Extracting '{}' to '{}'.".format(download_location, tmp_dir))
Expand Down