This is an automated email from the ASF dual-hosted git repository.
xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git
The following commit(s) were added to refs/heads/main by this push:
new 8ef38ac4 feat(bindings/python): Enable `abi3` to avoid building on
different python version (#2255)
8ef38ac4 is described below
commit 8ef38ac4492cfc7416319c25851ff0fe4e45cdad
Author: Frost Ming <[email protected]>
AuthorDate: Thu May 11 19:29:52 2023 +0800
feat(bindings/python): Enable `abi3` to avoid building on different python
version (#2255)
Fixes #2252
Signed-off-by: Frost Ming <[email protected]>
---
.github/workflows/bindings_python.yml | 6 +++---
Cargo.lock | 2 --
bindings/python/Cargo.toml | 3 +--
bindings/python/python/opendal/layers.pyi | 15 +++++++++++++++
bindings/python/src/layers.rs | 20 ++++++--------------
5 files changed, 25 insertions(+), 21 deletions(-)
diff --git a/.github/workflows/bindings_python.yml
b/.github/workflows/bindings_python.yml
index 4ad8f744..d69a90c7 100644
--- a/.github/workflows/bindings_python.yml
+++ b/.github/workflows/bindings_python.yml
@@ -67,7 +67,7 @@ jobs:
manylinux: auto
working-directory: "bindings/python"
command: build
- args: --release --sdist -o dist --find-interpreter
+ args: --release --sdist -o dist
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
@@ -83,7 +83,7 @@ jobs:
with:
working-directory: "bindings/python"
command: build
- args: --release -o dist --find-interpreter
+ args: --release -o dist
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
@@ -99,7 +99,7 @@ jobs:
with:
working-directory: "bindings/python"
command: build
- args: --release -o dist --universal2 --find-interpreter
+ args: --release -o dist --universal2
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
diff --git a/Cargo.lock b/Cargo.lock
index d42a5d02..8a986e38 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2711,7 +2711,6 @@ dependencies = [
name = "opendal-python"
version = "0.34.0"
dependencies = [
- "chrono",
"futures",
"opendal",
"pyo3",
@@ -3385,7 +3384,6 @@ source =
"registry+https://github.com/rust-lang/crates.io-index"
checksum = "cfb848f80438f926a9ebddf0a539ed6065434fd7aae03a89312a9821f81b8501"
dependencies = [
"cfg-if",
- "chrono",
"indoc",
"libc",
"memoffset",
diff --git a/bindings/python/Cargo.toml b/bindings/python/Cargo.toml
index 7b59cbd4..f84b8617 100644
--- a/bindings/python/Cargo.toml
+++ b/bindings/python/Cargo.toml
@@ -32,9 +32,8 @@ crate-type = ["cdylib"]
doc = false
[dependencies]
-chrono = { version = "0.4.24", default-features = false, features = ["std"] }
futures = "0.3.28"
opendal.workspace = true
-pyo3 = { version = "0.18", features = ["chrono"] }
+pyo3 = { version = "0.18", features = ["abi3-py37"] }
pyo3-asyncio = { version = "0.18", features = ["tokio-runtime"] }
tokio = "1"
diff --git a/bindings/python/python/opendal/layers.pyi
b/bindings/python/python/opendal/layers.pyi
new file mode 100644
index 00000000..29fad7cf
--- /dev/null
+++ b/bindings/python/python/opendal/layers.pyi
@@ -0,0 +1,15 @@
+class ConcurrentLimitLayer:
+ def __init__(self, permits: int) -> None: ...
+
+class ImmutableIndexLayer:
+ def insert(self, key: str) -> None: ...
+
+class RetryLayer:
+ def __init__(
+ self,
+ max_times: int | None = None,
+ factor: float | None = None,
+ jitter: bool = False,
+ max_delay: float | None = None,
+ min_delay: float | None = None,
+ ) -> None: ...
diff --git a/bindings/python/src/layers.rs b/bindings/python/src/layers.rs
index b643315e..1e7fe72f 100644
--- a/bindings/python/src/layers.rs
+++ b/bindings/python/src/layers.rs
@@ -15,9 +15,9 @@
// specific language governing permissions and limitations
// under the License.
+use std::time::Duration;
+
use ::opendal as od;
-use chrono::Duration;
-use pyo3::exceptions::PyOverflowError;
use pyo3::prelude::*;
#[derive(FromPyObject)]
@@ -73,8 +73,8 @@ impl RetryLayer {
max_times: Option<usize>,
factor: Option<f32>,
jitter: bool,
- max_delay: Option<Duration>,
- min_delay: Option<Duration>,
+ max_delay: Option<f64>,
+ min_delay: Option<f64>,
) -> PyResult<Self> {
let mut retry = od::layers::RetryLayer::default();
if let Some(max_times) = max_times {
@@ -87,18 +87,10 @@ impl RetryLayer {
retry = retry.with_jitter();
}
if let Some(max_delay) = max_delay {
- retry = retry.with_max_delay(
- max_delay
- .to_std()
- .map_err(|err| PyOverflowError::new_err(err.to_string()))?,
- );
+ retry = retry.with_max_delay(Duration::from_micros((max_delay *
1000000.0) as u64));
}
if let Some(min_delay) = min_delay {
- retry = retry.with_min_delay(
- min_delay
- .to_std()
- .map_err(|err| PyOverflowError::new_err(err.to_string()))?,
- );
+ retry = retry.with_min_delay(Duration::from_micros((min_delay *
1000000.0) as u64));
}
Ok(Self(retry))
}