mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
This patch switches servo to use `uv` for both installing a pinned Python version as well as installing the dependency packages using `uv`'s pip compatible interface. It also introduces a new 'composite' GitHub action to setup python in the different CI workflows. There is no support for externally managed python installations and virtual environments. These could be added in the future. Fixes #34095 Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
45 lines
1.8 KiB
Python
Executable file
45 lines
1.8 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
|
|
import os
|
|
import sys
|
|
|
|
# Destructure because version_info > max_ver is true when running the same version.
|
|
ver = (sys.version_info[0], sys.version_info[1])
|
|
min_ver = (3, 10)
|
|
if ver < min_ver:
|
|
print("mach requires at least version 3.{0} of Python. The version of Python installed in this system is {1}.{2}" \
|
|
.format(min_ver[1], ver[0], ver[1]))
|
|
sys.exit(1)
|
|
|
|
def main(args):
|
|
topdir = os.path.abspath(os.path.dirname(sys.argv[0]))
|
|
sys.path.insert(0, os.path.join(topdir, "python"))
|
|
import mach_bootstrap
|
|
if len(sys.argv) > 1 and sys.argv[1] == "bootstrap":
|
|
sys.exit(mach_bootstrap.bootstrap_command_only(topdir))
|
|
else:
|
|
mach = mach_bootstrap.bootstrap(topdir)
|
|
sys.exit(mach.run(sys.argv[1:]))
|
|
|
|
|
|
if __name__ == '__main__':
|
|
sys.dont_write_bytecode = True
|
|
|
|
need_nix_shell = os.path.exists('/etc/NIXOS') or 'MACH_USE_NIX' in os.environ
|
|
if need_nix_shell and not 'IN_NIX_SHELL' in os.environ:
|
|
import subprocess
|
|
from shlex import quote
|
|
mach_dir = os.path.abspath(os.path.dirname(__file__))
|
|
build_android_args = ['--arg', 'buildAndroid', 'true'] if 'SERVO_ANDROID_BUILD' in os.environ else []
|
|
print(f'NOTE: Entering nix-shell {mach_dir}/shell.nix')
|
|
try:
|
|
# sys argv already contains the ./mach part, so we just need to pass it as-is
|
|
result = subprocess.run(['nix-shell', f'{mach_dir}/shell.nix'] + build_android_args + ['--run', ' '.join(map(quote, sys.argv))])
|
|
sys.exit(result.returncode)
|
|
except KeyboardInterrupt:
|
|
sys.exit(0)
|
|
else:
|
|
main(sys.argv)
|