2020-11-02 09:17:26 +01:00
|
|
|
#!/usr/bin/env python3
|
2021-04-13 10:45:05 +02:00
|
|
|
# Copyright: Ankitects Pty Ltd and contributors
|
|
|
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
2020-11-02 09:17:26 +01:00
|
|
|
#
|
2020-11-03 00:03:00 +01:00
|
|
|
# See README.md
|
2020-11-02 09:17:26 +01:00
|
|
|
|
2020-11-03 02:27:44 +01:00
|
|
|
# If you get a message like the following during a build:
|
|
|
|
#
|
|
|
|
# DEBUG: Rule 'raze__reqwest__0_10_8' indicated that a canonical reproducible
|
|
|
|
# form can be obtained by modifying arguments shallow_since = "1604362745 +1000"
|
|
|
|
|
|
|
|
# ...then the commit and shallow_since argument should be added below, as this
|
|
|
|
# will remove the debug warning, and speed up the git clone.
|
|
|
|
|
|
|
|
COMMITS_SHALLOW_SINCE = {
|
2021-04-27 14:18:12 +02:00
|
|
|
# reqwest - must also update crates.bzl reference below
|
|
|
|
"7591444614de02b658ddab125efba7b2bb4e2335": "1619519742 +1000",
|
2020-11-03 02:27:44 +01:00
|
|
|
# hyper-timeout
|
2021-04-27 14:18:12 +02:00
|
|
|
"0cb6f7d14c62819e37cd221736f8b0555e823712": "1619519657 +1000",
|
2020-11-03 02:27:44 +01:00
|
|
|
# tokio-io-timeout
|
2021-04-27 14:18:12 +02:00
|
|
|
"1ee0892217e9a76bba4bb369ec5fab8854935a3c": "1619517354 +1000",
|
2021-07-16 02:35:09 +02:00
|
|
|
# pct-str
|
|
|
|
"4adccd8d4a222ab2672350a102f06ae832a0572d": "1605376517 +0100",
|
2021-07-23 11:39:40 +02:00
|
|
|
"2f20798ce521cc594d510d4e417e76d5eac04d4b": "1626729019 +0200",
|
2020-11-03 02:27:44 +01:00
|
|
|
}
|
|
|
|
|
2021-04-14 10:22:02 +02:00
|
|
|
import glob
|
2020-11-02 09:17:26 +01:00
|
|
|
import os
|
2020-11-03 02:27:44 +01:00
|
|
|
import re
|
2021-04-14 10:22:02 +02:00
|
|
|
import shutil
|
|
|
|
import subprocess
|
|
|
|
import sys
|
2020-11-02 09:17:26 +01:00
|
|
|
|
|
|
|
if os.getcwd() != os.path.abspath(os.path.dirname(__file__)):
|
|
|
|
print("Run this from the cargo/ folder")
|
|
|
|
sys.exit(1)
|
|
|
|
|
use ring on Linux; native-tls on other platforms
Python wheels on Linux require statically linked SSL libraries.
We were previously relying on the native-tls-vendored feature in
reqwest, but that does not work with Bazel, as openssl-src makes
assumptions that break when sandboxed. The static libs distributed
by distros like Ubuntu fail to link, and while we could potentially
build OpenSSL ourselves, we'd then need to keep it up to
date.
On Windows and Mac however, native-tls is preferable to ring, as it
allows us to get free updates from the OS, and results in
a smaller library.
Rust currently only supports platform-specific features in nightly,
and cargo-raze does not have support for them, so we currently need
to override the generated build file with a hand-crafted one that
specifies the relative features/deps for each platform.
update.py has been updated to automatically keep the version numbers
in this file up to date, so it should hopefully not prove too hard to
maintain going forward.
2020-11-15 06:24:05 +01:00
|
|
|
|
|
|
|
def update_cargo_lock():
|
|
|
|
# update Cargo.lock
|
|
|
|
subprocess.run(["cargo", "update"], check=True)
|
|
|
|
|
|
|
|
|
|
|
|
def run_cargo_raze():
|
|
|
|
# generate cargo-raze files
|
2020-11-24 09:41:03 +01:00
|
|
|
subprocess.run(["cargo-raze"], cwd="..", check=True)
|
use ring on Linux; native-tls on other platforms
Python wheels on Linux require statically linked SSL libraries.
We were previously relying on the native-tls-vendored feature in
reqwest, but that does not work with Bazel, as openssl-src makes
assumptions that break when sandboxed. The static libs distributed
by distros like Ubuntu fail to link, and while we could potentially
build OpenSSL ourselves, we'd then need to keep it up to
date.
On Windows and Mac however, native-tls is preferable to ring, as it
allows us to get free updates from the OS, and results in
a smaller library.
Rust currently only supports platform-specific features in nightly,
and cargo-raze does not have support for them, so we currently need
to override the generated build file with a hand-crafted one that
specifies the relative features/deps for each platform.
update.py has been updated to automatically keep the version numbers
in this file up to date, so it should hopefully not prove too hard to
maintain going forward.
2020-11-15 06:24:05 +01:00
|
|
|
|
|
|
|
|
|
|
|
def write_licenses():
|
|
|
|
# dump licenses
|
2020-12-15 09:09:11 +01:00
|
|
|
result = subprocess.check_output(["cargo-license", "-j"], cwd="../rslib")
|
use ring on Linux; native-tls on other platforms
Python wheels on Linux require statically linked SSL libraries.
We were previously relying on the native-tls-vendored feature in
reqwest, but that does not work with Bazel, as openssl-src makes
assumptions that break when sandboxed. The static libs distributed
by distros like Ubuntu fail to link, and while we could potentially
build OpenSSL ourselves, we'd then need to keep it up to
date.
On Windows and Mac however, native-tls is preferable to ring, as it
allows us to get free updates from the OS, and results in
a smaller library.
Rust currently only supports platform-specific features in nightly,
and cargo-raze does not have support for them, so we currently need
to override the generated build file with a hand-crafted one that
specifies the relative features/deps for each platform.
update.py has been updated to automatically keep the version numbers
in this file up to date, so it should hopefully not prove too hard to
maintain going forward.
2020-11-15 06:24:05 +01:00
|
|
|
with open("licenses.json", "wb") as file:
|
|
|
|
file.write(result)
|
|
|
|
|
|
|
|
# export license file
|
|
|
|
with open("BUILD.bazel", "a", encoding="utf8") as file:
|
|
|
|
file.write(
|
|
|
|
"""
|
2020-11-12 08:41:47 +01:00
|
|
|
exports_files(["licenses.json"])
|
|
|
|
"""
|
use ring on Linux; native-tls on other platforms
Python wheels on Linux require statically linked SSL libraries.
We were previously relying on the native-tls-vendored feature in
reqwest, but that does not work with Bazel, as openssl-src makes
assumptions that break when sandboxed. The static libs distributed
by distros like Ubuntu fail to link, and while we could potentially
build OpenSSL ourselves, we'd then need to keep it up to
date.
On Windows and Mac however, native-tls is preferable to ring, as it
allows us to get free updates from the OS, and results in
a smaller library.
Rust currently only supports platform-specific features in nightly,
and cargo-raze does not have support for them, so we currently need
to override the generated build file with a hand-crafted one that
specifies the relative features/deps for each platform.
update.py has been updated to automatically keep the version numbers
in this file up to date, so it should hopefully not prove too hard to
maintain going forward.
2020-11-15 06:24:05 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def update_crates_bzl():
|
|
|
|
output_lines = []
|
2020-12-15 09:09:11 +01:00
|
|
|
commit_re = re.compile(r'\s+commit = "([0-9a-f]+)",')
|
use ring on Linux; native-tls on other platforms
Python wheels on Linux require statically linked SSL libraries.
We were previously relying on the native-tls-vendored feature in
reqwest, but that does not work with Bazel, as openssl-src makes
assumptions that break when sandboxed. The static libs distributed
by distros like Ubuntu fail to link, and while we could potentially
build OpenSSL ourselves, we'd then need to keep it up to
date.
On Windows and Mac however, native-tls is preferable to ring, as it
allows us to get free updates from the OS, and results in
a smaller library.
Rust currently only supports platform-specific features in nightly,
and cargo-raze does not have support for them, so we currently need
to override the generated build file with a hand-crafted one that
specifies the relative features/deps for each platform.
update.py has been updated to automatically keep the version numbers
in this file up to date, so it should hopefully not prove too hard to
maintain going forward.
2020-11-15 06:24:05 +01:00
|
|
|
reqwest_build_prefix = re.compile(r"/remote:BUILD.reqwest-\d+\.\d+\.\d+")
|
|
|
|
|
|
|
|
with open("crates.bzl") as file:
|
|
|
|
for line in file.readlines():
|
|
|
|
# update shallow-since references for git crates
|
|
|
|
if match := commit_re.match(line):
|
|
|
|
commit = match.group(1)
|
|
|
|
if commit in line:
|
|
|
|
if since := COMMITS_SHALLOW_SINCE.get(commit):
|
|
|
|
output_lines.append(f' shallow_since = "{since}",\n')
|
|
|
|
else:
|
|
|
|
print(f"{commit} not in COMMITS_SHALLOW_SINCE")
|
|
|
|
|
|
|
|
# use our custom reqwest build file
|
|
|
|
if match := reqwest_build_prefix.search(line):
|
2021-04-27 14:18:12 +02:00
|
|
|
line = line.replace(match.group(0), ":BUILD.reqwest.native")
|
use ring on Linux; native-tls on other platforms
Python wheels on Linux require statically linked SSL libraries.
We were previously relying on the native-tls-vendored feature in
reqwest, but that does not work with Bazel, as openssl-src makes
assumptions that break when sandboxed. The static libs distributed
by distros like Ubuntu fail to link, and while we could potentially
build OpenSSL ourselves, we'd then need to keep it up to
date.
On Windows and Mac however, native-tls is preferable to ring, as it
allows us to get free updates from the OS, and results in
a smaller library.
Rust currently only supports platform-specific features in nightly,
and cargo-raze does not have support for them, so we currently need
to override the generated build file with a hand-crafted one that
specifies the relative features/deps for each platform.
update.py has been updated to automatically keep the version numbers
in this file up to date, so it should hopefully not prove too hard to
maintain going forward.
2020-11-15 06:24:05 +01:00
|
|
|
|
|
|
|
output_lines.append(line)
|
|
|
|
|
|
|
|
with open("crates.bzl", "w") as file:
|
|
|
|
for line in output_lines:
|
|
|
|
file.write(line)
|
2021-10-02 12:42:03 +02:00
|
|
|
|
2021-04-27 14:18:12 +02:00
|
|
|
# add rustls version
|
2021-10-02 12:42:03 +02:00
|
|
|
file.write(
|
|
|
|
"\n".join(
|
|
|
|
" " * 4 + l
|
|
|
|
for l in """
|
2021-04-27 14:18:12 +02:00
|
|
|
maybe(
|
|
|
|
new_git_repository,
|
|
|
|
name = "reqwest_rustls",
|
|
|
|
remote = "https://github.com/ankitects/reqwest.git",
|
|
|
|
shallow_since = "1619519742 +1000",
|
|
|
|
commit = "7591444614de02b658ddab125efba7b2bb4e2335",
|
|
|
|
build_file = Label("//cargo:BUILD.reqwest.rustls.bazel"),
|
|
|
|
init_submodules = True,
|
|
|
|
)
|
2021-10-02 12:42:03 +02:00
|
|
|
""".splitlines()
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
use ring on Linux; native-tls on other platforms
Python wheels on Linux require statically linked SSL libraries.
We were previously relying on the native-tls-vendored feature in
reqwest, but that does not work with Bazel, as openssl-src makes
assumptions that break when sandboxed. The static libs distributed
by distros like Ubuntu fail to link, and while we could potentially
build OpenSSL ourselves, we'd then need to keep it up to
date.
On Windows and Mac however, native-tls is preferable to ring, as it
allows us to get free updates from the OS, and results in
a smaller library.
Rust currently only supports platform-specific features in nightly,
and cargo-raze does not have support for them, so we currently need
to override the generated build file with a hand-crafted one that
specifies the relative features/deps for each platform.
update.py has been updated to automatically keep the version numbers
in this file up to date, so it should hopefully not prove too hard to
maintain going forward.
2020-11-15 06:24:05 +01:00
|
|
|
|
|
|
|
def generated_reqwest_build_file():
|
2021-07-23 11:39:40 +02:00
|
|
|
return glob.glob("remote/*reqwest-0.11.3*")[0]
|
use ring on Linux; native-tls on other platforms
Python wheels on Linux require statically linked SSL libraries.
We were previously relying on the native-tls-vendored feature in
reqwest, but that does not work with Bazel, as openssl-src makes
assumptions that break when sandboxed. The static libs distributed
by distros like Ubuntu fail to link, and while we could potentially
build OpenSSL ourselves, we'd then need to keep it up to
date.
On Windows and Mac however, native-tls is preferable to ring, as it
allows us to get free updates from the OS, and results in
a smaller library.
Rust currently only supports platform-specific features in nightly,
and cargo-raze does not have support for them, so we currently need
to override the generated build file with a hand-crafted one that
specifies the relative features/deps for each platform.
update.py has been updated to automatically keep the version numbers
in this file up to date, so it should hopefully not prove too hard to
maintain going forward.
2020-11-15 06:24:05 +01:00
|
|
|
|
|
|
|
|
2021-10-02 12:42:03 +02:00
|
|
|
def update_deps():
|
2021-04-27 14:18:12 +02:00
|
|
|
"Update version numbers in our custom reqwest build files."
|
use ring on Linux; native-tls on other platforms
Python wheels on Linux require statically linked SSL libraries.
We were previously relying on the native-tls-vendored feature in
reqwest, but that does not work with Bazel, as openssl-src makes
assumptions that break when sandboxed. The static libs distributed
by distros like Ubuntu fail to link, and while we could potentially
build OpenSSL ourselves, we'd then need to keep it up to
date.
On Windows and Mac however, native-tls is preferable to ring, as it
allows us to get free updates from the OS, and results in
a smaller library.
Rust currently only supports platform-specific features in nightly,
and cargo-raze does not have support for them, so we currently need
to override the generated build file with a hand-crafted one that
specifies the relative features/deps for each platform.
update.py has been updated to automatically keep the version numbers
in this file up to date, so it should hopefully not prove too hard to
maintain going forward.
2020-11-15 06:24:05 +01:00
|
|
|
dep_with_version = re.compile(r"@raze__(.+?)__([\d_]+)//")
|
|
|
|
|
|
|
|
version_map = {}
|
|
|
|
with open(generated_reqwest_build_file(), encoding="utf8") as file:
|
|
|
|
for line in file.readlines():
|
|
|
|
if match := dep_with_version.search(line):
|
|
|
|
version_map[match.group(1)] = match.group(2)
|
|
|
|
|
2021-04-27 14:18:12 +02:00
|
|
|
for path in "BUILD.reqwest.native.bazel", "BUILD.reqwest.rustls.bazel":
|
|
|
|
with open(path, "r+", encoding="utf8") as file:
|
use ring on Linux; native-tls on other platforms
Python wheels on Linux require statically linked SSL libraries.
We were previously relying on the native-tls-vendored feature in
reqwest, but that does not work with Bazel, as openssl-src makes
assumptions that break when sandboxed. The static libs distributed
by distros like Ubuntu fail to link, and while we could potentially
build OpenSSL ourselves, we'd then need to keep it up to
date.
On Windows and Mac however, native-tls is preferable to ring, as it
allows us to get free updates from the OS, and results in
a smaller library.
Rust currently only supports platform-specific features in nightly,
and cargo-raze does not have support for them, so we currently need
to override the generated build file with a hand-crafted one that
specifies the relative features/deps for each platform.
update.py has been updated to automatically keep the version numbers
in this file up to date, so it should hopefully not prove too hard to
maintain going forward.
2020-11-15 06:24:05 +01:00
|
|
|
|
2021-04-27 14:18:12 +02:00
|
|
|
def repl(m):
|
|
|
|
name = m.group(1)
|
|
|
|
current_version = m.group(2)
|
|
|
|
new_version = version_map.get(name)
|
|
|
|
return m.group(0).replace(current_version, new_version)
|
use ring on Linux; native-tls on other platforms
Python wheels on Linux require statically linked SSL libraries.
We were previously relying on the native-tls-vendored feature in
reqwest, but that does not work with Bazel, as openssl-src makes
assumptions that break when sandboxed. The static libs distributed
by distros like Ubuntu fail to link, and while we could potentially
build OpenSSL ourselves, we'd then need to keep it up to
date.
On Windows and Mac however, native-tls is preferable to ring, as it
allows us to get free updates from the OS, and results in
a smaller library.
Rust currently only supports platform-specific features in nightly,
and cargo-raze does not have support for them, so we currently need
to override the generated build file with a hand-crafted one that
specifies the relative features/deps for each platform.
update.py has been updated to automatically keep the version numbers
in this file up to date, so it should hopefully not prove too hard to
maintain going forward.
2020-11-15 06:24:05 +01:00
|
|
|
|
2021-04-27 14:18:12 +02:00
|
|
|
data = dep_with_version.sub(repl, file.read())
|
|
|
|
file.seek(0)
|
|
|
|
file.write(data)
|
use ring on Linux; native-tls on other platforms
Python wheels on Linux require statically linked SSL libraries.
We were previously relying on the native-tls-vendored feature in
reqwest, but that does not work with Bazel, as openssl-src makes
assumptions that break when sandboxed. The static libs distributed
by distros like Ubuntu fail to link, and while we could potentially
build OpenSSL ourselves, we'd then need to keep it up to
date.
On Windows and Mac however, native-tls is preferable to ring, as it
allows us to get free updates from the OS, and results in
a smaller library.
Rust currently only supports platform-specific features in nightly,
and cargo-raze does not have support for them, so we currently need
to override the generated build file with a hand-crafted one that
specifies the relative features/deps for each platform.
update.py has been updated to automatically keep the version numbers
in this file up to date, so it should hopefully not prove too hard to
maintain going forward.
2020-11-15 06:24:05 +01:00
|
|
|
|
2021-07-23 13:00:51 +02:00
|
|
|
with open("remote/BUILD.linkcheck-0.4.1-alpha.0.bazel") as f:
|
|
|
|
out = []
|
|
|
|
for line in f.readlines():
|
2021-10-02 12:42:03 +02:00
|
|
|
line = line.replace(
|
|
|
|
"@raze__reqwest__0_11_4//:reqwest", "@reqwest_rustls//:reqwest"
|
|
|
|
)
|
2021-07-23 13:00:51 +02:00
|
|
|
out.append(line)
|
|
|
|
with open("remote/BUILD.linkcheck-0.4.1-alpha.0.bazel", "w") as f:
|
|
|
|
f.writelines(out)
|
|
|
|
|
2021-10-02 12:42:03 +02:00
|
|
|
with open("BUILD.term-0.7.0.bazel") as f:
|
|
|
|
buf = f.read()
|
|
|
|
with open("remote/BUILD.term-0.7.0.bazel", "w") as f:
|
|
|
|
f.write(buf)
|
2021-07-23 13:00:51 +02:00
|
|
|
|
use ring on Linux; native-tls on other platforms
Python wheels on Linux require statically linked SSL libraries.
We were previously relying on the native-tls-vendored feature in
reqwest, but that does not work with Bazel, as openssl-src makes
assumptions that break when sandboxed. The static libs distributed
by distros like Ubuntu fail to link, and while we could potentially
build OpenSSL ourselves, we'd then need to keep it up to
date.
On Windows and Mac however, native-tls is preferable to ring, as it
allows us to get free updates from the OS, and results in
a smaller library.
Rust currently only supports platform-specific features in nightly,
and cargo-raze does not have support for them, so we currently need
to override the generated build file with a hand-crafted one that
specifies the relative features/deps for each platform.
update.py has been updated to automatically keep the version numbers
in this file up to date, so it should hopefully not prove too hard to
maintain going forward.
2020-11-15 06:24:05 +01:00
|
|
|
|
2020-12-28 01:12:10 +01:00
|
|
|
def stage_commit():
|
|
|
|
subprocess.run(
|
|
|
|
[
|
|
|
|
"git",
|
|
|
|
"add",
|
|
|
|
".",
|
|
|
|
"../Cargo.lock",
|
|
|
|
"../rslib/cargo/BUILD.bazel",
|
|
|
|
"../pylib/rsbridge/BUILD.bazel",
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2022-02-10 00:55:43 +01:00
|
|
|
if os.getenv("REPIN"):
|
|
|
|
update_cargo_lock()
|
use ring on Linux; native-tls on other platforms
Python wheels on Linux require statically linked SSL libraries.
We were previously relying on the native-tls-vendored feature in
reqwest, but that does not work with Bazel, as openssl-src makes
assumptions that break when sandboxed. The static libs distributed
by distros like Ubuntu fail to link, and while we could potentially
build OpenSSL ourselves, we'd then need to keep it up to
date.
On Windows and Mac however, native-tls is preferable to ring, as it
allows us to get free updates from the OS, and results in
a smaller library.
Rust currently only supports platform-specific features in nightly,
and cargo-raze does not have support for them, so we currently need
to override the generated build file with a hand-crafted one that
specifies the relative features/deps for each platform.
update.py has been updated to automatically keep the version numbers
in this file up to date, so it should hopefully not prove too hard to
maintain going forward.
2020-11-15 06:24:05 +01:00
|
|
|
run_cargo_raze()
|
|
|
|
write_licenses()
|
|
|
|
update_crates_bzl()
|
2021-10-02 12:42:03 +02:00
|
|
|
update_deps()
|
2020-12-28 01:12:10 +01:00
|
|
|
stage_commit()
|