diff --git a/dist/py/build.sh b/dist/py/build.sh index d48d0a0..b4af45d 100755 --- a/dist/py/build.sh +++ b/dist/py/build.sh @@ -6,17 +6,26 @@ TARGET_EXT="$($PYO3_PYTHON -c 'import sysconfig; print(sysconfig.get_config_var( maturin build -i "$PYO3_PYTHON" --out "$WHEEL_DIR" -CODEMPSUBLIME_DIR="../../../codemp-sublime/bindings/" +echo "\nAUTOINSTALL - REMOVE AFTER TESTING\n" + +CODEMPSUBLIME_DIR="../../../codemp-sublime/" CODEMPTEST_DIR="../../../codemp-python-test/" wheels=($WHEEL_DIR/*.whl) for wheel in $wheels; do echo "moving $wheel to $CODEMPSUBLIME_DIR" - cp $wheel "$CODEMPSUBLIME_DIR" + cp $wheel "$CODEMPSUBLIME_DIR/bindings/" cp $wheel "$CODEMPTEST_DIR" done -cd "$CODEMPSUBLIME_DIR" +pushd "$CODEMPTEST_DIR" source .venv/bin/activate pip install $wheel --force-reinstall +deactivate +popd +pushd "$CODEMPSUBLIME_DIR" +source .venv/bin/activate +pip install $wheel --force-reinstall +deactivate +popd diff --git a/src/ffi/python/controllers.rs b/src/ffi/python/controllers.rs index f68f14f..9865836 100644 --- a/src/ffi/python/controllers.rs +++ b/src/ffi/python/controllers.rs @@ -31,16 +31,28 @@ impl CursorController { } #[pyo3(name = "try_recv")] - fn pytry_recv(&self, py: Python) -> PyResult { + fn pytry_recv(&self, py: Python) -> PyResult { + // why? I want try-recv to have that 'blocking' flavour, for the "cool guy async" approach there's + // 'recv'... let this = self.clone(); - a_sync_allow_threads!(py, this.try_recv().await) + let prom: crate::Result = a_sync_allow_threads!(py, this.try_recv().await); + prom?._await(py) + // // bad situation, here we either return an opaque PyResult + // // or if we want to return exacly a Result> we would need to extract it back + // // into a rust object... which is expensive. + // // This is stupid isn't it? + // // the PyResult> will become a PyObject anyway to be returned back... lmao + // let this = self.clone(); + // let prom: crate::Result = a_sync_allow_threads!(py, this.try_recv().await); + // let pyobj = prom?._await(py)?; + // let opt = pyobj.extract::>(py)?; + // Ok(opt) } #[pyo3(name = "recv")] - fn pyrecv(&self, py: Python) -> crate::Result> { - py.allow_threads(|| super::tokio().block_on(self.try_recv())) - // let this = self.clone(); - // a_sync_allow_threads!(py, this.recv().await) + fn pyrecv(&self, py: Python) -> PyResult { + let this = self.clone(); + a_sync_allow_threads!(py, this.recv().await) } #[pyo3(name = "poll")]