Skip to content

Commit

Permalink
Add linux aarch64 wheel build support
Browse files Browse the repository at this point in the history
Signed-off-by: odidev <odidev@puresoftware.com>
  • Loading branch information
odidev committed Sep 14, 2021
1 parent e02b59f commit 7dd8e3d
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 5 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,56 @@ jobs:
name: Deploy to S3
run: ./build-support/bin/deploy_to_s3.py
timeout-minutes: 65
build_wheels_aarch64:
name: Build aarch64 wheels and fs_util (Linux)
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
pyver: [cp37-cp37m, cp38-cp38, cp39-cp39]
env:
PANTS_REMOTE_CACHE_READ: 'false'
PANTS_REMOTE_CACHE_WRITE: 'false'
img: quay.io/pypa/manylinux2014_aarch64
if: ${{ github.repository_owner == 'pantsbuild' }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 10
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v1
- name: Install dependencies
run: |
docker run --rm -v ${{ github.workspace }}:/ws:rw --workdir=/ws \
${{ env.img }} \
bash -exc 'curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -v -y --default-toolchain none && \
export PATH=$HOME/.cargo/bin:${PATH} && \
rustup --version && \
export MODE=debug && \
if \[ ${{ matrix.pyver }} == cp37-cp37m \] ; then
./build-support/bin/release.sh build-wheels
elif \[ ${{ matrix.pyver }} == cp38-cp38 \] ; then
export USE_PY38=true;
./build-support/bin/release.sh build-wheels;
else
export USE_PY39=true;
./build-support/bin/release.sh build-wheels;
fi && \
./build-support/bin/release.sh build-fs-util'
- if: always()
name: Upload pants.log
uses: actions/upload-artifact@v2
with:
name: pants-log-wheels-linux
path: .pants.d/pants.log
- env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
if: github.event_name == 'push'
name: Deploy to S3
run: ./build-support/bin/deploy_to_s3.py
build_wheels_macos:
env:
PANTS_REMOTE_CACHE_READ: 'false'
Expand Down
6 changes: 3 additions & 3 deletions build-support/bin/_release_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ def build_pex(fetch: bool) -> None:
if fetch:
extra_pex_args = [
f"--platform={plat}-{abi}"
for plat in ("linux_x86_64", "macosx_10.15_x86_64")
for plat in ("linux_x86_64", "linux_aarch64", "macosx_10.15_x86_64")
for abi in ("cp-37-m", "cp-38-cp38", "cp-39-cp39")
]
pex_name = f"pants.{CONSTANTS.pants_unstable_version}.pex"
Expand Down Expand Up @@ -918,10 +918,10 @@ def check_pants_wheels_present(check_dir: str | Path) -> None:
if not local_files:
missing_packages.append(package.name)
continue
if is_cross_platform(local_files) and len(local_files) != 6:
if is_cross_platform(local_files) and len(local_files) != 9:
formatted_local_files = ", ".join(f.name for f in local_files)
missing_packages.append(
f"{package.name} (expected 6 wheels, {{macosx, linux}} x {{cp37m, cp38, cp39}}, "
f"{package.name} (expected 9 wheels, {{macosx, linux_x86_64, linux_arm64}} x {{cp37m, cp38, cp39}}, "
f"but found {formatted_local_files})"
)
if missing_packages:
Expand Down
2 changes: 1 addition & 1 deletion src/python/pants/backend/python/util_rules/pex_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def default_known_versions(cls):
"3640830",
)
)
for plat in ["macos_arm64", "macos_x86_64", "linux_x86_64"]
for plat in ["macos_arm64", "macos_x86_64", "linux_x86_64", "linux_arm64"]
]


Expand Down
4 changes: 4 additions & 0 deletions src/python/pants/base/exception_sink_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ def test_set_invalid_log_location():
"Error opening fatal error log streams for log location '/': [Errno 13] Permission "
"denied: '/.pids'"
),
Platform.linux_arm64: (
"Error opening fatal error log streams for log location '/': [Errno 13] Permission "
"denied: '/.pids'"
),
}
assert match(Platform.current, err_str) in str(exc.value)

Expand Down
1 change: 1 addition & 0 deletions src/python/pants/engine/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Platform(Enum):
linux_x86_64 = "linux_x86_64"
macos_arm64 = "macos_arm64"
macos_x86_64 = "macos_x86_64"
linux_arm64 = "linux_arm64"

@property
def is_macos(self) -> bool:
Expand Down
6 changes: 5 additions & 1 deletion src/python/pants/option/global_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from __future__ import annotations

import enum
import platform
import importlib
import logging
import os
Expand Down Expand Up @@ -391,7 +392,10 @@ class LocalStoreOptions:

store_dir: str = os.path.join(get_pants_cachedir(), "lmdb_store")
processes_max_size_bytes: int = 16 * GIGABYTES
files_max_size_bytes: int = 256 * GIGABYTES
if platform.machine() != "aarch64":
files_max_size_bytes: int = 256* GIGABYTES
else:
files_max_size_bytes: int = 128 * GIGABYTES
directories_max_size_bytes: int = 16 * GIGABYTES
shard_count: int = 16

Expand Down
10 changes: 10 additions & 0 deletions src/rust/engine/process_execution/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ pub enum Platform {
Macos_x86_64,
Macos_arm64,
Linux_x86_64,
Linux_arm64,
}

impl Platform {
Expand All @@ -91,6 +92,13 @@ impl Platform {
} if sysname.to_lowercase() == "linux" && machine.to_lowercase() == "x86_64" => {
Ok(Platform::Linux_x86_64)
}
uname::Info {
ref sysname,
ref machine,
..
} if sysname.to_lowercase() == "linux" && machine.to_lowercase() == "aarch64" => {
Ok(Platform::Linux_arm64)
}
uname::Info {
ref sysname,
ref machine,
Expand Down Expand Up @@ -121,6 +129,7 @@ impl From<Platform> for String {
fn from(platform: Platform) -> String {
match platform {
Platform::Linux_x86_64 => "linux_x86_64".to_string(),
Platform::Linux_arm64 => "linux_arm64".to_string(),
Platform::Macos_arm64 => "macos_arm64".to_string(),
Platform::Macos_x86_64 => "macos_x86_64".to_string(),
}
Expand All @@ -134,6 +143,7 @@ impl TryFrom<String> for Platform {
"macos_arm64" => Ok(Platform::Macos_arm64),
"macos_x86_64" => Ok(Platform::Macos_x86_64),
"linux_x86_64" => Ok(Platform::Linux_x86_64),
"linux_arm64" => Ok(Platform::Linux_arm64),
other => Err(format!(
"Unknown platform {:?} encountered in parsing",
other
Expand Down

0 comments on commit 7dd8e3d

Please sign in to comment.