Skip to content

Commit

Permalink
cargo update, build misc, macOS 15, i686 and win GHA
Browse files Browse the repository at this point in the history
  • Loading branch information
ijl committed Nov 15, 2024
1 parent 8ece0d4 commit 3a90000
Show file tree
Hide file tree
Showing 28 changed files with 407 additions and 571 deletions.
152 changes: 120 additions & 32 deletions .github/workflows/artifact.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:

sdist:
runs-on: ubuntu-22.04
timeout-minutes: 10
strategy:
fail-fast: false
env:
Expand Down Expand Up @@ -77,25 +78,25 @@ jobs:
{
cc: "clang",
cflags: "-Os -fstrict-aliasing -fno-plt -flto=full -emit-llvm",
features: "avx512,no-panic,unstable-simd,yyjson",
features: "avx512,unstable-simd,yyjson",
ldflags: "-fuse-ld=lld -Wl,-plugin-opt=also-emit-llvm -Wl,--as-needed -Wl,-zrelro,-znow",
rustflags: "-C linker=clang -C link-arg=-fuse-ld=lld -C linker-plugin-lto -C lto=fat -C link-arg=-Wl,-zrelro,-znow -Z mir-opt-level=4 -Z threads=4 -D warnings",
tag: null,
target: "x86_64-unknown-linux-gnu",
},
]
env:
PYTHON: "${{ matrix.python.interpreter }}"
PYTHON_PACKAGE: "${{ matrix.python.package }}"
TARGET: "${{ matrix.arch.target }}"
CARGO_TARGET_DIR: "/tmp/orjson"
CC: "${{ matrix.arch.cc }}"
VENV: ".venv"
FEATURES: "${{ matrix.arch.features }}"
CFLAGS: "${{ matrix.arch.cflags }}"
COMPATIBILITY: "${{ matrix.python.compatibility }}"
FEATURES: "${{ matrix.arch.features }}"
LDFLAGS: "${{ matrix.arch.ldflags }}"
PYTHON: "${{ matrix.python.interpreter }}"
PYTHON_PACKAGE: "${{ matrix.python.package }}"
RUSTFLAGS: "${{ matrix.arch.rustflags }}"
CARGO_TARGET_DIR: "/tmp/orjson"
COMPATIBILITY: "${{ matrix.python.compatibility }}"
TARGET: "${{ matrix.arch.target }}"
VENV: ".venv"
steps:

- name: cpuinfo
Expand Down Expand Up @@ -167,25 +168,25 @@ jobs:
{
cc: "clang",
cflags: "-Os -fstrict-aliasing -fno-plt -flto=full -emit-llvm",
features: "no-panic,unstable-simd,yyjson",
features: "unstable-simd,yyjson",
ldflags: "-fuse-ld=lld -Wl,-plugin-opt=also-emit-llvm -Wl,--as-needed -Wl,-zrelro,-znow",
rustflags: "-C linker=clang -C link-arg=-fuse-ld=lld -C linker-plugin-lto -C lto=fat -C link-arg=-Wl,-zrelro,-znow -Z mir-opt-level=4 -Z threads=4 -D warnings",
tag: "aarch64",
target: "aarch64-unknown-linux-gnu",
},
]
env:
PYTHON: "${{ matrix.python.interpreter }}"
PYTHON_PACKAGE: "${{ matrix.python.package }}"
TARGET: "${{ matrix.arch.target }}"
CARGO_TARGET_DIR: "/tmp/orjson"
CC: "${{ matrix.arch.cc }}"
VENV: ".venv"
FEATURES: "${{ matrix.arch.features }}"
CFLAGS: "${{ matrix.arch.cflags }}"
COMPATIBILITY: "${{ matrix.python.compatibility }}"
FEATURES: "${{ matrix.arch.features }}"
LDFLAGS: "${{ matrix.arch.ldflags }}"
PYTHON: "${{ matrix.python.interpreter }}"
PYTHON_PACKAGE: "${{ matrix.python.package }}"
RUSTFLAGS: "${{ matrix.arch.rustflags }}"
CARGO_TARGET_DIR: "/tmp/orjson"
COMPATIBILITY: "${{ matrix.python.compatibility }}"
TARGET: "${{ matrix.arch.target }}"
VENV: ".venv"
steps:

- name: cpuinfo
Expand Down Expand Up @@ -241,6 +242,7 @@ jobs:

musllinux:
runs-on: ubuntu-24.04
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
Expand All @@ -256,11 +258,11 @@ jobs:
- target: aarch64-unknown-linux-musl
arch: aarch64
platform: linux/arm64
features: no-panic,unstable-simd,unwind,yyjson
features: unstable-simd,unwind,yyjson
- target: x86_64-unknown-linux-musl
arch: x86_64
platform: linux/amd64
features: avx512,no-panic,unstable-simd,unwind,yyjson
features: avx512,unstable-simd,unwind,yyjson
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -317,6 +319,7 @@ jobs:

manylinux_non_amd64:
runs-on: ubuntu-24.04
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
Expand All @@ -331,28 +334,35 @@ jobs:
{
arch: 'aarch64',
cflags: '-Os -flto=full -fstrict-aliasing',
features: 'no-panic,unstable-simd,yyjson',
features: 'unstable-simd,yyjson',
rustflags: '-Z mir-opt-level=4 -C lto=fat -D warnings',
target: 'aarch64-unknown-linux-gnu',
},
{
arch: 'i686',
cflags: '-Os -flto=full -fstrict-aliasing',
features: 'unstable-simd,yyjson',
rustflags: '-Z mir-opt-level=4 -C lto=fat -D warnings',
target: 'i686-unknown-linux-gnu',
},
{
arch: 'armv7',
cflags: '-Os -flto=full -fstrict-aliasing',
features: 'no-panic,yyjson', # no SIMD
features: 'yyjson', # no SIMD
rustflags: '-Z mir-opt-level=4 -C lto=fat -D warnings -C opt-level=s',
target: 'armv7-unknown-linux-gnueabihf',
},
{
arch: 'ppc64le',
cflags: '-Os -flto=full -fstrict-aliasing',
features: 'no-panic,unstable-simd,yyjson',
features: 'unstable-simd,yyjson',
rustflags: '-Z mir-opt-level=4 -C lto=fat -D warnings',
target: 'powerpc64le-unknown-linux-gnu',
},
{
arch: 's390x',
cflags: '-Os -flto=full -fstrict-aliasing -march=z10',
features: 'no-panic,yyjson',
features: 'yyjson',
rustflags: '-Z mir-opt-level=4 -C lto=fat -D warnings -C target-cpu=z10',
target: 's390x-unknown-linux-gnu',
},
Expand Down Expand Up @@ -389,7 +399,8 @@ jobs:
retention-days: 1

macos_aarch64:
runs-on: macos-14
runs-on: macos-15
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
Expand All @@ -400,12 +411,11 @@ jobs:
{ version: '3.10', macosx_target: "10.15" },
]
env:
CC: "clang"
CFLAGS: "-Os -fstrict-aliasing -flto=full"
LDFLAGS: "-Wl,--as-needed"
CFLAGS_x86_64_apple_darwin: "-O2 -fstrict-aliasing -flto=full -march=x86-64-v2 -mtune=generic"
CFLAGS_aarch64_apple_darwin: "-O2 -fstrict-aliasing -flto=full -mcpu=apple-m1 -mtune=generic"
RUSTFLAGS: "-C lto=fat -Z mir-opt-level=4 -Z threads=3 -D warnings"
CFLAGS_x86_64_apple_darwin: "-O2 -fstrict-aliasing -flto=full -emit-llvm -march=x86-64-v2 -mtune=generic"
CFLAGS_aarch64_apple_darwin: "-O2 -fstrict-aliasing -flto=full -emit-llvm -mcpu=apple-m1 -mtune=generic"
RUSTFLAGS: "-C linker=clang -C link-arg=-fuse-ld=lld -C linker-plugin-lto -C lto=fat -Z mir-opt-level=4 -Z threads=3 -D warnings"
PATH: "/Users/runner/work/orjson/orjson/.venv/bin:/Users/runner/.cargo/bin:/usr/local/opt/curl/bin:/usr/local/bin:/usr/local/sbin:/Users/runner/bin:/Library/Frameworks/Python.framework/Versions/Current/bin:/usr/bin:/bin:/usr/sbin:/sbin"
steps:

Expand All @@ -414,7 +424,6 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: "${{ matrix.python.version }}"
allow-prereleases: true

- uses: dtolnay/rust-toolchain@master
with:
Expand All @@ -426,6 +435,10 @@ jobs:
run: |
cargo fetch --target aarch64-apple-darwin &
brew install llvm@19
export PATH=$HOME/.cargo/bin:$HOME/.local/bin:$PATH
curl -LsSf https://astral.sh/uv/install.sh | sh
uv venv --python python${{ matrix.python.version }}
uv pip install --upgrade "maturin>=1,<2" -r test/requirements.txt -r integration/requirements.txt
Expand All @@ -435,11 +448,15 @@ jobs:
- name: maturin
run: |
PATH=$HOME/.cargo/bin:$PATH \
export PATH=$HOME/.cargo/bin:$HOME/.local/bin:$PATH
export CC=/opt/homebrew/opt/llvm@19/bin/clang
export LLD=/opt/homebrew/opt/llvm@19/bin/lld
MACOSX_DEPLOYMENT_TARGET="${{ matrix.python.macosx_target }}" \
PYO3_CROSS_LIB_DIR=$(python -c "import sysconfig;print(sysconfig.get_config_var('LIBDIR'))") \
maturin build --release --strip \
--features=no-panic,unstable-simd,yyjson \
--features=unstable-simd,yyjson \
--interpreter python${{ matrix.python.version }} \
--target=universal2-apple-darwin
uv pip install target/wheels/orjson*.whl
Expand All @@ -463,6 +480,7 @@ jobs:

macos_amd64:
runs-on: macos-13
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -496,6 +514,8 @@ jobs:
run: |
cargo fetch --target aarch64-apple-darwin &
export PATH=$HOME/.cargo/bin:$HOME/.local/bin:$PATH
curl -LsSf https://astral.sh/uv/install.sh | sh
uv venv --python python${{ matrix.python.version }}
uv pip install --upgrade "maturin>=1,<2" -r test/requirements.txt -r integration/requirements.txt
Expand All @@ -505,11 +525,12 @@ jobs:
- name: maturin
run: |
PATH=$HOME/.cargo/bin:$PATH \
export PATH=$HOME/.cargo/bin:$HOME/.local/bin:$PATH
MACOSX_DEPLOYMENT_TARGET="${{ matrix.python.macosx_target }}" \
PYO3_CROSS_LIB_DIR=$(python -c "import sysconfig;print(sysconfig.get_config_var('LIBDIR'))") \
maturin build --release --strip \
--features=no-panic,unstable-simd,yyjson \
--features=unstable-simd,yyjson \
--interpreter python${{ matrix.python.version }} \
--target=universal2-apple-darwin
uv pip install target/wheels/orjson*.whl
Expand All @@ -531,9 +552,75 @@ jobs:
overwrite: true
retention-days: 1

windows:
runs-on: windows-2022
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
python: [
{ version: '3.13' },
{ version: '3.12' },
{ version: '3.11' },
{ version: '3.10' },
{ version: '3.9' },
{ version: '3.8' },
]
platform: [
{ arch: "x64", target: "x86_64-pc-windows-msvc" },
{ arch: "x86", target: "i686-pc-windows-msvc" },
]
env:
CFLAGS: "-Os -flto"
LDFLAGS: "-Wl,--as-needed"
RUSTFLAGS: "-C lto=fat -Z mir-opt-level=4 -D warnings"
steps:

- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "${{ matrix.python.version }}"
architecture: "${{ matrix.platform.arch }}"

- uses: dtolnay/rust-toolchain@master
with:
toolchain: "${{ env.RUST_TOOLCHAIN }}"
targets: "${{ matrix.platform.target }}"
components: "rust-src"

- name: Build environment
run: |
cargo fetch --target "${{ matrix.platform.target }}" &
python.exe -m pip install --upgrade pip "maturin>=1,<2" wheel
python.exe -m pip install -r test\requirements.txt -r integration\requirements.txt
mkdir .cargo
cp ci\config.toml .cargo\config.toml
- name: maturin
run: |
maturin.exe build --release --strip --features=unstable-simd,yyjson --target="${{ matrix.platform.target }}"
python.exe -m pip install orjson --no-index --find-links target\wheels
- run: python.exe -m pytest -s -rxX -v test
env:
PYTHONMALLOC: "debug"

- name: Store wheels
if: "startsWith(github.ref, 'refs/tags/')"
uses: actions/upload-artifact@v4
with:
name: orjson_windows_${{ matrix.platform.arch }}_${{ matrix.python.version }}
path: target\wheels
overwrite: true
retention-days: 1

pypi:
name: PyPI
runs-on: ubuntu-24.04
timeout-minutes: 10
if: "startsWith(github.ref, 'refs/tags/')"
needs: [
macos_aarch64,
Expand All @@ -543,6 +630,7 @@ jobs:
manylinux_non_amd64,
musllinux,
sdist,
windows,
]
environment:
name: pypi
Expand Down
Loading

0 comments on commit 3a90000

Please sign in to comment.