Skip to content

Commit

Permalink
add musl wheels
Browse files Browse the repository at this point in the history
  • Loading branch information
panekj committed Mar 2, 2025
1 parent 5896b96 commit 3603c4e
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 39 deletions.
14 changes: 11 additions & 3 deletions .github/workflows/releases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,16 @@ jobs:
PUSH: ${{ github.event_name == 'push' }}
run: |
docker buildx bake
- name: Rename
run: |
- run: |
mkdir -p ./target/wheels
mv ./target/alpine/linux_*/taplo*.whl ../wheels/
- uses: actions/upload-artifact@v4
with:
name: wheels-musl
path: |
./target/wheels/*
retention-days: 1
- run: |
cd ./target/alpine
mv ./linux_386/taplo ./linux_386/taplo-x86
mv ./linux_amd64/taplo ./linux_amd64/taplo-x86_64
Expand Down Expand Up @@ -481,7 +489,7 @@ jobs:

pypi_test_taplo_cli:
name: Test python wheels
needs: ["pypi_build_taplo_cli"]
needs: ["pypi_build_taplo_cli", "build_cli_linux_musl"]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand Down
20 changes: 2 additions & 18 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,13 @@ variable "PUSH" {
default = false
}

variable "APK_FAMILY_PACKAGES" {
default = [
"make",
"clang",
"git",
"lld",
"build-base",
"openssl-dev",
"openssl-libs-static",
]
}


variable "platforms" {
default = [
"linux/i386",
"linux/amd64",
"linux/arm64",
// "linux/riscv64",
// "linux/s390x",
"linux/riscv64",
"linux/arm/v7",
// "linux/arm/v6",
]
}

Expand Down Expand Up @@ -72,7 +57,6 @@ target "alpine" {
args = {
RUST_VERSION = RUST_VERSION
XX_VERSION = XX_VERSION
DISTRIBUTION_VERSION = "3.20"
DISTRIBUTION_PACKAGES = join(" ", APK_FAMILY_PACKAGES)
DISTRIBUTION_VERSION = "3.21"
}
}
52 changes: 35 additions & 17 deletions docker/alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,14 @@ COPY --from=xx / /

SHELL [ "/bin/ash", "-c" ]

# install host dependencies
ARG DISTRIBUTION_PACKAGES
RUN \
--mount=type=cache,id=apk,sharing=private,target=/var/cache/apk \
--mount=type=cache,id=apk,sharing=private,target=/etc/apk/cache \
--mount=type=cache,id=apk,target=/var/cache/apk \
--mount=type=cache,id=apk,target=/etc/apk/cache \
<<EOF

apk upgrade -Ua
apk add --no-cache \
bash clang lld llvm file git pkgconf build-base \
${DISTRIBUTION_PACKAGES}
bash clang lld llvm file git pkgconf build-base maturin
EOF

WORKDIR /source
Expand All @@ -43,17 +40,15 @@ EOF

# Install target dependencies
ARG TARGETPLATFORM
ARG DISTRIBUTION_PACKAGES
RUN \
--mount=type=cache,id=apk,sharing=private,target=/var/cache/apk \
--mount=type=cache,id=apk,sharing=private,target=/etc/apk/cache \
--mount=type=cache,id=apk-cross,sharing=private,target=/var/cache/apk \
--mount=type=cache,id=apk-cross,sharing=private,target=/etc/apk/cache \
<<EOF
#!/usr/bin/env bash
set -euxo pipefail

xx-apk add \
"xx-cxx-essentials" \
${DISTRIBUTION_PACKAGES}
"xx-cxx-essentials"
EOF

FROM build-prep AS build
Expand Down Expand Up @@ -81,24 +76,47 @@ fi
export OPENSSL_STATIC="1"
export PKG_CONFIG_ALL_STATIC="1"
export OPENSSL_NO_VENDOR="1"
export RUSTFLAGS="-C linker=clang -C link-arg=-fuse-ld=lld -C target-feature=+crt-static"
export PKG_CONFIG="$(xx-clang --print-prog-name=pkg-config)"

xx-cargo build \
cargo_target_env=$(xx-cargo --print-target-triple | tr '[:lower:]' '[:upper:]' | tr - _)

export "CARGO_TARGET_${cargo_target_env}_CC=$(xx-cargo --print-target-triple)-clang"
export "CARGO_TARGET_${cargo_target_env}_LINKER=$(xx-cargo --print-target-triple)-clang"
export "CARGO_TARGET_${cargo_target_env}_RUSTFLAGS"="-C link-arg=-fuse-ld=lld -C target-feature=+crt-static"

export "TARGET_CC=$(xx-clang --print-target-triple)-clang"
export "TARGET_LINKER=$(xx-clang --print-target-triple)-clang"

export PKG_CONFIG="$(xx-cargo --print-target-triple)-pkg-config"

cargo build \
--verbose \
--frozen \
--bin taplo \
--release \
--features toml-test,lsp
--target "$(xx-cargo --print-target-triple)" \
--package taplo-cli

maturin build \
--verbose \
--frozen \
--release \
--target "$(xx-cargo --print-target-triple)" \
--out /maturin

if ! xx-info is-cross; then
maturin sdist \
--verbose \
--out /maturin
fi

xx-verify "${CARGO_TARGET_DIR}"/"$(xx-cargo --print-target-triple)"/release/taplo

mv -v "${CARGO_TARGET_DIR}"/"$(xx-cargo --print-target-triple)"/release/taplo /usr/local/bin/taplo
cp -v "${CARGO_TARGET_DIR}"/"$(xx-cargo --print-target-triple)"/release/taplo /usr/local/bin/taplo

EOF

FROM scratch AS binary
COPY --from=build /usr/local/bin/taplo .
COPY --from=build /maturin .

FROM scratch AS oci
COPY --from=build /usr/local/bin/taplo /taplo
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ build-backend = "maturin"
[project]
name = "taplo"
description = "A CLI for Taplo TOML toolkit"
readme = "README.md"
authors = [{ name = "tamasfe" }]
maintainers = [{ name = "Jakub Panek" }]
requires-python = ">=3.8"
Expand Down

0 comments on commit 3603c4e

Please sign in to comment.