Skip to content

Commit

Permalink
Add additional ARM targets to release (#2417)
Browse files Browse the repository at this point in the history
Closes #2415.
Closes #2416.
  • Loading branch information
charliermarsh authored Mar 15, 2024
1 parent fbb8bc1 commit c296da3
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 23 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/build-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,10 @@ jobs:
maturin_docker_options: -e JEMALLOC_SYS_WITH_LG_PAGE=16
- target: armv7-unknown-linux-gnueabihf
arch: armv7
- target: armv7-unknown-linux-musleabihf
arch: armv7
- target: arm-unknown-linux-musleabihf
arch: arm

steps:
- uses: actions/checkout@v4
Expand All @@ -284,15 +288,15 @@ jobs:
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
manylinux: 2_28
# On `aarch64`, use `manylinux: 2_28`; otherwise, use `manylinux: auto`.
manylinux: ${{ matrix.platform.arch == 'aarch64' && '2_28' || 'auto' }}
docker-options: ${{ matrix.platform.maturin_docker_options }}
args: --release --locked --out dist
- uses: uraimo/run-on-arch-action@v2
if: matrix.platform.arch != 'ppc64'
name: Test wheel
with:
arch: ${{ matrix.platform.arch }}
distro: ubuntu20.04
arch: ${{ matrix.platform.arch == 'arm' && 'armv6' || matrix.platform.arch }}
distro: ${{ matrix.platform.arch == 'arm' && 'bullseye' || 'ubuntu20.04' }}
githubToken: ${{ github.token }}
install: |
apt-get update
Expand All @@ -302,6 +306,8 @@ jobs:
pip3 install ${{ env.PACKAGE_NAME }} --no-index --find-links dist/ --force-reinstall
${{ env.MODULE_NAME }} --help
- name: "Upload wheels"
# Skip for `arm`, which is not supported by PyPI.
if: ${{ matrix.platform.arch != 'arm' }}
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.platform.target }}
Expand Down Expand Up @@ -534,8 +540,6 @@ jobs:
- target: aarch64-unknown-linux-musl
arch: aarch64
maturin_docker_options: -e JEMALLOC_SYS_WITH_LG_PAGE=16
- target: armv7-unknown-linux-musleabihf
arch: armv7

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ windows-archive = ".zip"
# The archive format to use for non-windows builds (defaults .tar.xz)
unix-archive = ".tar.gz"
# Target platforms to build apps for (Rust target-triple syntax)
targets = ["aarch64-unknown-linux-gnu", "x86_64-unknown-linux-gnu", "i686-unknown-linux-gnu", "aarch64-apple-darwin", "x86_64-apple-darwin", "aarch64-unknown-linux-musl", "x86_64-unknown-linux-musl", "i686-unknown-linux-musl", "x86_64-pc-windows-msvc", "i686-pc-windows-msvc", "armv7-unknown-linux-gnueabihf", "powerpc64-unknown-linux-gnu", "powerpc64le-unknown-linux-gnu", "s390x-unknown-linux-gnu"]
targets = ["aarch64-unknown-linux-gnu", "x86_64-unknown-linux-gnu", "i686-unknown-linux-gnu", "aarch64-apple-darwin", "x86_64-apple-darwin", "aarch64-unknown-linux-musl", "x86_64-unknown-linux-musl", "i686-unknown-linux-musl", "x86_64-pc-windows-msvc", "i686-pc-windows-msvc", "armv7-unknown-linux-gnueabihf", "powerpc64-unknown-linux-gnu", "powerpc64le-unknown-linux-gnu", "s390x-unknown-linux-gnu", "armv7-unknown-linux-musleabihf", "arm-unknown-linux-musleabihf"]
# Whether to auto-include files like READMEs and CHANGELOGs (default true)
auto-includes = false
# Whether cargo-dist should create a Github Release or use an existing draft
Expand Down
15 changes: 11 additions & 4 deletions crates/platform-tags/src/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ impl fmt::Display for Os {
pub enum Arch {
#[serde(alias = "arm64")]
Aarch64,
Armv6L,
Armv7L,
Powerpc64Le,
Powerpc64,
Expand All @@ -89,6 +90,7 @@ impl fmt::Display for Arch {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Self::Aarch64 => write!(f, "aarch64"),
Self::Armv6L => write!(f, "armv6l"),
Self::Armv7L => write!(f, "armv7l"),
Self::Powerpc64Le => write!(f, "ppc64le"),
Self::Powerpc64 => write!(f, "ppc64"),
Expand All @@ -100,13 +102,18 @@ impl fmt::Display for Arch {
}

impl Arch {
/// Returns the oldest possible Manylinux tag for this architecture
pub fn get_minimum_manylinux_minor(&self) -> u16 {
/// Returns the oldest possible `manylinux` tag for this architecture, if it supports
/// `manylinux`.
pub fn get_minimum_manylinux_minor(&self) -> Option<u16> {
match self {
// manylinux 2014
Self::Aarch64 | Self::Armv7L | Self::Powerpc64 | Self::Powerpc64Le | Self::S390X => 17,
Self::Aarch64 | Self::Armv7L | Self::Powerpc64 | Self::Powerpc64Le | Self::S390X => {
Some(17)
}
// manylinux 1
Self::X86 | Self::X86_64 => 5,
Self::X86 | Self::X86_64 => Some(5),
// unsupported
Self::Armv6L => None,
}
}
}
25 changes: 13 additions & 12 deletions crates/platform-tags/src/tags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,18 +336,19 @@ fn compatible_tags(platform: &Platform) -> Result<Vec<String>, PlatformError> {
let platform_tags = match (&os, arch) {
(Os::Manylinux { major, minor }, _) => {
let mut platform_tags = vec![format!("linux_{}", arch)];
platform_tags.extend(
(arch.get_minimum_manylinux_minor()..=*minor)
.map(|minor| format!("manylinux_{major}_{minor}_{arch}")),
);
if (arch.get_minimum_manylinux_minor()..=*minor).contains(&12) {
platform_tags.push(format!("manylinux2010_{arch}"));
}
if (arch.get_minimum_manylinux_minor()..=*minor).contains(&17) {
platform_tags.push(format!("manylinux2014_{arch}"));
}
if (arch.get_minimum_manylinux_minor()..=*minor).contains(&5) {
platform_tags.push(format!("manylinux1_{arch}"));
if let Some(min_minor) = arch.get_minimum_manylinux_minor() {
platform_tags.extend(
(min_minor..=*minor).map(|minor| format!("manylinux_{major}_{minor}_{arch}")),
);
if (min_minor..=*minor).contains(&12) {
platform_tags.push(format!("manylinux2010_{arch}"));
}
if (min_minor..=*minor).contains(&17) {
platform_tags.push(format!("manylinux2014_{arch}"));
}
if (min_minor..=*minor).contains(&5) {
platform_tags.push(format!("manylinux1_{arch}"));
}
}
platform_tags
}
Expand Down

0 comments on commit c296da3

Please sign in to comment.