Skip to content

Commit

Permalink
Build 3.13 alpha 3 compatibility, misc
Browse files Browse the repository at this point in the history
  • Loading branch information
ijl committed Feb 3, 2024
1 parent 6d7e1ac commit f275011
Show file tree
Hide file tree
Showing 15 changed files with 201 additions and 111 deletions.
15 changes: 12 additions & 3 deletions .github/workflows/debug.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ jobs:
profile: [
{ rust: "1.65", features: "" },
{ rust: "1.65", features: "--features=yyjson" },
{ rust: "nightly-2024-01-17", features: "--features=yyjson,unstable-simd" },
{ rust: "nightly-2024-02-01", features: "--features=yyjson,unstable-simd" },
]
python: [
{ version: '3.12', abi: 'cp312-cp312' },
{ version: '3.8', abi: 'cp38-cp38' },
{ version: '3.13' },
{ version: '3.12' },
{ version: '3.8' },
]
env:
CC: "gcc"
Expand All @@ -26,7 +27,9 @@ jobs:

- uses: actions/setup-python@v5
with:
allow-prereleases: true
python-version: '${{ matrix.python.version }}'

- run: python -m pip install --user --upgrade pip "maturin>=1,<2" wheel

- uses: actions/checkout@v4
Expand All @@ -43,9 +46,15 @@ jobs:
- run: python -m pip install --user -r test/requirements.txt -r integration/requirements.txt

- run: pytest -s -rxX -v test
timeout-minutes: 4
env:
PYTHONMALLOC: "debug"

- run: ./integration/run thread
timeout-minutes: 2

- run: ./integration/run http
timeout-minutes: 2

- run: ./integration/run init
timeout-minutes: 2
18 changes: 9 additions & 9 deletions .github/workflows/linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ jobs:
options: --user 0
steps:
- run: yum install -y clang lld
- run: curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain nightly-2024-01-17 --profile minimal -y
- run: rustup component add rust-src --toolchain nightly-2024-01-17-x86_64-unknown-linux-gnu
- run: curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain nightly-2024-02-01 --profile minimal -y
- run: rustup component add rust-src --toolchain nightly-2024-02-01-x86_64-unknown-linux-gnu
- uses: actions/checkout@v4

- name: build-std
Expand Down Expand Up @@ -143,11 +143,11 @@ jobs:
RUSTFLAGS: "-C target-feature=-crt-static"
CARGO_UNSTABLE_SPARSE_REGISTRY: "true"
with:
rust-toolchain: nightly-2024-01-17
rust-toolchain: nightly-2024-02-01
rustup-components: rust-src
target: ${{ matrix.platform.target }}
manylinux: musllinux_1_1
args: --release --strip --out=dist --features=no-panic,yyjson -i python${{ matrix.python.version }}
args: --release --strip --out=dist --features=encoding_rs/simd-accel,no-panic,unstable-simd,yyjson -i python${{ matrix.python.version }}

- name: Set up QEMU
if: matrix.platform.arch != 'x86_64'
Expand Down Expand Up @@ -196,28 +196,28 @@ jobs:
arch: 'aarch64',
cflags: '-O2 -flto',
features: 'encoding_rs/simd-accel,no-panic,unstable-simd,yyjson',
rustflags: '-Z mir-opt-level=4 -D warnings',
rustflags: '-D warnings',
target: 'aarch64-unknown-linux-gnu',
},
{
arch: 'armv7',
cflags: '-Os -flto -fstrict-aliasing',
features: 'no-panic,yyjson', # no SIMD
rustflags: '-C opt-level=s -Z mir-opt-level=4 -D warnings',
rustflags: '-C opt-level=s -D warnings',
target: 'armv7-unknown-linux-gnueabihf',
},
{
arch: 'ppc64le',
cflags: '-O2 -flto',
features: 'no-panic,unstable-simd,yyjson',
rustflags: '-Z mir-opt-level=4 -D warnings',
rustflags: '-D warnings',
target: 'powerpc64le-unknown-linux-gnu',
},
{
arch: 's390x',
cflags: '-O2 -flto -march=z10',
features: 'no-panic,unstable-simd,yyjson',
rustflags: '-Z mir-opt-level=4 -C target-cpu=z10 -D warnings',
rustflags: '-C target-cpu=z10 -D warnings',
target: 's390x-unknown-linux-gnu',
},
]
Expand All @@ -238,7 +238,7 @@ jobs:
RUSTFLAGS: "${{ matrix.target.rustflags }}"
with:
target: ${{ matrix.target.target }}
rust-toolchain: nightly-2024-01-17
rust-toolchain: nightly-2024-02-01
rustup-components: rust-src
manylinux: auto
args: --release --strip --out=dist --features=${{ matrix.target.features }} -i python${{ matrix.python.version }}
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@
/target
/vendor
__pycache__
corpus
data/yelp
32 changes: 16 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ keywords = ["fast", "json", "dataclass", "dataclasses", "datetime", "rfc", "8259
include = [
"Cargo.toml",
"CHANGELOG.md",
"data/*",
"data",
"include",
"LICENSE-APACHE",
"LICENSE-MIT",
"pyproject.toml",
"README.md",
"src/*",
"src",
"test/*.py",
"test/requirements.txt",
]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,7 @@ It benefits from also having a C build environment to compile a faster
deserialization backend. See this project's `manylinux_2_28` builds for an
example using clang and LTO.

The project's own CI tests against `nightly-2024-01-17` and stable 1.65. It
The project's own CI tests against `nightly-2024-02-01` and stable 1.65. It
is prudent to pin the nightly version because that channel can introduce
breaking changes.

Expand Down
2 changes: 1 addition & 1 deletion ci/azure-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ steps:
LDFLAGS: "-O2 -fstrict-aliasing -flto=full -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 virtual-function-elimination -D warnings"
RUSTFLAGS: "-C lto=fat -Z virtual-function-elimination -D warnings"
CARGO_UNSTABLE_SPARSE_REGISTRY: "true"
displayName: build universal2

Expand Down
2 changes: 1 addition & 1 deletion ci/azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
variables:
toolchain: nightly-2024-01-17
toolchain: nightly-2024-02-01

jobs:

Expand Down
4 changes: 4 additions & 0 deletions integration/run
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,7 @@ fi
if [[ $to_run == *"init"* ]]; then
"${_dir}"/init
fi

if [[ $to_run == *"yelp"* ]]; then
"${_dir}"/yelp.py
fi
32 changes: 32 additions & 0 deletions integration/yelp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

import sys
from pathlib import Path

import orjson

# https://www.yelp.com/dataset, ~8.6GiB
FILES = {
"yelp_academic_dataset_business.json",
"yelp_academic_dataset_checkin.json",
"yelp_academic_dataset_review.json",
"yelp_academic_dataset_tip.json",
"yelp_academic_dataset_user.json",
}

for filename in FILES:
message = f"Processing {filename} ..."
sys.stdout.buffer.write(f"{message}".encode("ascii"))
count = 0
data = Path(f"data/yelp/{filename}").read_bytes()
for line in data.split(b"\n"):
if not line:
continue
count += 1
deserialized = orjson.loads(line)
assert orjson.loads(orjson.dumps(deserialized)) == deserialized
if count % 100 == 0:
sys.stdout.buffer.write(f"\r{message} {count} entries".encode("ascii"))

sys.stdout.buffer.write(f"\r{message} {count} entries\n".encode("ascii"))
2 changes: 1 addition & 1 deletion script/lint
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -eou pipefail

to_lint="./bench/*.py ./pysrc/orjson/__init__.pyi ./test/*.py script/pydataclass script/pymem
script/pysort script/pynumpy script/pynonstr script/pycorrectness script/graph integration/init
integration/wsgi.py integration/typestubs.py integration/thread"
integration/wsgi.py integration/typestubs.py integration/thread integration/yelp.py"

ruff ${to_lint} --fix
ruff format ${to_lint}
Expand Down
8 changes: 8 additions & 0 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,20 @@ macro_rules! use_immortal {
};
}

#[cfg(not(Py_3_13))]
macro_rules! pydict_next {
($obj1:expr, $obj2:expr, $obj3:expr, $obj4:expr) => {
unsafe { pyo3_ffi::_PyDict_Next($obj1, $obj2, $obj3, $obj4, std::ptr::null_mut()) }
};
}

#[cfg(Py_3_13)]
macro_rules! pydict_next {
($obj1:expr, $obj2:expr, $obj3:expr, $obj4:expr) => {
unsafe { pyo3_ffi::PyDict_Next($obj1, $obj2, $obj3, $obj4) }
};
}

macro_rules! reserve_minimum {
($writer:expr) => {
$writer.reserve(64);
Expand Down
Loading

0 comments on commit f275011

Please sign in to comment.