Skip to content

Commit

Permalink
Upgrade to v8 13.2 and use native aarch64 runners
Browse files Browse the repository at this point in the history
  • Loading branch information
bpcreech committed Feb 2, 2025
1 parent cbe0447 commit f9f0ae2
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 42 deletions.
59 changes: 28 additions & 31 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,44 +32,41 @@ jobs:
- name: Build
run: python -m build --sdist

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: sdist
path: dist/*
if-no-files-found: error

# We build for Linux using uraimo/run-on-arch-action@v2, which runs a container under
# the runner in order to reach different platforms (notably Alpine with its musl) and
# architectures (notably aarch64) via emulation. uraimo/run-on-arch-action@v2 doesn't
# support Mac or Windows, so we run a separate job for those.
# architectures. uraimo/run-on-arch-action@v2 doesn't support Mac or Windows, so we
# run a separate job for those.
linux-wheels:
name: Build wheel for ${{ matrix.image }}
runs-on: ubuntu-latest
name: Build wheel for ${{ matrix.config.image }} on ${{ matrix.config.os }}
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
image:
config:
# To maximize compatibility of generated wheels, we should theoreticaly build
# on the *oldest* supported distros.
# But V8 ships its own bullseye sysroot and links against that, so we may as
# well run on bullseye (even though buster would provide an older supported
# build distro):
- debian:bullseye
- arm64v8/debian:bullseye
# Alpine 3.19 includes a clang new enough for V8 to build (with only minor
# patches!). Builds on 3.19 seem incompatible with <= 3.18 due to libstdc++
# symbols. (And we can't just run on an old Alpine and update clang from the
# llvm site, because unlike Debian, the llvm project doesn't maintain
# updated packages for old Alpine distros.)
- alpine:3.19
- arm64v8/alpine:3.19
exclude:
# The aarch64 builds run really slowly, so let's skip them except for
# releases.
# For more info on this GitHub Actions hack, see:
# https://stackoverflow.com/questions/65384420/how-do-i-make-a-github-action-matrix-element-conditional#answer-73822998
- image: ${{ !startsWith(github.ref, 'refs/heads/release/') && 'arm64v8/debian:bullseye' }}
- image: ${{ !startsWith(github.ref, 'refs/heads/release/') && 'arm64v8/alpine:3.19' }}
- os: ubuntu-latest # x86_64 base OS (on which we run a container)
image: debian:bullseye
- os: ubuntu-latest
# Alpine 3.19 includes a clang new enough for V8 to build (with only minor
# patches!). Builds on 3.19 seem incompatible with <= 3.18 due to libstdc++
# symbols. (And we can't just run on an old Alpine and update clang from the
# llvm site, because unlike Debian, the llvm project doesn't maintain
# updated packages for old Alpine distros.)
image: alpine:3.19
- os: ubuntu-24.04-arm
image: bullseye
- os: ubuntu-24.04-arm
image: alpine:3.19

steps:
- name: Configure git
Expand All @@ -90,7 +87,7 @@ jobs:
with:
arch: none
distro: none
base_image: ${{ matrix.image }}
base_image: ${{ matrix.config.image }}

setup: |
mkdir -p "${PWD}/wheels"
Expand All @@ -101,7 +98,7 @@ jobs:
shell: /bin/sh

install: |
case "${{ matrix.image }}" in
case "${{ matrix.config.image }}" in
*debian*)
# Let's download some system packages!
# Note that the precise list of packages we need is intertwined not just
Expand Down Expand Up @@ -232,7 +229,7 @@ jobs:
cp dist/*.whl /wheels/
chmod a+rwx /wheels/*.whl
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: wheels
path: ./wheels/*
Expand All @@ -243,7 +240,7 @@ jobs:
with:
arch: none
distro: none
base_image: ${{ matrix.image }}
base_image: ${{ matrix.config.image }}

setup: |
mkdir -p "${PWD}/wheels"
Expand All @@ -254,7 +251,7 @@ jobs:
shell: /bin/sh

install: |
case "${{ matrix.image }}" in
case "${{ matrix.config.image }}" in
*debian*)
PACKAGES=""
PACKAGES="${PACKAGES} python3"
Expand All @@ -280,7 +277,7 @@ jobs:
python3 -m venv /venv
. /venv/bin/activate
case "${{ matrix.image }}" in
case "${{ matrix.config.image }}" in
*debian*)
python3 -m pip install --upgrade hatch hatch-fancy-pypi-readme hatch-mkdocs
hatch run testinstalled:install /wheels/*.whl
Expand Down Expand Up @@ -336,7 +333,7 @@ jobs:
python3 -m pip install --upgrade build
python3 -m build --wheel
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: wheels
path: dist/*
Expand All @@ -359,7 +356,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4

- name: Compute release version
run: |
Expand All @@ -386,7 +383,7 @@ jobs:
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4

- name: Make dist directory
run: mkdir dist && cp wheels/* sdist/* dist/
Expand Down
9 changes: 7 additions & 2 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ PyMiniRacer!) which wants to integrate V8 must first build it.
### Build PyPI wheels

Because V8 takes so long to build (about 2-3 hours at present on the free GitHub Actions
runners, and >12 hours when emulating `aarch64` on them), we want to build wheels for
PyPI. We don't want folks to have to build V8 when they `pip install mini-racer`!
runners), we want to build wheels for PyPI. We don't want folks to have to build V8 when
they `pip install mini-racer`!

We build wheels for many operating systems and architectures based on popular demand via
GitHib issues. Currently the list is
Expand Down Expand Up @@ -238,6 +238,11 @@ wouldn't simplify the overall workflow management.

### Use `sccache` to patch around build timeouts

**Update: We still use `sscache` but with
[the new Github-hosted `aarch64` runners](https://github.com/actions/runner-images/issues/10820),
this should no longer be strictly required. We no longer run builds on emulation as
discussed below.**

As of this writing, the Linux `aarch64` builds run on emulation becaues GitHub Actions
has no free hosted `aarch64` runners for Linux. This makes them so slow, they struggle
to complete at all. They take about 24 hours to run. The GitHub Actions
Expand Down
2 changes: 1 addition & 1 deletion hatch_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# During env initialization the PYTHONPATH doesn't include our helpers, so
# give it some help:
syspath.append(dirname(__file__))
from helpers.v8_build import build_v8, clean_v8, get_platform_tag
from helpers.v8_build import build_v8, clean_v8, get_platform_tag # noqa: E402


class V8BuildHook(BuildHookInterface[BuilderConfig]):
Expand Down
2 changes: 1 addition & 1 deletion helpers/v8_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
LOGGER = getLogger(__name__)
LOGGER.setLevel(DEBUG)
ROOT_DIR = dirname(abspath(__file__))
V8_VERSION = "branch-heads/12.6"
V8_VERSION = "branch-heads/13.2"


def local_path(path="."):
Expand Down
6 changes: 3 additions & 3 deletions src/py_mini_racer/_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,9 @@ async def run_one(params: JSArray) -> None:
err = err_maker(s)
reject(err)

pending: set[Task[PythonJSConvertedTypes | JSEvalException] | Future[bool]] = (
set()
)
pending: set[
Task[PythonJSConvertedTypes | JSEvalException] | Future[bool]
] = set()

def process(params: PythonJSConvertedTypes | JSEvalException) -> None:
params = cast(JSArray, params)
Expand Down
2 changes: 1 addition & 1 deletion src/py_mini_racer/_mini_racer.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def v8_version(self) -> str:
"""Return the V8 version string."""
return self._ctx.v8_version()

def eval(
def eval( # noqa: A003
self,
code: str,
timeout: Numeric | None = None,
Expand Down
6 changes: 3 additions & 3 deletions src/py_mini_racer/_value_handle.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,16 @@ class MiniRacerTypes:

invalid = 0
null = 1
bool = 2
bool = 2 # noqa: A003
integer = 3
double = 4
str_utf8 = 5
array = 6
# deprecated:
hash = 7
hash = 7 # noqa: A003
date = 8
symbol = 9
object = 10
object = 10 # noqa: A003
undefined = 11

function = 100
Expand Down

0 comments on commit f9f0ae2

Please sign in to comment.