Skip to content

Commit

Permalink
Added support for armv7l
Browse files Browse the repository at this point in the history
  • Loading branch information
Lauszus committed Dec 11, 2024
1 parent 7c2c0c9 commit 349b216
Show file tree
Hide file tree
Showing 9 changed files with 131 additions and 7 deletions.
77 changes: 74 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,34 @@ jobs:
- name: Noop
run: "true"
ci:
name: (${{ matrix.os }}) CI
name: (${{ matrix.name }}) CI
needs: org-check
runs-on: ${{ matrix.os }}
strategy:
matrix:
# N.B.: macos-13 is the oldest non-deprecated Intel Mac runner and macos-14 is the oldest
# non-deprecated ARM Mac runner.
os: [ ubuntu-22.04, linux-arm64, macos-13, macos-14, windows-2022, windows-arm64 ]
include:
- os: ubuntu-24.04
name: Linux x86-64
- os: linux-arm64
name: Linux aarch64
- os: ubuntu-24.04
name: Linux armv7l
docker-platform: linux/arm/v7
- os: macos-13
name: macOS x86-64
- os: macos-14
name: macOS aarch64
- os: windows-2022
name: Windows x86-64
- os: windows-arm64
name: Windows aarch64
env:
SCIENCE_AUTH_API_GITHUB_COM_BEARER: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Setup Python 3.12
if: matrix.os != 'linux-arm64' && matrix.os != 'windows-arm64'
if: matrix.docker-platform == '' && matrix.os != 'linux-arm64' && matrix.os != 'windows-arm64'
uses: actions/setup-python@v5
with:
python-version: 3.12
Expand All @@ -43,20 +58,76 @@ jobs:
py -3.12 -m venv .venv
echo "$(pwd)/.venv/Scripts" >> "${GITHUB_PATH}"
- name: Setup Nox
if: matrix.docker-platform == ''
run: pip install nox
- name: Installing emulators
if: matrix.docker-platform != ''
run: docker run --privileged --rm tonistiigi/binfmt --install all
- name: Checkout Lift
uses: actions/checkout@v4
- name: Check Formatting & Lints
if: matrix.docker-platform == ''
run: nox -e lint
- name: Check Formatting & Lints
if: matrix.docker-platform != ''
run: |
docker run --rm \
-v $PWD:/code \
-w /code \
--platform ${{ matrix.docker-platform }} \
python:3.12-slim-bookworm \
bash -c "
pip install nox &&
nox -e lint
"
- name: Configure Windows pytest short tmp dir path
if: matrix.os == 'windows-2022' || matrix.os == 'windows-arm64'
run: |
mkdir -p C:/tmp/gha
echo PYTEST_ADDOPTS="--basetemp C:/tmp/gha/pytest" >> ${GITHUB_ENV}
echo SCIE_BASE=C:/tmp/gha/nce >> ${GITHUB_ENV}
- name: Unit Tests
if: matrix.docker-platform == ''
run: nox -e test -- -vvs
- name: Unit Tests
if: matrix.docker-platform != ''
run: |
docker run --rm \
-v $PWD:/code \
-w /code \
--platform ${{ matrix.docker-platform }} \
python:3.12-slim-bookworm \
bash -c "
pip install nox &&
nox -e test -- -vvs
"
- name: Build & Package
if: matrix.docker-platform == ''
run: nox -e package
- name: Build & Package
if: matrix.docker-platform != ''
run: |
docker run --rm \
-v $PWD:/code \
-w /code \
--platform ${{ matrix.docker-platform }} \
python:3.12-slim-bookworm \
bash -c "
pip install nox &&
nox -e package
"
- name: Generate Doc Site
if: matrix.docker-platform == ''
run: nox -e doc linkcheck
- name: Generate Doc Site
if: matrix.docker-platform != ''
run: |
docker run --rm \
-v $PWD:/code \
-w /code \
--platform ${{ matrix.docker-platform }} \
python:3.12-slim-bookworm \
bash -c "
pip install nox &&
nox -e doc linkcheck
"
38 changes: 35 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,29 @@ jobs:
exit 1
fi
github-release:
name: (${{ matrix.os }}) Create Github Release
name: (${{ matrix.name }}) Create Github Release
needs: determine-tag
runs-on: ${{ matrix.os }}
strategy:
matrix:
# N.B.: macos-13 is the oldest non-deprecated Intel Mac runner and macos-14 is the oldest
# non-deprecated ARM Mac runner.
os: [ ubuntu-22.04, linux-arm64, macos-13, macos-14, windows-2022, windows-arm64 ]
include:
- os: ubuntu-24.04
name: Linux x86-64
- os: linux-arm64
name: Linux aarch64
- os: ubuntu-24.04
name: Linux armv7l
docker-platform: linux/arm/v7
- os: macos-13
name: macOS x86-64
- os: macos-14
name: macOS aarch64
- os: windows-2022
name: Windows x86-64
- os: windows-arm64
name: Windows aarch64
environment: Release
env:
SCIENCE_AUTH_API_GITHUB_COM_BEARER: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -58,7 +73,7 @@ jobs:
discussions: write
steps:
- name: Setup Python 3.12
if: matrix.os != 'linux-arm64' && matrix.os != 'windows-arm64'
if: matrix.docker-platform == '' && matrix.os != 'linux-arm64' && matrix.os != 'windows-arm64'
uses: actions/setup-python@v5
with:
python-version: 3.12
Expand All @@ -73,13 +88,30 @@ jobs:
py -3.12 -m venv .venv
echo "$(pwd)/.venv/Scripts" >> "${GITHUB_PATH}"
- name: Setup Nox
if: matrix.docker-platform == ''
run: pip install nox
- name: Installing emulators
if: matrix.docker-platform != ''
run: docker run --privileged --rm tonistiigi/binfmt --install all
- name: Checkout lift ${{ needs.determine-tag.outputs.release-tag }}
uses: actions/checkout@v4
with:
ref: ${{ needs.determine-tag.outputs.release-tag }}
- name: Package science ${{ needs.determine-tag.outputs.release-tag }} binary
if: matrix.docker-platform == ''
run: nox -e package
- name: Package science ${{ needs.determine-tag.outputs.release-tag }} binary
if: matrix.docker-platform != ''
run: |
docker run --rm \
-v $PWD:/code \
-w /code \
--platform ${{ matrix.docker-platform }} \
python:3.12-slim-bookworm \
bash -c "
pip install nox &&
nox -e package
"
- name: Generate science ${{ needs.determine-tag.outputs.release-tag }} artifact attestations
uses: actions/attest-build-provenance@v1
with:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ __pycache__/

# Our Sphinx extension (see: docs/_ext/) dynamically generates doc sources here.
/docs/_/

# IntelliJ projects.
.idea/
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release Notes

## 0.9.0

This release adds support for Linux ARM (armv7l and armv8l 32 bit mode).

## 0.8.2

Upgrade the science internal Python distribution to [PBS][PBS] CPython 3.12.8.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ You'll need to download the correct binary for your system, mark it as executabl
your $PATH somewhere.

The binaries are released via [GitHub Releases](https://github.com/a-scie/lift/releases)
for Windows, Linux and macOS for both aarch64 and x86-64. For each of these platforms
for Windows, Linux and macOS for both armv7l (Linux only), aarch64 and x86-64. For each of these platforms
there are two varieties, "thin" and "fat". The "fat" varieties are named `science-fat-*`, include
a hermetic CPython 3.12 distribution from the [Python Build Standalone]() project and are larger as
a result. The "thin" varieties have the CPython 3.12 distribution gouged out and are smaller as a
Expand Down
2 changes: 2 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ function determine_arch() {
amd64*) echo "x86_64" ;;
arm64*) echo "aarch64" ;;
aarch64*) echo "aarch64" ;;
armv7l*) echo "armv7l" ;;
armv8l*) echo "armv7l" ;;
*) die "unknown arch: ${read_arch}" ;;
esac
}
Expand Down
3 changes: 3 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def current(cls) -> OperatingSystem:
if OperatingSystem.WINDOWS is OS
else platform.machine().lower()
) in ("aarch64", "arm64")
IS_ARMV7L = platform.machine().lower() in ("armv7l", "armv8l")


def check_lift_manifest(session: Session):
Expand Down Expand Up @@ -296,6 +297,8 @@ def nox_session() -> Callable[[Callable[[Session], T]], Callable[[Session], T]]:
if OperatingSystem.LINUX is OS:
if IS_ARM64:
target_triple = "aarch64-unknown-linux-gnu"
elif IS_ARMV7L:
target_triple = "armv7-unknown-linux-gnueabihf"
else:
target_triple = "x86_64-unknown-linux-gnu"
elif OperatingSystem.MAC is OS:
Expand Down
3 changes: 3 additions & 0 deletions science/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

class Platform(Enum):
Linux_aarch64 = "linux-aarch64"
Linux_armv7l = "linux-armv7l"
Linux_x86_64 = "linux-x86_64"
Macos_aarch64 = "macos-aarch64"
Macos_x86_64 = "macos-x86_64"
Expand All @@ -33,6 +34,8 @@ def current(cls) -> Platform:
match (system := platform.system().lower(), machine := platform.machine().lower()):
case ("linux", "aarch64" | "arm64"):
return cls.Linux_aarch64
case ("linux", "armv7l" | "armv8l"):
return cls.Linux_armv7l
case ("linux", "amd64" | "x86_64"):
return cls.Linux_x86_64
case ("darwin", "aarch64" | "arm64"):
Expand Down
6 changes: 6 additions & 0 deletions science/providers/python_build_standalone.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ def rank_compatibility(platform: Platform, target_triple: str) -> int | None:
match target_triple:
case "aarch64-unknown-linux-gnu":
return 0
case Platform.Linux_armv7l:
match target_triple:
case "armv7-unknown-linux-gnueabihf":
return 0
case "armv7-unknown-linux-gnueabi":
return 1
case Platform.Linux_x86_64:
match target_triple:
case "x86_64-unknown-linux-gnu":
Expand Down

0 comments on commit 349b216

Please sign in to comment.