Skip to content

Commit

Permalink
cargo update, musllinux_1_2, test and tool misc
Browse files Browse the repository at this point in the history
  • Loading branch information
ijl committed Feb 3, 2024
1 parent 41018c8 commit 58ba5f3
Show file tree
Hide file tree
Showing 35 changed files with 266 additions and 234 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/debug.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ 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-03", features: "--features=yyjson,unstable-simd" },
]
python: [
{ version: '3.13' },
Expand Down
21 changes: 11 additions & 10 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-03 --profile minimal -y
- run: rustup component add rust-src --toolchain nightly-2024-02-03-x86_64-unknown-linux-gnu
- uses: actions/checkout@v4

- name: build-std
Expand Down Expand Up @@ -107,7 +107,7 @@ jobs:
path: dist
retention-days: 1

musllinux_1_1:
musllinux_1_2:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
Expand Down Expand Up @@ -140,14 +140,14 @@ jobs:
CC: "gcc"
CFLAGS: "-O2"
LDFLAGS: "-O2 -flto -Wl,--as-needed"
RUSTFLAGS: "-C target-feature=-crt-static"
RUSTFLAGS: "-C target-feature=-crt-static -Z mir-opt-level=4"
CARGO_UNSTABLE_SPARSE_REGISTRY: "true"
with:
rust-toolchain: nightly-2024-01-17
rust-toolchain: nightly-2024-02-03
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 }}
manylinux: musllinux_1_2
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 All @@ -159,10 +159,11 @@ jobs:
- name: Test
uses: addnab/docker-run-action@v3
with:
image: quay.io/pypa/musllinux_1_1_${{ matrix.platform.arch }}:latest
image: quay.io/pypa/musllinux_1_2_${{ matrix.platform.arch }}:latest
options: -v ${{ github.workspace }}:/io -w /io
run: |
apk add tzdata
sed -i '/^psutil/d' test/requirements.txt # missing 3.11, 3.12 wheels
sed -i '/^numpy/d' test/requirements.txt
python${{ matrix.python.version }} -m venv venv
Expand Down Expand Up @@ -238,7 +239,7 @@ jobs:
RUSTFLAGS: "${{ matrix.target.rustflags }}"
with:
target: ${{ matrix.target.target }}
rust-toolchain: nightly-2024-01-17
rust-toolchain: nightly-2024-02-03
rustup-components: rust-src
manylinux: auto
args: --release --strip --out=dist --features=${{ matrix.target.features }} -i python${{ matrix.python.version }}
Expand Down Expand Up @@ -280,7 +281,7 @@ jobs:
contents: write
runs-on: ubuntu-22.04
if: "startsWith(github.ref, 'refs/tags/')"
needs: [ manylinux_2_17_amd64, manylinux_2_17_non_amd64, musllinux_1_1, sdist ]
needs: [ manylinux_2_17_amd64, manylinux_2_17_non_amd64, musllinux_1_2, sdist ]
steps:
- uses: actions/download-artifact@v3
with:
Expand Down
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-03` 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-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-03

jobs:

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ include = [
line-length = 88
target-version = "py38"

[tool.ruff.lint]
select = [
"I",
]

ignore = [
"E501", # line too long
"F601", # Dictionary key literal ... repeated
Expand Down
4 changes: 2 additions & 2 deletions src/deserialize/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

use associative_cache::replacement::RoundRobinReplacement;
use associative_cache::*;
use core::ffi::c_void;
use once_cell::unsync::OnceCell;
use std::hash::Hasher;
use std::os::raw::c_void;

#[repr(transparent)]
pub struct CachedKey {
Expand Down Expand Up @@ -44,7 +44,7 @@ pub fn cache_hash(key: &[u8]) -> u64 {
debug_assert!(key.len() <= 64);
#[cfg(feature = "intrinsics")]
unsafe {
std::intrinsics::assume(key.len() <= 64);
core::intrinsics::assume(key.len() <= 64);
};
let mut hasher = ahash::AHasher::default();
hasher.write(key);
Expand Down
2 changes: 1 addition & 1 deletion src/deserialize/deserializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use crate::deserialize::utf8::read_input_to_buf;
use crate::deserialize::DeserializeError;
use crate::typeref::EMPTY_UNICODE;
use std::ptr::NonNull;
use core::ptr::NonNull;

pub fn deserialize(
ptr: *mut pyo3_ffi::PyObject,
Expand Down
2 changes: 1 addition & 1 deletion src/deserialize/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
use crate::deserialize::pyobject::*;
use crate::deserialize::DeserializeError;
use crate::str::unicode_from_str;
use core::ptr::NonNull;
use serde::de::{self, DeserializeSeed, Deserializer, MapAccess, SeqAccess, Visitor};
use smallvec::SmallVec;
use std::borrow::Cow;
use std::fmt;
use std::ptr::NonNull;

pub fn deserialize_json(
data: &'static str,
Expand Down
2 changes: 1 addition & 1 deletion src/deserialize/pyobject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use crate::deserialize::cache::*;
use crate::str::{hash_str, unicode_from_str};
use crate::typeref::{FALSE, NONE, TRUE};
use std::ptr::NonNull;
use core::ptr::NonNull;

pub fn get_unicode_key(key_str: &str) -> *mut pyo3_ffi::PyObject {
let pykey = if unlikely!(key_str.len() > 64) {
Expand Down
10 changes: 5 additions & 5 deletions src/deserialize/utf8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use crate::ffi::*;
use crate::str::unicode_to_str;
use crate::typeref::{BYTEARRAY_TYPE, BYTES_TYPE, MEMORYVIEW_TYPE, STR_TYPE};
use crate::util::INVALID_STR;
use core::ffi::c_char;
use std::borrow::Cow;
use std::os::raw::c_char;

#[cfg(all(target_arch = "x86_64", not(target_feature = "sse4.2")))]
fn is_valid_utf8(buf: &[u8]) -> bool {
Expand Down Expand Up @@ -39,7 +39,7 @@ pub fn read_input_to_buf(
let buffer: &[u8];
if is_type!(obj_type_ptr, BYTES_TYPE) {
buffer = unsafe {
std::slice::from_raw_parts(
core::slice::from_raw_parts(
PyBytes_AS_STRING(ptr) as *const u8,
PyBytes_GET_SIZE(ptr) as usize,
)
Expand All @@ -53,7 +53,7 @@ pub fn read_input_to_buf(
return Err(DeserializeError::invalid(Cow::Borrowed(INVALID_STR)));
}
let as_str = uni.unwrap();
buffer = unsafe { std::slice::from_raw_parts(as_str.as_ptr(), as_str.len()) };
buffer = unsafe { core::slice::from_raw_parts(as_str.as_ptr(), as_str.len()) };
} else if unlikely!(is_type!(obj_type_ptr, MEMORYVIEW_TYPE)) {
let membuf = unsafe { PyMemoryView_GET_BUFFER(ptr) };
if unsafe { pyo3_ffi::PyBuffer_IsContiguous(membuf, b'C' as c_char) == 0 } {
Expand All @@ -62,14 +62,14 @@ pub fn read_input_to_buf(
)));
}
buffer = unsafe {
std::slice::from_raw_parts((*membuf).buf as *const u8, (*membuf).len as usize)
core::slice::from_raw_parts((*membuf).buf as *const u8, (*membuf).len as usize)
};
if !is_valid_utf8(buffer) {
return Err(DeserializeError::invalid(Cow::Borrowed(INVALID_STR)));
}
} else if unlikely!(is_type!(obj_type_ptr, BYTEARRAY_TYPE)) {
buffer = unsafe {
std::slice::from_raw_parts(
core::slice::from_raw_parts(
ffi!(PyByteArray_AsString(ptr)) as *const u8,
ffi!(PyByteArray_Size(ptr)) as usize,
)
Expand Down
8 changes: 4 additions & 4 deletions src/deserialize/yyjson.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ use crate::deserialize::DeserializeError;
use crate::ffi::yyjson::*;
use crate::str::unicode_from_str;
use crate::typeref::{yyjson_init, YYJSON_ALLOC, YYJSON_BUFFER_SIZE};
use core::ffi::c_char;
use core::ptr::{null, null_mut, NonNull};
use std::borrow::Cow;
use std::os::raw::c_char;
use std::ptr::{null, null_mut, NonNull};

const YYJSON_TAG_BIT: u8 = 8;

const YYJSON_VAL_SIZE: usize = std::mem::size_of::<yyjson_val>();
const YYJSON_VAL_SIZE: usize = core::mem::size_of::<yyjson_val>();

const TAG_ARRAY: u8 = 0b00000110;
const TAG_DOUBLE: u8 = 0b00010100;
Expand Down Expand Up @@ -67,7 +67,7 @@ pub fn deserialize_yyjson(
read_doc_default(data, &mut err)
};
if unlikely!(doc.is_null()) {
let msg: Cow<str> = unsafe { std::ffi::CStr::from_ptr(err.msg).to_string_lossy() };
let msg: Cow<str> = unsafe { core::ffi::CStr::from_ptr(err.msg).to_string_lossy() };
Err(DeserializeError::from_yyjson(msg, err.pos as i64, data))
} else {
let root = yyjson_doc_get_root(doc);
Expand Down
2 changes: 1 addition & 1 deletion src/ffi/buffer.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: (Apache-2.0 OR MIT)

use core::ffi::c_int;
use pyo3_ffi::*;
use std::os::raw::c_int;

#[repr(C)]
pub struct _PyManagedBufferObject {
Expand Down
2 changes: 1 addition & 1 deletion src/ffi/bytes.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: (Apache-2.0 OR MIT)

use core::ffi::c_char;
use pyo3_ffi::{PyBytesObject, PyObject, PyVarObject, Py_ssize_t};
use std::os::raw::c_char;

#[allow(non_snake_case)]
#[inline(always)]
Expand Down
10 changes: 5 additions & 5 deletions src/ffi/fragment.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: (Apache-2.0 OR MIT)

use core::ffi::{c_char, c_ulong};
use core::ptr::null_mut;
use pyo3_ffi::*;
use std::os::raw::{c_char, c_ulong};
use std::ptr::null_mut;

// https://docs.python.org/3/c-api/typeobj.html#typedef-examples

Expand Down Expand Up @@ -75,12 +75,12 @@ pub unsafe extern "C" fn orjson_fragmenttype_new() -> *mut PyTypeObject {
ob_refcnt: pyo3_ffi::PyObjectObRefcnt { ob_refcnt: 0 },
#[cfg(not(Py_3_12))]
ob_refcnt: 0,
ob_type: std::ptr::addr_of_mut!(PyType_Type),
ob_type: core::ptr::addr_of_mut!(PyType_Type),
},
ob_size: 0,
},
tp_name: "orjson.Fragment\0".as_ptr() as *const c_char,
tp_basicsize: std::mem::size_of::<Fragment>() as isize,
tp_basicsize: core::mem::size_of::<Fragment>() as isize,
tp_itemsize: 0,
tp_dealloc: Some(orjson_fragment_dealloc),
tp_init: None,
Expand Down Expand Up @@ -114,7 +114,7 @@ pub unsafe extern "C" fn orjson_fragmenttype_new() -> *mut PyTypeObject {
tp_getattro: None,
tp_setattro: None,
tp_as_buffer: null_mut(),
tp_doc: std::ptr::null_mut(),
tp_doc: core::ptr::null_mut(),
tp_traverse: None,
tp_clear: None,
tp_richcompare: None,
Expand Down
Loading

0 comments on commit 58ba5f3

Please sign in to comment.