Skip to content

Commit

Permalink
Add --scie support for Linux ppc64le and s390x. (#2635)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsirois authored Jan 3, 2025
1 parent ed02078 commit bf81c7a
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 10 deletions.
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Release Notes

## 2.28.0

This release adds Pex `--scie {eager,lazy}` support for Linux ppc64le
and s390x.

* Add `--scie` support for Linux ppc64le and s390x. (#2635)

## 2.27.1

This release fixes a bug in `PEX_ROOT` handling that could manifest
Expand Down
21 changes: 20 additions & 1 deletion pex/scie/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,10 @@ def __get__(self, obj, objtype=None):
self._current = SciePlatform.LINUX_AARCH64
elif machine in ("armv7l", "armv8l"):
self._current = SciePlatform.LINUX_ARMV7L
elif machine == "ppc64le":
self._current = SciePlatform.LINUX_PPC64LE
elif machine == "s390x":
self._current = SciePlatform.LINUX_S390X
elif machine in ("amd64", "x86_64"):
self._current = SciePlatform.LINUX_X86_64
elif "darwin" == system:
Expand Down Expand Up @@ -291,6 +295,8 @@ def qualified_file_name(self, file_name):

LINUX_AARCH64 = Value("linux-aarch64")
LINUX_ARMV7L = Value("linux-armv7l")
LINUX_PPC64LE = Value("linux-powerpc64")
LINUX_S390X = Value("linux-s390x")
LINUX_X86_64 = Value("linux-x86_64")
MACOS_AARCH64 = Value("macos-aarch64")
MACOS_X86_64 = Value("macos-x86_64")
Expand Down Expand Up @@ -445,15 +451,21 @@ def _from_platform_specs(
platform_str = platform_spec.platform
is_aarch64 = "arm64" in platform_str or "aarch64" in platform_str
is_armv7l = "armv7l" in platform_str or "armv8l" in platform_str
is_ppc64le = "ppc64le" in platform_str
is_s390x = "s390x" in platform_str
is_x86_64 = "amd64" in platform_str or "x86_64" in platform_str
if not is_aarch64 ^ is_armv7l ^ is_x86_64:
if not is_aarch64 ^ is_armv7l ^ is_ppc64le ^ is_s390x ^ is_x86_64:
continue

if "linux" in platform_str:
if is_aarch64:
scie_platform = SciePlatform.LINUX_AARCH64
elif is_armv7l:
scie_platform = SciePlatform.LINUX_ARMV7L
elif is_ppc64le:
scie_platform = SciePlatform.LINUX_PPC64LE
elif is_s390x:
scie_platform = SciePlatform.LINUX_S390X
else:
scie_platform = SciePlatform.LINUX_X86_64
elif "mac" in platform_str:
Expand Down Expand Up @@ -484,6 +496,13 @@ def _from_platform_specs(
# PyPy distributions are not available for Linux armv7l
if SciePlatform.LINUX_ARMV7L is scie_platform:
continue
# PyPy distributions for Linux ppc64le are only available for 2.7 and 3.{5,6}.
if (
SciePlatform.LINUX_PPC64LE is scie_platform
and plat_python_version[0] == 3
and plat_python_version >= (3, 7)
):
continue
# PyPy distributions for Mac arm64 start with 3.8 (and PyPy always releases for
# 2.7).
if (
Expand Down
6 changes: 3 additions & 3 deletions pex/scie/science.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def qualified_binary_name(self, binary_name):


SCIENCE_RELEASES_URL = "https://github.com/a-scie/lift/releases"
MIN_SCIENCE_VERSION = Version("0.9.0")
MIN_SCIENCE_VERSION = Version("0.10.0")
SCIENCE_REQUIREMENT = SpecifierSet("~={min_version}".format(min_version=MIN_SCIENCE_VERSION))


Expand All @@ -78,8 +78,8 @@ def _science_binary_url(suffix=""):
)


PTEX_VERSION = "1.4.0"
SCIE_JUMP_VERSION = "1.4.1"
PTEX_VERSION = "1.5.0"
SCIE_JUMP_VERSION = "1.5.0"


@attr.s(frozen=True)
Expand Down
2 changes: 1 addition & 1 deletion pex/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2015 Pex project contributors.
# Licensed under the Apache License, Version 2.0 (see LICENSE).

__version__ = "2.27.1"
__version__ = "2.28.0"
2 changes: 0 additions & 2 deletions testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,8 @@
IS_MAC = platform.system() == "Darwin"
IS_X86_64 = platform.machine().lower() in ("amd64", "x86_64")
IS_ARM_64 = platform.machine().lower() in ("arm64", "aarch64")
IS_ARMV7L = platform.machine().lower() in ("armv7l", "armv8l")
IS_LINUX_X86_64 = IS_LINUX and IS_X86_64
IS_LINUX_ARM64 = IS_LINUX and IS_ARM_64
IS_LINUX_ARMV7L = IS_LINUX and IS_ARMV7L
IS_MAC_X86_64 = IS_MAC and IS_X86_64
IS_MAC_ARM64 = IS_MAC and IS_ARM_64
NOT_CPYTHON27_OR_OSX = NOT_CPYTHON27 or not IS_LINUX
Expand Down
20 changes: 17 additions & 3 deletions tests/integration/scie/test_pex_scie.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ def create_scies(
"--platform",
"linux-armv7l-cp-311-cp311",
"--platform",
"linux-ppc64le-cp-312-cp312",
"--platform",
"linux-s390x-cp-313-cp313",
"--platform",
"linux-x86_64-cp-310-cp310",
"--platform",
"macosx-10.9-arm64-cp-311-cp311",
Expand All @@ -175,6 +179,8 @@ def create_scies(
python_version_by_platform = {
SciePlatform.LINUX_AARCH64: "3.9",
SciePlatform.LINUX_ARMV7L: "3.11",
SciePlatform.LINUX_PPC64LE: "3.12",
SciePlatform.LINUX_S390X: "3.13",
SciePlatform.LINUX_X86_64: "3.10",
SciePlatform.MACOS_AARCH64: "3.11",
SciePlatform.MACOS_X86_64: "3.12",
Expand Down Expand Up @@ -232,13 +238,15 @@ def assert_platforms(
expected_platforms=(
SciePlatform.LINUX_AARCH64,
SciePlatform.LINUX_ARMV7L,
SciePlatform.LINUX_PPC64LE,
SciePlatform.LINUX_S390X,
SciePlatform.LINUX_X86_64,
SciePlatform.MACOS_AARCH64,
SciePlatform.MACOS_X86_64,
),
)

# Now restrict the PEX's implied natural platform set of 5 down to 2 or 3 using
# Now restrict the PEX's implied natural platform set of 7 down to 2 or 3 using
# `--scie-platform`.
restricted_platforms_output_dir = os.path.join(str(tmpdir), "restricted-platforms")
create_scies(
Expand Down Expand Up @@ -302,7 +310,7 @@ def test_specified_science_binary(tmpdir):

local_science_binary = os.path.join(str(tmpdir), "science")
with open(local_science_binary, "wb") as write_fp, URLFetcher().get_body_stream(
"https://github.com/a-scie/lift/releases/download/v0.9.0/{binary}".format(
"https://github.com/a-scie/lift/releases/download/v0.10.0/{binary}".format(
binary=SciePlatform.CURRENT.qualified_binary_name("science")
)
) as read_fp:
Expand Down Expand Up @@ -346,7 +354,7 @@ def test_specified_science_binary(tmpdir):
cached_science_binaries
), "Expected the local science binary to be used but not cached."
assert (
"0.9.0"
"0.10.0"
== subprocess.check_output(args=[local_science_binary, "--version"]).decode("utf-8").strip()
)

Expand Down Expand Up @@ -394,6 +402,8 @@ def make_20240415_3_10_14_url(platform):
"x86_64-apple-darwin",
"aarch64-unknown-linux-gnu",
"armv7-unknown-linux-gnueabihf",
"ppc64le-unknown-linux-gnu",
"s390x-unknown-linux-gnu",
"x86_64-unknown-linux-gnu",
)
}
Expand All @@ -419,6 +429,10 @@ def make_20240415_3_10_14_url(platform):
expected_platform = "aarch64-unknown-linux-gnu"
elif SciePlatform.CURRENT is SciePlatform.LINUX_ARMV7L:
expected_platform = "armv7-unknown-linux-gnueabihf"
elif SciePlatform.CURRENT is SciePlatform.LINUX_PPC64LE:
expected_platform = "ppc64le-unknown-linux-gnu"
elif SciePlatform.CURRENT is SciePlatform.LINUX_S390X:
expected_platform = "s390x-unknown-linux-gnu"
elif SciePlatform.CURRENT is SciePlatform.LINUX_X86_64:
expected_platform = "x86_64-unknown-linux-gnu"
elif SciePlatform.CURRENT is SciePlatform.MACOS_AARCH64:
Expand Down
2 changes: 2 additions & 0 deletions tests/test_pep_508.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ def assert_platform_machine(
assert_platform_machine("x86_64", "manylinux_2_5-x86_64-cp-37-cp37m")
assert_platform_machine("aarch64", "manylinux_2_77-aarch64-cp-37-cp37m")
assert_platform_machine("armv7l", "linux-armv7l-cp-311-cp311")
assert_platform_machine("ppc64le", "linux-ppc64le-cp-312-cp312")
assert_platform_machine("s390x", "linux-s390x-cp-313-cp313")

assert_platform_machine("x86_64", "macosx-10.15-x86_64-cp-38-m")
assert_platform_machine("arm64", "macosx-11.0-arm64-cp-39-cp39")

0 comments on commit bf81c7a

Please sign in to comment.