Skip to content

Commit d42d184

Browse files
committed
Windows support
1 parent 9f6ab5c commit d42d184

11 files changed

Lines changed: 66 additions & 9 deletions

File tree

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ crate-type = ["cdylib"]
1919
classifier = [
2020
"Development Status :: 5 - Production/Stable",
2121
"Intended Audience :: Developers",
22-
"License :: OSI Approved",
2322
"License :: OSI Approved :: Apache Software License",
2423
"License :: OSI Approved :: MIT License",
24+
"License :: OSI Approved",
2525
"Operating System :: MacOS",
26+
"Operating System :: Microsoft :: Windows",
2627
"Operating System :: POSIX :: Linux",
2728
"Programming Language :: Python :: 3",
2829
"Programming Language :: Python :: 3.6",

build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ py_min=$(python -c 'import sys; print(str(sys.version_info.minor))')
55

66
rm -f target/wheels/*
77

8-
CARGO_INCREMENTAL=0 pyo3-pack build -i "python${py_maj}.${py_min}" --release "$@"
8+
pyo3-pack build -i "python${py_maj}.${py_min}" --release "$@"
99

1010
pip install --force $(find target/wheels -name "*cp${py_maj}${py_min}*")

ci/azure-linux.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
steps:
22
- bash: curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain nightly -y
3+
displayName: rustup
34
- bash: sudo apt-get update && sudo apt-get install -y wrk

ci/azure-macos.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
steps:
22
- bash: curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain nightly -y
3+
displayName: rustup
34
- bash: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
45
- bash: brew install wrk

ci/azure-pipelines.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,33 @@ jobs:
6363
- checkout: self
6464
- template: ./azure-macos.yml
6565
- template: ./azure-posix.yml
66+
67+
- job: win_python37
68+
pool:
69+
vmImage: vs2017-win2016
70+
variables:
71+
interpreter: C:\hostedtoolcache\windows\Python\3.7.0\x64\python.exe
72+
target: x86_64-pc-windows-msvc
73+
steps:
74+
- task: UsePythonVersion@0
75+
inputs:
76+
versionSpec: '3.7'
77+
addToPath: true
78+
architecture: 'x64'
79+
- checkout: self
80+
- template: ./azure-win.yml
81+
82+
- job: win_python36
83+
pool:
84+
vmImage: vs2017-win2016
85+
variables:
86+
interpreter: C:\hostedtoolcache\windows\Python\3.6.4\x64\python.exe
87+
target: x86_64-pc-windows-msvc
88+
steps:
89+
- task: UsePythonVersion@0
90+
inputs:
91+
versionSpec: '3.6'
92+
addToPath: true
93+
architecture: 'x64'
94+
- checkout: self
95+
- template: ./azure-win.yml

ci/azure-posix.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ parameters:
44

55
steps:
66
- bash: pip install --upgrade pip wheel pyo3-pack pytest hypothesis mypy psutil pendulum pytz arrow gunicorn flask twine
7-
- bash: PATH=$HOME/.cargo/bin:$PATH CARGO_INCREMENTAL=0 pyo3-pack build --release --strip --interpreter $(interpreter) --target $(target)
7+
displayName: python dependencies
8+
- bash: PATH=$HOME/.cargo/bin:$PATH pyo3-pack build --release --strip --interpreter $(interpreter) --target $(target)
89
displayName: build
910
- bash: pip install target/wheels/orjson*.whl
1011
displayName: install
@@ -16,7 +17,7 @@ steps:
1617
displayName: thread
1718
- bash: ./integration/run gunicorn
1819
displayName: gunicorn
19-
- bash: ./deploy
20+
- bash: ./deploy target/wheels/*.whl
2021
displayName: deploy
2122
env:
2223
TWINE_PASSWORD: $(TWINE_PASSWORD)

ci/azure-win.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
parameters:
2+
interpreter: ''
3+
target: ''
4+
5+
steps:
6+
- script: |
7+
curl https://win.rustup.rs/x86_64 -o rustup-init.exe
8+
rustup-init.exe -y --default-host $(target) --default-toolchain nightly
9+
set PATH=%PATH%;%USERPROFILE%\.cargo\bin
10+
echo "##vso[task.setvariable variable=PATH;]%PATH%;%USERPROFILE%\.cargo\bin"
11+
displayName: rustup
12+
- script: python.exe -m pip install --upgrade pip wheel
13+
displayName: pip upgrade
14+
- script: python.exe -m pip install --upgrade pyo3-pack pytest hypothesis psutil pendulum pytz arrow twine
15+
displayName: python dependencies
16+
- script: pyo3-pack.exe build --release --strip --interpreter $(interpreter) --target $(target)
17+
displayName: build
18+
- script: python.exe -m pip install orjson --find-links=D:\a\1\s\target\wheels\
19+
displayName: install
20+
- script: python.exe -m pytest -v test
21+
displayName: pytest
22+
- script: python.exe integration\thread
23+
displayName: thread

deploy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ if [[ "$tag" == "undefined" ]]; then
1111
exit 0
1212
fi
1313

14-
twine upload target/wheels/*.whl
14+
twine upload "$1"

src/decode.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,14 @@ impl<'de, 'a> Visitor<'de> for JsonValue {
102102
where
103103
E: de::Error,
104104
{
105-
Ok(unsafe { pyo3::ffi::PyLong_FromLong(value) })
105+
Ok(unsafe { pyo3::ffi::PyLong_FromLongLong(value) })
106106
}
107107

108108
fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E>
109109
where
110110
E: de::Error,
111111
{
112-
Ok(unsafe { pyo3::ffi::PyLong_FromLong(value as i64) })
112+
Ok(unsafe { pyo3::ffi::PyLong_FromLongLong(value as i64) })
113113
}
114114

115115
fn visit_f64<E>(self, value: f64) -> Result<Self::Value, E>

src/encode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ impl<'p> Serialize for SerializePyObject {
8181
} else if unsafe { obj_ptr == FLOAT_PTR } {
8282
serializer.serialize_f64(unsafe { pyo3::ffi::PyFloat_AsDouble(self.ptr) })
8383
} else if unsafe { obj_ptr == INT_PTR } {
84-
let val = unsafe { pyo3::ffi::PyLong_AsLong(self.ptr) };
84+
let val = unsafe { pyo3::ffi::PyLong_AsLongLong(self.ptr) };
8585
if unsafe {
8686
std::intrinsics::unlikely(val == -1 && !pyo3::ffi::PyErr_Occurred().is_null())
8787
} {

0 commit comments

Comments
 (0)