From 55da78ad912a8fa1a428be11a21bfbcb29bcb81b Mon Sep 17 00:00:00 2001 From: Camillo Schenone Date: Sat, 23 Mar 2024 18:55:26 +0100 Subject: [PATCH] chore: name change and build script tweak, adding the wheel Former-commit-id: e77044f56c199268115c8768d69b4fe06357d6c3 --- Cargo.toml | 4 ++-- ...-cp38-macosx_11_0_arm64.whl.REMOVED.git-id | 1 + ...codemp.cpython-38-darwin.so.REMOVED.git-id | 1 + build.sh | 23 +++++++++++++------ plugin.py | 21 +++++++++-------- src/lib.rs | 6 ++--- src/wrappers.py | 2 +- 7 files changed, 35 insertions(+), 23 deletions(-) create mode 100644 bindings/Codemp_Sublime-0.6.1-cp38-cp38-macosx_11_0_arm64.whl.REMOVED.git-id create mode 100644 bindings/codemp.cpython-38-darwin.so.REMOVED.git-id diff --git a/Cargo.toml b/Cargo.toml index ffa26ba..943d9d3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,11 +1,11 @@ [package] -name = "CodempClient-Sublime" +name = "Codemp-Sublime" version = "0.6.1" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [lib] -name = "codemp_client" +name = "codemp" crate-type = ["cdylib"] [dependencies] diff --git a/bindings/Codemp_Sublime-0.6.1-cp38-cp38-macosx_11_0_arm64.whl.REMOVED.git-id b/bindings/Codemp_Sublime-0.6.1-cp38-cp38-macosx_11_0_arm64.whl.REMOVED.git-id new file mode 100644 index 0000000..ba1f3ec --- /dev/null +++ b/bindings/Codemp_Sublime-0.6.1-cp38-cp38-macosx_11_0_arm64.whl.REMOVED.git-id @@ -0,0 +1 @@ +f629b2a823b8f4d351a4641f0f42bf84f95406c8 \ No newline at end of file diff --git a/bindings/codemp.cpython-38-darwin.so.REMOVED.git-id b/bindings/codemp.cpython-38-darwin.so.REMOVED.git-id new file mode 100644 index 0000000..fdceec4 --- /dev/null +++ b/bindings/codemp.cpython-38-darwin.so.REMOVED.git-id @@ -0,0 +1 @@ +5f1dfe7e8371de1f4967223a801cf49286065133 \ No newline at end of file diff --git a/build.sh b/build.sh index 541b07a..71281e1 100755 --- a/build.sh +++ b/build.sh @@ -1,18 +1,27 @@ #!/bin/sh ROOT_DIR="$(pwd)" -BUILD_DIR="$ROOT_DIR/target/debug/deps" -FILENAME="libcodemp_client" +BUILD_DIR="$ROOT_DIR/target/debug/" +WHEEL_DIR="$ROOT_DIR/target/wheels" +FILENAME="libcodemp" TARGET_DIR="$ROOT_DIR/bindings" -TARGET_NAME="codemp_client" +SO_NAME="codemp" +WHEEL_NAME="Codemp_Sublime" PYO3_PYTHON="$(pyenv which python)" TARGET_EXT="$($PYO3_PYTHON -c 'import sysconfig; print(sysconfig.get_config_var("EXT_SUFFIX"))')" -FULL_TARGET="${TARGET_NAME}${TARGET_EXT}" +SO_TARGET="${SO_NAME}${TARGET_EXT}" -echo "Building with python: $PYO3_PYTHON" +echo "Building .SO with python: $PYO3_PYTHON" env PYO3_PYTHON="${PYO3_PYTHON}" cargo build -echo "Copying into: $TARGET_DIR/$FULL_TARGET" +echo "Copying into: $TARGET_DIR/$SO_TARGET" -ditto "$BUILD_DIR/${FILENAME}.dylib" "$TARGET_DIR/$FULL_TARGET" +echo "Building python wheel..." +maturin build -i "$PYO3_PYTHON" + +wheels=($WHEEL_DIR/$WHEEL_NAME*.whl) +for whl in $wheels; do + cp $whl $TARGET_DIR +done +ditto "$BUILD_DIR/${FILENAME}.dylib" "$TARGET_DIR/$SO_TARGET" diff --git a/plugin.py b/plugin.py index 3aa8623..aed653f 100644 --- a/plugin.py +++ b/plugin.py @@ -1,16 +1,17 @@ import sublime import sublime_plugin -from Codemp.src.codemp_client import VirtualClient -from Codemp.src.codemp_client import CodempLogger -from Codemp.src.TaskManager import rt -from Codemp.src.utils import status_log -from Codemp.src.utils import safe_listener_detach -from Codemp.src.utils import get_contents -from Codemp.src.utils import populate_view -from Codemp.src.utils import get_view_from_local_path -import Codemp.src.globals as g -from Codemp.bindings.codemp_client import init_logger +# import os +# import sys +# import importlib.util + +from .src.codemp_client import VirtualClient +from .src.codemp_client import CodempLogger +from .src.TaskManager import rt +from .src.utils import status_log +from .src.utils import safe_listener_detach +from .src import globals as g +from .bindings.codemp import init_logger CLIENT = None TEXT_LISTENER = None diff --git a/src/lib.rs b/src/lib.rs index b8b7b6d..4c97fdc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,8 +4,8 @@ use tokio::sync::{mpsc, Mutex, RwLock}; use tracing; use tracing_subscriber; -use codemp::errors::Error as CodempError; -use codemp::prelude::*; +use ::codemp::errors::Error as CodempError; +use ::codemp::prelude::*; use codemp_proto::{ common::Identity, cursor::{CursorEvent, CursorPosition}, @@ -536,7 +536,7 @@ impl PyTextChange { /* ------ Python module --------*/ #[pymodule] -fn codemp_client(_py: Python, m: &PyModule) -> PyResult<()> { +fn codemp(_py: Python, m: &PyModule) -> PyResult<()> { m.add_function(wrap_pyfunction!(codemp_init, m)?)?; m.add_function(wrap_pyfunction!(init_logger, m)?)?; m.add_class::()?; diff --git a/src/wrappers.py b/src/wrappers.py index 0964662..0e54447 100644 --- a/src/wrappers.py +++ b/src/wrappers.py @@ -1,6 +1,6 @@ from __future__ import annotations from typing import Optional -from Codemp.bindings.codemp_client import codemp_init, PyCursorEvent, PyTextChange, PyId +from ..bindings.codemp import codemp_init, PyCursorEvent, PyTextChange, PyId ###################################################################################### # These are helper wrappers, that wrap the coroutines returned from the