Skip to content

Commit

Permalink
fedora manylinux_2_17
Browse files Browse the repository at this point in the history
  • Loading branch information
ijl committed Apr 12, 2024
1 parent 79202e3 commit 1f5c887
Show file tree
Hide file tree
Showing 13 changed files with 83 additions and 61 deletions.
59 changes: 36 additions & 23 deletions .github/workflows/linux.yaml → .github/workflows/artifact.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: linux
name: artifact
on: push
env:
RUST_TOOLCHAIN: "nightly-2024-03-27"
jobs:

sdist:
Expand All @@ -9,18 +11,22 @@ jobs:
env:
RUST_TOOLCHAIN: "1.72" # MSRV
steps:
- run: curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain $RUST_TOOLCHAIN -y
- run: rustup default $RUST_TOOLCHAIN
- name: rustup stable
run: |
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain "${RUST_TOOLCHAIN}" -y
rustup default "${RUST_TOOLCHAIN}"
- uses: actions/checkout@v4

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

- run: maturin build
- run: cargo fetch
- run: mkdir .cargo
- run: cp ci/sdist.toml .cargo/config.toml
- run: cargo vendor include/cargo --versioned-dirs
- name: Vendor dependencies
run: |
maturin build
cargo fetch
mkdir .cargo
cp ci/sdist.toml .cargo/config.toml
cargo vendor include/cargo --versioned-dirs
- run: maturin sdist --out=dist

Expand Down Expand Up @@ -61,37 +67,44 @@ jobs:
{ version: '3.8', abi: 'cp38-cp38' },
]
env:
PATH: /github/home/.local/bin:/github/home/.cargo/bin:/opt/python/${{ matrix.python.abi }}/bin:/opt/rh/gcc-toolset-12/root/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
CC: "clang"
CFLAGS: "-Os -fstrict-aliasing -flto=full"
LDFLAGS: "-fuse-ld=lld -Wl,--as-needed"
RUSTFLAGS: "-C linker=clang -C lto=fat -C link-arg=-fuse-ld=lld -Z mir-opt-level=4 -Z virtual-function-elimination -D warnings"
CARGO_UNSTABLE_SPARSE_REGISTRY: "true"
UNSAFE_PYO3_SKIP_VERSION_CHECK: "1"
PATH: "/__w/orjson/orjson/.venv/bin:/github/home/.cargo/bin:/root/.local/bin:/root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
container:
image: quay.io/pypa/manylinux_2_28_x86_64:latest
image: fedora:41
options: --user 0
steps:
- run: yum install -y clang lld
- run: curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain nightly-2024-03-27 --profile minimal -y
- run: rustup component add rust-src --toolchain nightly-2024-03-27-x86_64-unknown-linux-gnu

- uses: actions/checkout@v4

- name: build-std
- name: Build environment
run: |
dnf install -y rustup clang lld python${{ matrix.python.version }}
rustup-init --default-toolchain "${RUST_TOOLCHAIN}-x86_64-unknown-linux-gnu" --profile minimal --component rust-src -y
cargo fetch --target=x86_64-unknown-linux-gnu &
curl -LsSf https://astral.sh/uv/install.sh | sh
uv venv --python python${{ matrix.python.version }}
source .venv/bin/activate
uv pip install --upgrade "maturin>=1,<2" -r test/requirements.txt -r integration/requirements.txt
mkdir .cargo
cp ci/config.toml .cargo/config.toml
pwd
- run: python3 -m pip install --user --upgrade pip "maturin>=1,<2" wheel
- run: |
- name: maturin
run: |
maturin build --release --strip \
--out=dist \
--features=no-panic,unstable-simd,yyjson \
--compatibility manylinux_2_17 \
--interpreter python${{ matrix.python.version }} \
--target=x86_64-unknown-linux-gnu
- run: python3 -m pip install --user dist/orjson*.whl
- run: python3 -m pip install --user -r test/requirements.txt -r integration/requirements.txt
uv pip install target/wheels/orjson*.whl
- run: pytest -s -rxX -v -n 4 test
env:
Expand All @@ -106,7 +119,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: orjson_manylinux_2_17_amd64_${{ matrix.python.version }}
path: dist
path: target/wheels
overwrite: true
retention-days: 1

Expand Down Expand Up @@ -153,11 +166,11 @@ jobs:
manylinux: musllinux_1_2
args: --release --strip --out=dist --features=no-panic,unstable-simd,yyjson -i python${{ matrix.python.version }}

- name: Set up QEMU
- name: QEMU
if: matrix.platform.arch != 'x86_64'
uses: docker/setup-qemu-action@v3
with:
image: tonistiigi/binfmt:qemu-v8.1.4
image: tonistiigi/binfmt:qemu-v8.1.5
platforms: ${{ matrix.platform.platform }}

- name: Test
Expand Down Expand Up @@ -293,7 +306,7 @@ jobs:
merge-multiple: true
- uses: actions/setup-python@v5
with:
python-version: "3.11"
python-version: "3.12"
- run: pip install pip "maturin>=1,<2"
- run: ls -1 .
- name: deploy wheel
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
steps:
- uses: actions/setup-python@v5
with:
python-version: '3.11'
python-version: "3.12"
- run: curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=stable --profile=default -y
- run: pip install -U autoflake isort black ruff mypy types-python-dateutil types-pytz types-simplejson types-ujson

Expand Down
36 changes: 18 additions & 18 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 bench/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
memory-profiler
pandas
pandas; python_version<"3.13"
pytest-benchmark
pytest-random-order
python-rapidjson
seaborn
seaborn; python_version<"3.13"
simplejson
tabulate
ujson
4 changes: 2 additions & 2 deletions script/develop
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ export LD="${LD:-lld}"

echo "CC: ${CC}, LD: ${LD}, LD_LIBRARY_PATH: ${LD_LIBRARY_PATH}"

export CFLAGS="-Os -fstrict-aliasing -flto=full"
export CFLAGS="-Os -fstrict-aliasing -fno-plt -flto=full"
export LDFLAGS="-fuse-ld=${LD} -Wl,--as-needed"
export RUSTFLAGS="-C linker=${CC} -C lto=fat -C link-arg=-fuse-ld=${LD} -Z mir-opt-level=4 -Z virtual-function-elimination -Z threads=8"

maturin build "$@"

pip install --force target/wheels/*.whl
uv pip install target/wheels/*.whl
5 changes: 4 additions & 1 deletion script/graph
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ def tab(obj):
if isinstance(each[1], float)
else None
)
each[1] = "%.1f" % each[1] if isinstance(each[1], float) else None
if group.startswith("github"):
each[1] = "%.2f" % each[1] if isinstance(each[1], float) else None
else:
each[1] = "%.1f" % each[1] if isinstance(each[1], float) else None

buf.write(tabulate(table, headers, tablefmt="github") + "\n")

Expand Down
6 changes: 1 addition & 5 deletions src/deserialize/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,7 @@ pub static mut KEY_MAP: OnceCell<KeyMap> = OnceCell::new();

pub fn cache_hash(key: &[u8]) -> u64 {
// try to omit code for >64 path in ahash
debug_assert!(key.len() <= 64);
#[cfg(feature = "intrinsics")]
unsafe {
core::intrinsics::assume(key.len() <= 64);
};
assume!(key.len() <= 64);
let mut hasher = ahash::AHasher::default();
hasher.write(key);
hasher.finish()
Expand Down
4 changes: 2 additions & 2 deletions src/deserialize/yyjson.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ fn parse_yy_array(elem: *mut yyjson_val) -> NonNull<pyo3_ffi::PyObject> {
return nonnull!(list);
}
let mut cur = unsafe_yyjson_get_first(elem);
for idx in 0..=len - 1 {
for idx in 0..len {
let next = unsafe_yyjson_get_next(cur);
let val = parse_node(cur).as_ptr();
ffi!(PyList_SET_ITEM(list, idx as isize, val));
Expand All @@ -165,7 +165,7 @@ fn parse_yy_object(elem: *mut yyjson_val) -> NonNull<pyo3_ffi::PyObject> {
}
let mut key = unsafe_yyjson_get_first(elem);
let dict = ffi!(_PyDict_NewPresized(len as isize));
for _ in 0..=len - 1 {
for _ in 0..len {
let val = key.add(1);
let key_str = str_from_slice!((*key).uni.str_ as *const u8, unsafe_yyjson_get_len(key));
let pykey = get_unicode_key(key_str);
Expand Down
4 changes: 2 additions & 2 deletions src/serialize/per_type/dataclass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl Serialize for DataclassFastSerializer {
let mut pos = 0;

pydict_next!(self.ptr, &mut pos, &mut next_key, &mut next_value);
for _ in 0..=ffi!(Py_SIZE(self.ptr)) as usize - 1 {
for _ in 0..ffi!(Py_SIZE(self.ptr)) as usize {
let key = next_key;
let value = next_value;

Expand Down Expand Up @@ -163,7 +163,7 @@ impl Serialize for DataclassFallbackSerializer {
let mut pos = 0;

pydict_next!(fields, &mut pos, &mut next_key, &mut next_value);
for _ in 0..=ffi!(Py_SIZE(fields)) as usize - 1 {
for _ in 0..ffi!(Py_SIZE(fields)) as usize {
let attr = next_key;
let field = next_value;

Expand Down
6 changes: 3 additions & 3 deletions src/serialize/per_type/dict.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl Serialize for Dict {
let mut pos = 0;

pydict_next!(self.ptr, &mut pos, &mut next_key, &mut next_value);
for _ in 0..=ffi!(Py_SIZE(self.ptr)) as usize - 1 {
for _ in 0..ffi!(Py_SIZE(self.ptr)) as usize {
let key = next_key;
let value = next_value;

Expand Down Expand Up @@ -210,7 +210,7 @@ impl Serialize for DictSortedKey {
let mut pos = 0;

pydict_next!(self.ptr, &mut pos, &mut next_key, &mut next_value);
for _ in 0..=len as usize - 1 {
for _ in 0..len as usize {
let key = next_key;
let value = next_value;

Expand Down Expand Up @@ -377,7 +377,7 @@ impl Serialize for DictNonStrKey {
let mut pos = 0;

pydict_next!(self.ptr, &mut pos, &mut next_key, &mut next_value);
for _ in 0..=len - 1 {
for _ in 0..len {
let key = next_key;
let value = next_value;

Expand Down
2 changes: 1 addition & 1 deletion src/serialize/per_type/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ impl Serialize for ListTupleSerializer {
}
debug_assert!(self.len >= 1);
let mut seq = serializer.serialize_seq(None).unwrap();
for idx in 0..=self.len - 1 {
for idx in 0..self.len {
let value = unsafe { *((self.data_ptr).add(idx)) };
let value_ob_type = ob_type!(value);
if is_class_by_type!(value_ob_type, STR_TYPE) {
Expand Down
2 changes: 1 addition & 1 deletion src/serialize/per_type/numpy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ impl NumpyArray {
#[cfg_attr(feature = "optimize", optimize(size))]
fn build(&mut self) {
if self.depth < self.dimensions() - 1 {
for i in 0..=self.shape()[self.depth] - 1 {
for i in 0..self.shape()[self.depth] {
let mut position: Vec<isize> = self.position.to_vec();
position[self.depth] = i;
let num_children: usize = if self.depth < self.dimensions() - 2 {
Expand Down
10 changes: 10 additions & 0 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,3 +257,13 @@ macro_rules! reserve_minimum {
$writer.reserve(64);
};
}

macro_rules! assume {
($expr:expr) => {
debug_assert!($expr);
#[cfg(feature = "intrinsics")]
unsafe {
core::intrinsics::assume($expr);
};
};
}

0 comments on commit 1f5c887

Please sign in to comment.