From 32d475a37c0378f39a5c61e2b61c8e1b4e2fd70c Mon Sep 17 00:00:00 2001 From: Sanskar Jethi Date: Thu, 5 Aug 2021 01:55:07 +0530 Subject: [PATCH] Update to pyo3 v0.14 test with extension module Check pipeline Fix pyo3 pipeline Try changing shell Try removing deprecation Update latest Cargo files --- .github/workflows/CI.yml | 5 +-- Cargo.lock | 66 ++++++++++++++++++++++++++-------------- Cargo.toml | 9 ++---- src/processor.rs | 2 +- src/server.rs | 10 ++++++ test.py | 2 +- 6 files changed, 61 insertions(+), 33 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index e04a4c740..6631b9292 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -37,7 +37,7 @@ jobs: args: -i python --release --universal2 --out dist --no-sdist - name: Install built wheel - universal2 run: | - pip install --force-reinstall dist/robyn*.whl + pip install --force-reinstall dist/robyn*_universal2.whl cd ~ && python -c 'import robyn' - name: Upload wheels uses: actions/upload-artifact@v2 @@ -69,8 +69,9 @@ jobs: target: ${{ matrix.target }} args: -i python --release --out dist --no-sdist - name: Install built wheel + shell: bash run: | - pip install robyn --no-index --find-links dist --force-reinstall + pip install --force-reinstall dist/robyn*.whl cd ~ && python -c 'import robyn' - name: Upload wheels uses: actions/upload-artifact@v2 diff --git a/Cargo.lock b/Cargo.lock index 8ea608b42..008ccecfd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -714,9 +714,9 @@ checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" [[package]] name = "jobserver" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "972f5ae5d1cb9c6ae417789196c803205313edde988685da5e3aae0827b9e7fd" +checksum = "f5ca711fd837261e14ec9e674f092cbb931d3fa1482b017ae59328ddc6f3212b" dependencies = [ "libc", ] @@ -982,39 +982,58 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.13.2" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4837b8e8e18a102c23f79d1e9a110b597ea3b684c95e874eb1ad88f8683109c3" +checksum = "338f7f3701e11fd7f76508c91fbcaabc982564bcaf4d1ca7e1574ff2b4778aec" dependencies = [ "cfg-if", - "ctor", "indoc", - "inventory", "libc", "parking_lot", "paste 0.1.18", + "pyo3-build-config", "pyo3-macros", "unindent", ] [[package]] name = "pyo3-asyncio" -version = "0.13.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5f22bea2f54bc9ffa9c3c5084b1d6577ac7a6ce5291cffa018f193ec60be15f" +version = "0.14.0" +source = "git+https://github.com/awestlake87/pyo3-asyncio?rev=dd6f2cc7838a2990ed15447ff9ef9f93fa51423d#dd6f2cc7838a2990ed15447ff9ef9f93fa51423d" dependencies = [ "futures", "inventory", "lazy_static", "once_cell", "pyo3", + "pyo3-asyncio-macros", + "tokio", +] + +[[package]] +name = "pyo3-asyncio-macros" +version = "0.14.0" +source = "git+https://github.com/awestlake87/pyo3-asyncio?rev=dd6f2cc7838a2990ed15447ff9ef9f93fa51423d#dd6f2cc7838a2990ed15447ff9ef9f93fa51423d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pyo3-build-config" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcb2e98cc9ccc83d4f7115c8f925e0057e88c8d324b1bc4c2db4a7270c06ac9d" +dependencies = [ + "once_cell", ] [[package]] name = "pyo3-macros" -version = "0.13.2" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a47f2c300ceec3e58064fd5f8f5b61230f2ffd64bde4970c81fdd0563a2db1bb" +checksum = "cfb8671a42d0ecc4bec8cc107ae96d49292ca20cd1968e09b98af4aafd516adf" dependencies = [ "pyo3-macros-backend", "quote", @@ -1023,11 +1042,12 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.13.2" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87b097e5d84fcbe3e167f400fbedd657820a375b034c78bd852050749a575d66" +checksum = "9addf6dc422f05d4949cc0990195ee74fa43e3c3780cc9a1972fe9e7b68a9f48" dependencies = [ "proc-macro2", + "pyo3-build-config", "quote", "syn", ] @@ -1531,9 +1551,9 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" [[package]] name = "wasm-bindgen" -version = "0.2.74" +version = "0.2.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54ee1d4ed486f78874278e63e4069fc1ab9f6a18ca492076ffb90c5eb2997fd" +checksum = "b608ecc8f4198fe8680e2ed18eccab5f0cd4caaf3d83516fa5fb2e927fda2586" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -1541,9 +1561,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.74" +version = "0.2.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b33f6a0694ccfea53d94db8b2ed1c3a8a4c86dd936b13b9f0a15ec4a451b900" +checksum = "580aa3a91a63d23aac5b6b267e2d13cb4f363e31dce6c352fca4752ae12e479f" dependencies = [ "bumpalo", "lazy_static", @@ -1556,9 +1576,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.74" +version = "0.2.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "088169ca61430fe1e58b8096c24975251700e7b1f6fd91cc9d59b04fb9b18bd4" +checksum = "171ebf0ed9e1458810dfcb31f2e766ad6b3a89dbda42d8901f2b268277e5f09c" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1566,9 +1586,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.74" +version = "0.2.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be2241542ff3d9f241f5e2cb6dd09b37efe786df8851c54957683a49f0987a97" +checksum = "6c2657dd393f03aa2a659c25c6ae18a13a4048cebd220e147933ea837efc589f" dependencies = [ "proc-macro2", "quote", @@ -1579,9 +1599,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.74" +version = "0.2.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7cff876b8f18eed75a66cf49b65e7f967cb354a7aa16003fb55dbfd25b44b4f" +checksum = "2e0c4a743a309662d45f4ede961d7afa4ba4131a59a639f29b0069c3798bbcc2" [[package]] name = "winapi" diff --git a/Cargo.toml b/Cargo.toml index c6f18cb71..99e62fba2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,16 +14,13 @@ name = "robyn" crate-type = ["cdylib", "rlib"] [dependencies.pyo3] -version = "0.13.2" -features = ["extension-module"] - -[dependencies.pyo3-asyncio] -version = "0.13.4" -features = [] +version = "0.14.1" +features = ["extension-module", "auto-initialize"] [dependencies] tokio = { version = "1.7.0", features = ["full"] } dashmap = {git = "https://github.com/quake/dashmap", branch = "parking_lot", features = ["parking_lot"]} +pyo3-asyncio = { git = "https://github.com/awestlake87/pyo3-asyncio", rev = "dd6f2cc7838a2990ed15447ff9ef9f93fa51423d", features = ["attributes", "tokio-runtime"] } anyhow = "1.0.38" actix-web = "4.0.0-beta.8" futures-util = "0.3.15" diff --git a/src/processor.rs b/src/processor.rs index 0c71daa31..9efc785b5 100644 --- a/src/processor.rs +++ b/src/processor.rs @@ -109,7 +109,7 @@ async fn execute_function( } None => handler.call0(), }; - pyo3_asyncio::into_future(coro?) + pyo3_asyncio::tokio::into_future(coro?) })?; let output = output.await?; let res = Python::with_gil(|py| -> PyResult { diff --git a/src/server.rs b/src/server.rs index 3cc7fe825..013fc6620 100644 --- a/src/server.rs +++ b/src/server.rs @@ -63,6 +63,16 @@ impl Server { }); }); + // let asyncio = py.import("asyncio").unwrap(); + + // let event_loop = asyncio.call_method0("new_event_loop").unwrap(); + // asyncio + // .call_method1("set_event_loop", (event_loop,)) + // .unwrap(); + + // event_loop.call_method0("run_forever").unwrap(); + // println!("test test_run_forever ... ok"); + run_forever(py).unwrap() } diff --git a/test.py b/test.py index a659aee4d..9caf3df21 100644 --- a/test.py +++ b/test.py @@ -54,4 +54,4 @@ def blocker(): if __name__ == "__main__": app.add_header("server", "robyn") - app.start(port=5000) + app.start(port=5001)