Skip to content

Commit

Permalink
Added support for armv7l (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lauszus authored Dec 12, 2024
1 parent 7c2c0c9 commit b160893
Show file tree
Hide file tree
Showing 15 changed files with 164 additions and 25 deletions.
92 changes: 84 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,47 +16,123 @@ 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
docker-platform: linux/amd64
- os: ubuntu-24.04
name: Linux aarch64
docker-platform: linux/arm64
- 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 != 'windows-arm64'
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Setup Python 3.12
if: matrix.os == 'linux-arm64'
run: |
python3.12 -m venv .venv
echo "$(pwd)/.venv/bin" >> "${GITHUB_PATH}"
- name: Setup Python 3.12
if: matrix.os == 'windows-arm64'
run: |
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-bookworm \
bash -c "
pip install nox &&
addgroup --gid $(id -g) build &&
adduser --disabled-password --gecos '' --gid $(id -g) --uid $(id -u) build &&
su build -c '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-bookworm \
bash -c "
pip install nox &&
addgroup --gid $(id -g) build &&
adduser --disabled-password --gecos '' --gid $(id -g) --uid $(id -u) build &&
su build -c '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-bookworm \
bash -c "
pip install nox &&
addgroup --gid $(id -g) build &&
adduser --disabled-password --gecos '' --gid $(id -g) --uid $(id -u) build &&
su build -c '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-bookworm \
bash -c "
pip install nox &&
addgroup --gid $(id -g) build &&
adduser --disabled-password --gecos '' --gid $(id -g) --uid $(id -u) build &&
su build -c 'nox -e doc linkcheck'
"
49 changes: 40 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,31 @@ 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
docker-platform: linux/amd64
- os: ubuntu-24.04
name: Linux aarch64
docker-platform: linux/arm64
- 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,28 +75,42 @@ jobs:
discussions: write
steps:
- name: Setup Python 3.12
if: matrix.os != 'linux-arm64' && matrix.os != 'windows-arm64'
if: matrix.docker-platform == '' && matrix.os != 'windows-arm64'
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Setup Python 3.12
if: matrix.os == 'linux-arm64'
run: |
python3.12 -m venv .venv
echo "$(pwd)/.venv/bin" >> "${GITHUB_PATH}"
- name: Setup Python 3.12
if: matrix.os == 'windows-arm64'
run: |
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-bookworm \
bash -c "
pip install nox &&
addgroup --gid $(id -g) build &&
adduser --disabled-password --gecos '' --gid $(id -g) --uid $(id -u) build &&
su build -c 'nox -e package'
"
- name: Generate science ${{ needs.determine-tag.outputs.release-tag }} artifact attestations
uses: actions/attest-build-provenance@v1
with:
Expand All @@ -90,7 +121,7 @@ jobs:
with:
changelog-file: ${{ github.workspace }}/CHANGES.md
version: ${{ needs.determine-tag.outputs.release-version }}
setup-python: ${{ matrix.os != 'linux-arm64' && matrix.os != 'windows-arm64' }}
setup-python: ${{ matrix.os != 'windows-arm64' }}
- name: Create ${{ needs.determine-tag.outputs.release-tag }} Release
uses: softprops/action-gh-release@v2
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
2 changes: 1 addition & 1 deletion science/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

from packaging.version import Version

__version__ = "0.8.2"
__version__ = "0.9.0"

VERSION = Version(__version__)
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
2 changes: 1 addition & 1 deletion tests/data/interpreter-groups.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "igs"
description = "Test interpreter group selection."

[lift.scie_jump]
version = "1.2.0"
version = "1.4.1"

[[lift.interpreters]]
id = "cpython310"
Expand Down
2 changes: 1 addition & 1 deletion tests/data/unrecognized-config-fields.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ version = "0.11.0"

[lift.scie_jump]
# N.B: `version2` is invalid, should be `version`.
version2 = "1.2.0"
version2 = "1.4.1"

[[lift.interpreters]]
id = "cpython310"
Expand Down
4 changes: 2 additions & 2 deletions tests/test_a_scie.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ def test_ptex_latest(tmp_path_factory: TempPathFactory) -> None:

def test_ptex_version(tmp_path_factory: TempPathFactory) -> None:
dest_dir = tmp_path_factory.mktemp("staging")
latest = a_scie.ptex(dest_dir=dest_dir, specification=Ptex(version=version.parse("1.2.0")))
latest = a_scie.ptex(dest_dir=dest_dir, specification=Ptex(version=version.parse("1.4.0")))
assert (
"1.2.0"
"1.4.0"
== subprocess.run(
args=[str(dest_dir / latest.name), "-V"], stdout=subprocess.PIPE, text=True, check=True
).stdout.strip()
Expand Down
6 changes: 4 additions & 2 deletions tests/test_exe.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def url_source_lift_toml_content(
[[lift.interpreters]]
id = "cpython311"
provider = "PythonBuildStandalone"
release = "20230116"
release = "20241206"
version = "3.11"
lazy = true
Expand Down Expand Up @@ -739,8 +739,10 @@ def test_invert_lazy_non_lazy(tmp_path: Path, science_exe: Path) -> None:
)


def working_pypy_versions():
def working_pypy_versions() -> list[str]:
match Platform.current():
case Platform.Linux_armv7l:
return []
case Platform.Macos_aarch64:
return ["2.7", "3.8", "3.9", "3.10"]
case Platform.Linux_aarch64:
Expand Down
9 changes: 9 additions & 0 deletions tests/test_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from _pytest.tmpdir import TempPathFactory

from science.os import IS_WINDOWS
from science.platform import Platform


@pytest.fixture(scope="module")
Expand All @@ -30,6 +31,10 @@ def test_installer_help(installer: list):
assert long_help in result.stdout, f"Expected '{long_help}' in tool output"


@pytest.mark.skipif(
Platform.current() == Platform.Linux_armv7l,
reason="TODO: Remove once 0.9.0 is released",
)
def test_installer_fetch_latest(tmp_path_factory: TempPathFactory, installer: list):
"""Invokes install.sh to fetch the latest science release binary, then invokes it."""
test_dir = tmp_path_factory.mktemp("install-test-default")
Expand All @@ -44,6 +49,10 @@ def test_installer_fetch_latest(tmp_path_factory: TempPathFactory, installer: li
assert result.stdout.strip(), "Expected version output in tool stdout"


@pytest.mark.skipif(
Platform.current() == Platform.Linux_armv7l,
reason="TODO: Remove once 0.9.0 is released",
)
def test_installer_fetch_argtest(tmp_path_factory: TempPathFactory, installer: list):
"""Exercises all the options in the installer."""
test_dir = tmp_path_factory.mktemp("install-test")
Expand Down

0 comments on commit b160893

Please sign in to comment.