mirror of
https://github.com/servo/servo.git
synced 2025-06-29 19:43:39 +01:00
Auto merge of #22596 - shanavas786:fix-certifi, r=SimonSapin
Fix certifi import error while running ./match bootstrap Fixes #22590 <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach bootstrap` does not report any errors - [x] These changes fix #22590 <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22596) <!-- Reviewable:end -->
This commit is contained in:
commit
1753cda362
2 changed files with 20 additions and 12 deletions
|
@ -26,7 +26,7 @@ from mach.decorators import (
|
||||||
|
|
||||||
from servo.command_base import CommandBase, cd, call, BIN_SUFFIX
|
from servo.command_base import CommandBase, cd, call, BIN_SUFFIX
|
||||||
from servo.build_commands import notify_build_done
|
from servo.build_commands import notify_build_done
|
||||||
from servo.util import STATIC_RUST_LANG_ORG_DIST, URLOPEN_KWARGS
|
from servo.util import get_static_rust_lang_org_dist, get_urlopen_kwargs
|
||||||
|
|
||||||
|
|
||||||
@CommandProvider
|
@CommandProvider
|
||||||
|
@ -216,8 +216,8 @@ class MachCommands(CommandBase):
|
||||||
description='Update the Rust version to latest Nightly',
|
description='Update the Rust version to latest Nightly',
|
||||||
category='devenv')
|
category='devenv')
|
||||||
def rustup(self):
|
def rustup(self):
|
||||||
url = STATIC_RUST_LANG_ORG_DIST + "/channel-rust-nightly-date.txt"
|
url = get_static_rust_lang_org_dist() + "/channel-rust-nightly-date.txt"
|
||||||
nightly_date = urllib2.urlopen(url, **URLOPEN_KWARGS).read()
|
nightly_date = urllib2.urlopen(url, **get_urlopen_kwargs()).read()
|
||||||
toolchain = "nightly-" + nightly_date
|
toolchain = "nightly-" + nightly_date
|
||||||
filename = path.join(self.context.topdir, "rust-toolchain")
|
filename = path.join(self.context.topdir, "rust-toolchain")
|
||||||
with open(filename, "w") as f:
|
with open(filename, "w") as f:
|
||||||
|
|
|
@ -28,14 +28,22 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
HAS_SNI = False
|
HAS_SNI = False
|
||||||
|
|
||||||
# The cafile parameter was added in 2.7.9
|
HAS_SNI_AND_RECENT_PYTHON = HAS_SNI and sys.version_info >= (2, 7, 9)
|
||||||
if HAS_SNI and sys.version_info >= (2, 7, 9):
|
|
||||||
import certifi
|
|
||||||
STATIC_RUST_LANG_ORG_DIST = "https://static.rust-lang.org/dist"
|
def get_static_rust_lang_org_dist():
|
||||||
URLOPEN_KWARGS = {"cafile": certifi.where()}
|
if HAS_SNI_AND_RECENT_PYTHON:
|
||||||
else:
|
return "https://static.rust-lang.org/dist"
|
||||||
STATIC_RUST_LANG_ORG_DIST = "https://static-rust-lang-org.s3.amazonaws.com/dist"
|
|
||||||
URLOPEN_KWARGS = {}
|
return "https://static-rust-lang-org.s3.amazonaws.com/dist"
|
||||||
|
|
||||||
|
|
||||||
|
def get_urlopen_kwargs():
|
||||||
|
# The cafile parameter was added in 2.7.9
|
||||||
|
if HAS_SNI_AND_RECENT_PYTHON:
|
||||||
|
import certifi
|
||||||
|
return {"cafile": certifi.where()}
|
||||||
|
return {}
|
||||||
|
|
||||||
|
|
||||||
def remove_readonly(func, path, _):
|
def remove_readonly(func, path, _):
|
||||||
|
@ -96,7 +104,7 @@ def download(desc, src, writer, start_byte=0):
|
||||||
req = urllib2.Request(src)
|
req = urllib2.Request(src)
|
||||||
if start_byte:
|
if start_byte:
|
||||||
req = urllib2.Request(src, headers={'Range': 'bytes={}-'.format(start_byte)})
|
req = urllib2.Request(src, headers={'Range': 'bytes={}-'.format(start_byte)})
|
||||||
resp = urllib2.urlopen(req, **URLOPEN_KWARGS)
|
resp = urllib2.urlopen(req, **get_urlopen_kwargs())
|
||||||
|
|
||||||
fsize = None
|
fsize = None
|
||||||
if resp.info().getheader('Content-Length'):
|
if resp.info().getheader('Content-Length'):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue