Skip to content

Commit

Permalink
Drop support for python3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
ijl committed Sep 18, 2023
1 parent 46d1181 commit 1c9198b
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 152 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/debug.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
]
python: [
{ version: '3.11', abi: 'cp311-cp311' },
{ version: '3.7', abi: 'cp37-cp37m' },
{ version: '3.8', abi: 'cp38-cp38' },
]
env:
CC: "gcc"
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ jobs:
{ version: '3.10', abi: 'cp310-cp310' },
{ version: '3.9', abi: 'cp39-cp39' },
{ version: '3.8', abi: 'cp38-cp38' },
{ version: '3.7', abi: 'cp37-cp37m' },
]
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
Expand Down Expand Up @@ -120,7 +119,6 @@ jobs:
{ version: '3.10' },
{ version: '3.9' },
{ version: '3.8' },
{ version: '3.7' },
]
platform:
- target: aarch64-unknown-linux-musl
Expand Down Expand Up @@ -194,7 +192,6 @@ jobs:
{ version: '3.10', abi: 'cp310-cp310' },
{ version: '3.9', abi: 'cp39-cp39' },
{ version: '3.8', abi: 'cp38-cp38' },
{ version: '3.7', abi: 'cp37-cp37m' },
]
target: [
{
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ support for 64-bit
* does not provide `load()` or `dump()` functions for reading from/writing to
file-like objects

orjson supports CPython 3.7, 3.8, 3.9, 3.10, 3.11, and 3.12. It distributes
orjson supports CPython 3.8, 3.9, 3.10, 3.11, and 3.12. It distributes
amd64/x86_64, aarch64/armv8, arm7, POWER/ppc64le, and s390x wheels for Linux,
amd64 and aarch64 wheels for macOS, and amd64 and i686/x86 wheels for Windows.
orjson does not support PyPy. Releases follow semantic versioning and
Expand Down
46 changes: 0 additions & 46 deletions ci/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,6 @@ jobs:
- checkout: self
- template: ./azure-macos.yml

- job: macos_python37_univeral2
pool:
vmImage: macOS-11
variables:
interpreter: python3.7
macosx_deployment_target: '10.15'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.7'
addToPath: true
- checkout: self
- template: ./azure-macos.yml

- job: win_python312_amd64
pool:
vmImage: windows-2022
Expand Down Expand Up @@ -170,22 +156,6 @@ jobs:
- checkout: self
- template: ./azure-win.yml

- job: win_python37_amd64
pool:
vmImage: windows-2022
variables:
interpreter: C:\hostedtoolcache\windows\Python\3.7.9\x64\python.exe
rustup: https://win.rustup.rs/x86_64
target: x86_64-pc-windows-msvc
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.7.9'
addToPath: true
architecture: 'x64'
- checkout: self
- template: ./azure-win.yml

- job: win_python312_x86
pool:
vmImage: windows-2022
Expand Down Expand Up @@ -265,19 +235,3 @@ jobs:
architecture: 'x86'
- checkout: self
- template: ./azure-win.yml

- job: win_python37_x86
pool:
vmImage: windows-2022
variables:
interpreter: C:\hostedtoolcache\windows\Python\3.7.9\x86\python.exe
rustup: https://win.rustup.rs/x86
target: i686-pc-windows-msvc
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.7.9'
addToPath: true
architecture: 'x86'
- checkout: self
- template: ./azure-win.yml
9 changes: 4 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "orjson"
repository = "https://github.com/ijl/orjson"
requires-python = ">=3.7"
requires-python = ">=3.8"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
Expand All @@ -11,7 +11,6 @@ classifiers = [
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
Expand Down Expand Up @@ -42,17 +41,17 @@ include = [

[tool.black]
line-length = 88
target-version = ["py37"]
target-version = ["py38"]
include = ".pyi?$"

[tool.ruff]
line-length = 88
target-version = "py37"
target-version = "py38"

ignore = [
"E501", # line too long
"F601", # Dictionary key literal ... repeated
]

[tool.mypy]
python_version = "3.8" # numpy
python_version = "3.8"
2 changes: 0 additions & 2 deletions src/ffi/fragment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,11 @@ pub unsafe extern "C" fn orjson_fragmenttype_new() -> *mut PyTypeObject {
tp_is_gc: None,
tp_mro: null_mut(),
tp_subclasses: null_mut(),
#[cfg(Py_3_8)]
tp_vectorcall: None,
tp_version_tag: 0,
tp_weaklist: null_mut(),
#[cfg(not(Py_3_9))]
tp_print: None,
#[cfg(Py_3_8)]
tp_vectorcall_offset: 0,
tp_getattr: None,
tp_setattr: None,
Expand Down
101 changes: 8 additions & 93 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,30 +78,14 @@ pub unsafe extern "C" fn orjson_init_exec(mptr: *mut PyObject) -> c_int {
let dumps_doc =
"dumps(obj, /, default=None, option=None)\n--\n\nSerialize Python objects to JSON.\0";

let wrapped_dumps: PyMethodDef;

#[cfg(Py_3_8)]
{
wrapped_dumps = PyMethodDef {
ml_name: "dumps\0".as_ptr() as *const c_char,
ml_meth: PyMethodDefPointer {
_PyCFunctionFastWithKeywords: dumps,
},
ml_flags: pyo3_ffi::METH_FASTCALL | METH_KEYWORDS,
ml_doc: dumps_doc.as_ptr() as *const c_char,
};
}
#[cfg(not(Py_3_8))]
{
wrapped_dumps = PyMethodDef {
ml_name: "dumps\0".as_ptr() as *const c_char,
ml_meth: PyMethodDefPointer {
PyCFunctionWithKeywords: dumps,
},
ml_flags: METH_VARARGS | METH_KEYWORDS,
ml_doc: dumps_doc.as_ptr() as *const c_char,
};
}
let wrapped_dumps = PyMethodDef {
ml_name: "dumps\0".as_ptr() as *const c_char,
ml_meth: PyMethodDefPointer {
_PyCFunctionFastWithKeywords: dumps,
},
ml_flags: pyo3_ffi::METH_FASTCALL | METH_KEYWORDS,
ml_doc: dumps_doc.as_ptr() as *const c_char,
};

let func = PyCFunction_NewEx(
Box::into_raw(Box::new(wrapped_dumps)),
Expand Down Expand Up @@ -305,7 +289,6 @@ pub unsafe extern "C" fn loads(_self: *mut PyObject, obj: *mut PyObject) -> *mut
}
}

#[cfg(Py_3_8)]
#[no_mangle]
pub unsafe extern "C" fn dumps(
_self: *mut PyObject,
Expand Down Expand Up @@ -369,71 +352,3 @@ pub unsafe extern "C" fn dumps(
Err(err) => raise_dumps_exception_dynamic(&err),
}
}

#[cfg(not(Py_3_8))]
#[no_mangle]
pub unsafe extern "C" fn dumps(
_self: *mut PyObject,
args: *mut PyObject,
kwds: *mut PyObject,
) -> *mut PyObject {
let mut default: Option<NonNull<PyObject>> = None;
let mut optsptr: Option<NonNull<PyObject>> = None;

let obj = PyTuple_GET_ITEM(args, 0);

let num_args = Py_SIZE(args);
if unlikely!(num_args == 0) {
return raise_dumps_exception_fixed(
"dumps() missing 1 required positional argument: 'obj'",
);
}
if num_args & 2 == 2 {
default = Some(NonNull::new_unchecked(PyTuple_GET_ITEM(args, 1)));
}
if num_args & 3 == 3 {
optsptr = Some(NonNull::new_unchecked(PyTuple_GET_ITEM(args, 2)));
}

if !kwds.is_null() {
for (arg, val) in crate::ffi::PyDictIter::from_pyobject(kwds) {
if arg.as_ptr() == typeref::DEFAULT {
if unlikely!(num_args & 2 == 2) {
return raise_dumps_exception_fixed(
"dumps() got multiple values for argument: 'default'",
);
}
default = Some(val);
} else if arg.as_ptr() == typeref::OPTION {
if unlikely!(num_args & 3 == 3) {
return raise_dumps_exception_fixed(
"dumps() got multiple values for argument: 'option'",
);
}
optsptr = Some(val);
} else if arg.as_ptr().is_null() {
break;
} else {
return raise_dumps_exception_fixed("dumps() got an unexpected keyword argument");
}
}
}

let mut optsbits: i32 = 0;
if let Some(opts) = optsptr {
if opts.as_ptr() == typeref::NONE {
} else if (*opts.as_ptr()).ob_type != typeref::INT_TYPE {
return raise_dumps_exception_fixed("Invalid opts");
} else {
optsbits = PyLong_AsLong(optsptr.unwrap().as_ptr()) as i32;
if !(0..=opt::MAX_OPT).contains(&optsbits) {
return raise_dumps_exception_fixed("Invalid opts");
}
}
}

match crate::serialize::serialize(obj, default, optsbits as opt::Opt) {
Ok(val) => val.as_ptr(),
Err(err) => raise_dumps_exception_dynamic(&err),
}
}
2 changes: 1 addition & 1 deletion test/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
arrow
faker
numpy;(platform_machine=="x86_64" or (platform_machine=="aarch64" and sys_platform == "linux")) and python_version>"3.7" and python_version<"3.12"
numpy;(platform_machine=="x86_64" or (platform_machine=="aarch64" and sys_platform == "linux")) and python_version<"3.12"
pendulum;sys_platform=="linux" and platform_machine=="x86_64" and python_version<"3.12"
psutil;(sys_platform=="linux" or sys_platform == "macos") and platform_machine=="x86_64"
pytest
Expand Down

0 comments on commit 1c9198b

Please sign in to comment.