Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
mukilan committed Dec 6, 2024
1 parent 61ca2dd commit 1f0bad5
Show file tree
Hide file tree
Showing 20 changed files with 81 additions and 60 deletions.
14 changes: 14 additions & 0 deletions .github/actions/setup-python/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Setup Python and UV
runs:
using: "composite"
steps:
# Use the setup-python action to take advantage of the cache. uv will symlink
# to this version
- name: Setup system python
uses: actions/setup-python@v5
with:
python-version-file: '.python-version'
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
version: "0.5.6"
4 changes: 2 additions & 2 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ jobs:
uses: mozilla-actions/[email protected]
- name: Install crown
run: cargo install --path support/crown
- name: Bootstrap Python
run: python3 -m pip install --upgrade pip virtualenv
- name: Setup Python
uses: ./.github/actions/setup-python
- name: Bootstrap dependencies
run: sudo apt update && python3 ./mach bootstrap --skip-lints
- name: Set up JDK 17
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: ./.github/actions/setup-python
- name: Bootstrap
run: |
python3 -m pip install --upgrade pip
sudo apt update
python3 ./mach bootstrap --skip-lints
- name: Set LIBCLANG_PATH # This is needed for bindgen in mozangle.
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ jobs:
uses: mozilla-actions/[email protected]
- name: Set LIBCLANG_PATH env # needed for bindgen in mozangle
run: echo "LIBCLANG_PATH=/usr/lib/llvm-14/lib" >> $GITHUB_ENV
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Setup Python
uses: ./.github/actions/setup-python
- name: Install taplo
uses: baptiste0928/cargo-install@v3
with:
Expand All @@ -46,8 +45,6 @@ jobs:
locked: true
# 0.16.2 requires Rust 1.81 or newer.
version: '0.16.1'
- name: Bootstrap Python
run: python3 -m pip install --upgrade pip
- name: Bootstrap dependencies
run: |
sudo apt update
Expand All @@ -57,4 +54,4 @@ jobs:
run: |
python3 ./mach clippy --use-crown --locked -- -- --deny warnings
- name: Tidy
run: python3 ./mach test-tidy --no-progress --all
run: python3 ./mach test-tidy --no-progress --all
3 changes: 2 additions & 1 deletion .github/workflows/linux-wpt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ jobs:
path: ${{ inputs.profile }}-binary-linux
- name: unPackage binary
run: tar -xzf ${{ inputs.profile }}-binary-linux/target.tar.gz
- name: Setup Python
uses: ./.github/actions/setup-python
- name: Bootstrap dependencies
run: |
python3 -m pip install --upgrade pip
sudo apt update
sudo apt install -qy --no-install-recommends mesa-vulkan-drivers
python3 ./mach bootstrap --skip-lints
Expand Down
8 changes: 2 additions & 6 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,9 @@ jobs:
- name: Set LIBCLANG_PATH env # needed for bindgen in mozangle
if: ${{ ! fromJSON(needs.runner-select.outputs.is-self-hosted) && !inputs.upload }} # not needed on ubuntu 20.04 used for nightly
run: echo "LIBCLANG_PATH=/usr/lib/llvm-14/lib" >> $GITHUB_ENV
- uses: actions/setup-python@v5
- name: Setup Python
if: ${{ ! fromJSON(needs.runner-select.outputs.is-self-hosted) }}
with:
python-version: '3.10'
- name: Bootstrap Python
if: ${{ ! fromJSON(needs.runner-select.outputs.is-self-hosted) }}
run: python3 -m pip install --upgrade pip
uses: ./.github/actions/setup-python
- name: Bootstrap dependencies
if: ${{ ! fromJSON(needs.runner-select.outputs.is-self-hosted) }}
run: |
Expand Down
8 changes: 2 additions & 6 deletions .github/workflows/mac-wpt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,11 @@ jobs:
- uses: actions/download-artifact@v4
with:
name: ${{ inputs.profile }}-binary-macos
# Python 3.13 breaks wptrunner, so pin the version until
# web-platform-tests/wpt#48585 is fixed.
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Setup Python
uses: ./.github/actions/setup-python
- name: Prep test environment
run: |
gtar -xzf target.tar.gz
python3 -m pip install --upgrade pip
python3 ./mach bootstrap --skip-lints
- name: Smoketest
run: python3 ./mach smoketest --${{ inputs.profile }}
Expand Down
8 changes: 2 additions & 6 deletions .github/workflows/mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,14 @@ jobs:
if: github.event_name == 'pull_request_target'
with:
ref: ${{ github.event.pull_request.head.sha }}
# Python 3.13 breaks wptrunner, so pin the version until
# web-platform-tests/wpt#48585 is fixed.
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Setup Python
uses: ./.github/actions/setup-python
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
- name: Install crown
run: cargo install --path support/crown
- name: Bootstrap
run: |
python3 -m pip install --upgrade pip
python3 ./mach bootstrap --skip-lints
brew install gnu-tar
- name: Build (${{ inputs.profile }})
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@ jobs:
outputs:
configuration: ${{ steps.configuration.outputs.result }}
steps:
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- uses: actions/checkout@v4
with:
fetch-depth: 1
sparse-checkout: |
python/servo/try_parser.py
.github/actions/setup-python
.python-version
sparse-checkout-cone-mode: false
- name: Setup Python
uses: ./.github/actions/setup-python
- name: Get Configuration
id: configuration
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ohos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ jobs:
uses: mozilla-actions/[email protected]
- name: Install crown
run: cargo install --path support/crown
- name: Bootstrap Python
run: python3 -m pip install --upgrade pip virtualenv
- name: Setup Python
uses: ./.github/actions/setup-python
- name: Bootstrap dependencies
run: sudo apt update && python3 ./mach bootstrap --skip-lints
- name: Setup OpenHarmony SDK
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/pull-request-wpt-export.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@ jobs:
# using the token specified here.
# See https://github.com/actions/checkout/issues/162.
token: ${{ secrets.WPT_SYNC_TOKEN }}
- name: Setup Python
uses: ./.github/actions/setup-python
- name: Install requirements
run: pip install -r servo/python/requirements.txt
run: uv pip install -r servo/python/requirements.txt
- name: Process pull request
run: servo/python/wpt/export.py
run: |
source .venv/bin/activate
servo/python/wpt/export.py
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
WPT_SYNC_TOKEN: ${{ secrets.WPT_SYNC_TOKEN }}
3 changes: 2 additions & 1 deletion .github/workflows/scheduled-wpt-import.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ jobs:
- uses: actions/download-artifact@v4
with:
name: wpt-full-logs-linux-layout-2020
- name: Setup Python
uses: ./.github/actions/setup-python
- name: Prep environment
run: |
python3 -m pip install --upgrade pip
sudo apt update
python3 ./mach bootstrap
- name: Add upstream remote
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/try-label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,15 @@ jobs:
}
return try_string;
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- uses: actions/checkout@v4
with:
sparse-checkout: |
python/servo/try_parser.py
.github/actions/setup-python
.python-version
sparse-checkout-cone-mode: false
- name: Setup Python
uses: ./.github/actions/setup-python
- name: Parse Labels
if: ${{ steps.try_string.outputs.result }}
id: configuration
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/try.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,16 @@ jobs:
outputs:
configuration: ${{ steps.configuration.outputs.result }}
steps:
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- uses: actions/checkout@v4
with:
fetch-depth: 1
sparse-checkout: |
python/servo/try_parser.py
.github/actions/setup-python
.python-version
sparse-checkout-cone-mode: false
- name: Setup Python
uses: ./.github/actions/setup-python
- name: Get Full Configuration
id: full_config
run: |
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,12 @@ jobs:
choco install wixtoolset
echo "C:\\Program Files (x86)\\WiX Toolset v3.11\\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- uses: actions/setup-python@v5
- name: Setup Python
if: ${{ ! fromJSON(needs.runner-select.outputs.is-self-hosted) }}
with:
python-version: "3.10"
uses: ./.github/actions/setup-python
- name: Bootstrap
if: ${{ ! fromJSON(needs.runner-select.outputs.is-self-hosted) }}
run: |
python -m pip install --upgrade pip
python mach fetch
python mach bootstrap-gstreamer
# For some reason WiX isn't currently on the GitHub runner path. This is a
Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12.8
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,35 @@ For more detailed build instructions, see the Servo book under [Setting up your
[Building for Android]: https://book.servo.org/hacking/building-for-android.html
[Building for OpenHarmony]: https://book.servo.org/hacking/building-for-openharmony.html

**NOTE**: In the below steps, please ensure you install at least version 3 of python, preferably the latest version supported on your platform.
Servo will use its own pinned version of python, which it installs using [`uv`](https://docs.astral.sh/uv).
The system version is required for now just to bootstrap the process of creating and activating the virtual environment.

### macOS

- Download and install [`python`](https://www.python.org/downloads/macos/) (version 3.10 to 3.12), [Xcode](https://developer.apple.com/xcode/), and [`brew`](https://brew.sh/).
- Download and install [`python`](https://www.python.org/downloads/macos/), [Xcode](https://developer.apple.com/xcode/), and [`brew`](https://brew.sh/).
- Install `uv`: `curl -LsSf https://astral.sh/uv/install.sh | sh`
- Install `rustup`: `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh`
- Restart your shell to make sure `cargo` is available
- Install the other dependencies: `./mach bootstrap`
- Build servoshell: `./mach build`

### Linux

- Install `curl` and `python` (version 3.10 to 3.12):
- Arch: `sudo pacman -S --needed curl python python-pip`
- Debian, Ubuntu: `sudo apt install curl python3-pip python3-venv python3-setuptools`
- Fedora: `sudo dnf install curl python3 python3-pip python3-devel`
- Gentoo: `sudo emerge net-misc/curl dev-python/pip`
- Install `curl` and `python`:
- Arch: `sudo pacman -S --needed curl python`
- Debian, Ubuntu: `sudo apt install curl`
- Fedora: `sudo dnf install curl python3`
- Gentoo: `sudo emerge net-misc/curl`
- Install `uv`: `curl -LsSf https://astral.sh/uv/install.sh | sh`
- Install `rustup`: `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh`
- Restart your shell to make sure `cargo` is available
- Install the other dependencies: `./mach bootstrap`
- Build servoshell: `./mach build`

### Windows

- Download and install [`python`](https://www.python.org/downloads/windows/) (version 3.10 to 3.12), [`choco`](https://chocolatey.org/install#individual), and [`rustup`](https://win.rustup.rs/)
- Download and install [`python`](https://www.python.org/downloads/windows/), [`uv`](https://docs.astral.sh/uv/getting-started/installation/#standalone-installer), [`choco`](https://chocolatey.org/install#individual), and [`rustup`](https://win.rustup.rs/)
- Be sure to select *Quick install via the Visual Studio Community installer*
- In the Visual Studio Installer, ensure the following components are installed:
- **Windows 10 SDK (10.0.19041.0)** (`Microsoft.VisualStudio.Component.Windows10SDK.19041`)
Expand Down
14 changes: 8 additions & 6 deletions python/mach_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,8 @@ def install_virtual_env_requirements(project_path: str, python: str, virtualenv_
requirements_hash = requirements_hasher.hexdigest()

if marker_hash != requirements_hash:
print(" * Upgrading pip...")
_process_exec([python, "-m", "pip", "install", "--upgrade", "pip"])

print(" * Installing Python requirements...")
_process_exec([python, "-m", "pip", "install", "-I",
_process_exec(["uv", "pip", "install",
"-r", requirements_paths[0],
"-r", requirements_paths[1],
"-r", requirements_paths[2]])
Expand All @@ -144,14 +141,14 @@ def install_virtual_env_requirements(project_path: str, python: str, virtualenv_


def _activate_virtualenv(topdir):
virtualenv_path = os.path.join(topdir, "python", "_venv%d.%d" % (sys.version_info[0], sys.version_info[1]))
virtualenv_path = os.path.join(topdir, ".venv")
python = sys.executable

if os.environ.get("VIRTUAL_ENV") != virtualenv_path:
venv_script_path = os.path.join(virtualenv_path, _get_virtualenv_script_dir())
if not os.path.exists(virtualenv_path):
print(" * Setting up virtual environment...")
_process_exec([python, "-m", "venv", "--system-site-packages", virtualenv_path])
_process_exec(["uv", "venv"])

# This general approach is taken from virtualenv's `activate_this.py`.
os.environ["PATH"] = os.pathsep.join([venv_script_path, *os.environ.get("PATH", "").split(os.pathsep)])
Expand All @@ -171,6 +168,11 @@ def _activate_virtualenv(topdir):

install_virtual_env_requirements(topdir, python, virtualenv_path)

# Turn off warnings about deprecated syntax in our indirect dependencies.
# TODO: find a better approach to do this.
import warnings
warnings.filterwarnings('ignore', category=SyntaxWarning, module=r'.*.venv')


def _ensure_case_insensitive_if_windows():
# The folder is called 'python'. By deliberately checking for it with the wrong case, we determine if the file
Expand Down
1 change: 0 additions & 1 deletion servo-tidy.toml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ directories = [
"./tests/wpt/mozilla/tests/mozilla/referrer-policy",
"./tests/wpt/mozilla/tests/webgl",
"./python/tidy/tests",
"./python/_v*",
"./python/mach",
# Generated and upstream code combined with our own. Could use cleanup
"./target",
Expand Down
7 changes: 6 additions & 1 deletion shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,12 @@ stdenv.mkDerivation (androidEnvironment // {

# Build utilities
cmake dbus gcc git pkg-config which llvm perl yasm m4
(python3.withPackages (ps: with ps; [virtualenv pip dbus]))

# Ensure the Python version is same as the one in `.python-version` file so
# that `uv` will just symlink to the one in nix store. Otherwise `uv` will
# download a pre-built binary that won't work on nix.
(python312.withPackages (ps: with ps; [dbus]))
uv

# This pins gnumake to 4.3 since 4.4 breaks jobserver
# functionality in mozjs and causes builds to be extremely
Expand Down

0 comments on commit 1f0bad5

Please sign in to comment.