Files
servo/mach
Jonathan Schwender b5df4bc90a mach: use uv run --frozen (#42169)
This will avoid updating the lockfile during regular operations. Also
ignore the `servo.egg-info` directory, which
the new python requirement installation mechanism via setuptools
creates.
To update the lockfile one can run `uv lock`. This is also done
automatically, when syncing requirements from WPT.

This PR also updates the uv version in CI to a newer one. If you
encounter any issues with the lockfile after this PR, it might be
necessary to update your local instance of uv.

Testing: Build still works. [mach try
full](https://github.com/servo/servo/actions/runs/21624364040)

---------

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
2026-02-03 12:43:04 +00:00

57 lines
2.2 KiB
Bash
Executable File

#!/bin/sh
# 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/.
# The beginning of this script is both valid shell and valid python, such that
# the script starts with the shell and is reexecuted with `uv run`. This
# ensures that the Python provided by the virtual environment (in the .venv
# directory) is used. If the virtual environment does not exist, `uv run` will
# still use the correct version of Python given in `.python-version` and
# python/mach_bootstrap.py will provision a new environment that will be used
# for the subsequent runs.
''':' && {
MACH_DIR=$(dirname "$0");
run_in_nix_if_needed() {
if { [ -f /etc/NIXOS ] || [ -n "${MACH_USE_NIX}" ]; } && [ -z "${IN_NIX_SHELL}" ]; then
EXTRA_NIX_ARGS=${SERVO_ANDROID_BUILD:+'--arg buildAndroid true'}
# `nix-shell` needs the whole command passed as a single argument, so the arguments need
# to be shell-quoted. Rotate through the arguments, replacing them with quoted versions.
for arg in "$@"; do
set -- "$@" "$(printf \%q "$1")"
shift
done
echo "NOTE: Entering nix-shell ${MACH_DIR}/shell.nix"
exec nix-shell "${MACH_DIR}/shell.nix" $EXTRA_NIX_ARGS --run "$*"
else
exec "$@"
fi
}
run_in_nix_if_needed uv run --frozen python ${MACH_DIR}/mach "$@"
}
'''
import os
import sys
# On NixOS, prepend nix-provided binary paths so they take precedence over .venv/bin
if 'SERVO_NIX_BIN_DIR' in os.environ:
os.environ['PATH'] = os.environ['SERVO_NIX_BIN_DIR'] + os.pathsep + os.environ.get('PATH', '')
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__':
main(sys.argv)