diff --git a/Cargo.lock b/Cargo.lock index 1e9bff3e7..e25e9b228 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -338,7 +338,7 @@ dependencies = [ name = "console" version = "0.1.0" dependencies = [ - "pyo3 0.14.5", + "pyo3", "windows", "winres", ] @@ -370,7 +370,7 @@ dependencies = [ "ordered-float", "parking_lot", "paste 1.0.6", - "pyo3 0.13.2", + "pyo3", "rand", "regex", "rust-ini", @@ -642,17 +642,6 @@ dependencies = [ "wasi", ] -[[package]] -name = "ghost" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a5bcf1bbeab73aa4cf2fde60a846858dc036163c7c33bec309f8d17de785479" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "gimli" version = "0.24.0" @@ -753,28 +742,6 @@ dependencies = [ "cfg-if 1.0.0", ] -[[package]] -name = "inventory" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f0f7efb804ec95e33db9ad49e4252f049e37e8b0a4652e3cd61f7999f2eff7f" -dependencies = [ - "ctor", - "ghost", - "inventory-impl", -] - -[[package]] -name = "inventory-impl" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75c094e94816723ab936484666968f5b58060492e880f3c8d00489a1e244fa51" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "iter-read" version = "0.3.0" @@ -1250,26 +1217,9 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.13.2" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4837b8e8e18a102c23f79d1e9a110b597ea3b684c95e874eb1ad88f8683109c3" -dependencies = [ - "cfg-if 1.0.0", - "ctor", - "indoc", - "inventory", - "libc", - "parking_lot", - "paste 0.1.18", - "pyo3-macros 0.13.2", - "unindent", -] - -[[package]] -name = "pyo3" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35100f9347670a566a67aa623369293703322bb9db77d99d7df7313b575ae0c8" +checksum = "64664505ce285a59b8b7e940fbe54ad65b1758a0810eddc5bc26df6f6ec8c557" dependencies = [ "cfg-if 1.0.0", "indoc", @@ -1277,57 +1227,35 @@ dependencies = [ "parking_lot", "paste 0.1.18", "pyo3-build-config", - "pyo3-macros 0.14.5", + "pyo3-macros", "unindent", ] [[package]] name = "pyo3-build-config" -version = "0.14.5" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d12961738cacbd7f91b7c43bc25cfeeaa2698ad07a04b3be0aa88b950865738f" +checksum = "5f1e4a72de84cdcd69f62211b62f62753d0c11b7b5715f3467f3754dab22a7ca" dependencies = [ "once_cell", ] [[package]] name = "pyo3-macros" -version = "0.13.2" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a47f2c300ceec3e58064fd5f8f5b61230f2ffd64bde4970c81fdd0563a2db1bb" +checksum = "244f21d0a3887a9c02018b94e3b78d693dc7eca5c56839b7796a499cc364deb4" dependencies = [ - "pyo3-macros-backend 0.13.2", - "quote", - "syn", -] - -[[package]] -name = "pyo3-macros" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc0bc5215d704824dfddddc03f93cb572e1155c68b6761c37005e1c288808ea8" -dependencies = [ - "pyo3-macros-backend 0.14.5", - "quote", - "syn", -] - -[[package]] -name = "pyo3-macros-backend" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87b097e5d84fcbe3e167f400fbedd657820a375b034c78bd852050749a575d66" -dependencies = [ - "proc-macro2", + "pyo3-macros-backend", "quote", "syn", ] [[package]] name = "pyo3-macros-backend" -version = "0.14.5" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71623fc593224afaab918aa3afcaf86ed2f43d34f6afde7f3922608f253240df" +checksum = "b3d3d18ac41d05199bb82645d56e39f8c8b4909a0137c6f2640f03685b29f672" dependencies = [ "proc-macro2", "pyo3-build-config", diff --git a/Cargo.toml b/Cargo.toml index 42e331649..471230756 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,6 @@ [workspace] members = ["console_backend", "entrypoint"] +resolver = "2" [profile.release] lto = true diff --git a/Makefile.toml b/Makefile.toml index eb60a1d07..56abb6766 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -11,6 +11,7 @@ if eq ${os} windows set_env BACKEND_WHEEL console_backend-0.1.0-cp39-cp39-win_amd64.whl set_env BUILD_TRIPLET "x86_64-pc-windows-msvc" set_env PYO3_CONFIG_FILE "${WORKSPACE}\\standalone-py\\pyo3_config.txt" + set_env CONSOLE_PYO3_CONFIG_FILE "${WORKSPACE}\\standalone-py\\pyo3_config.txt" elseif eq ${os} linux set_env STANDALONE_PY_URL "${STANDALONE_PY_BASE_URL}/cpython-3.9.7-x86_64-unknown-linux-gnu-pgo+lto-20211017T1616.tar.zst" set_env PYTHON "${WORKSPACE}/py39/bin/python3" @@ -18,6 +19,7 @@ elseif eq ${os} linux set_env PYSIDE2_RCC "${WORKSPACE}/py39/bin/pyside2-rcc" set_env BACKEND_WHEEL console_backend-0.1.0-cp39-cp39-linux_x86_64.whl set_env PYO3_CONFIG_FILE "${WORKSPACE}/standalone-py/pyo3_config.txt" + set_env CONSOLE_PYO3_CONFIG_FILE "${WORKSPACE}/standalone-py/pyo3_config_console.txt" output = exec --fail-on-error gcc -dumpmachine triplet = trim ${output.stdout} set_env BUILD_TRIPLET ${triplet} @@ -28,6 +30,7 @@ else set_env PYSIDE2_RCC "${WORKSPACE}/py39/bin/pyside2-rcc" set_env BACKEND_WHEEL console_backend-0.1.0-cp39-cp39-macosx_10_15_x86_64.whl set_env PYO3_CONFIG_FILE "${WORKSPACE}/standalone-py/pyo3_config.txt" + set_env CONSOLE_PYO3_CONFIG_FILE "${WORKSPACE}/standalone-py/pyo3_config_console.txt" output = exec --fail-on-error gcc -dumpmachine triplet = trim ${output.stdout} set_env BUILD_TRIPLET ${triplet} @@ -239,7 +242,7 @@ args = ["-m", "flit", "build", "--no-setup-py"] [tasks.build-backend-wheel] cwd = "console_backend" command = "${PYTHON}" -args = ["setup.py", "bdist_wheel"] +args = ["setup.py", "-vv", "bdist_wheel"] [tasks.get-get-pip] script_runner = "@duckscript" @@ -247,12 +250,24 @@ script = ''' wget -O ./get-pip.py https://bootstrap.pypa.io/get-pip.py ''' +[tasks.write-pyo3-config-console] +script_runner = "@duckscript" +cwd = "standalone-py" +condition = { files_not_exist = ["${CONSOLE_PYO3_CONFIG_FILE}"] } +script = ''' +writefile pyo3_config_console.txt "implementation=CPython\nversion=3.9\nshared=true\nabi3=false\nlib_name=python3.9\nlib_dir=${WORKSPACE}/standalone-py/python/install/lib\nexecutable=${WORKSPACE}/standalone-py/python/install/bin/python3.9\npointer_width=64\nbuild_flags=WITH_THREAD\nsuppress_build_script_link_lines=false\nextra_build_script_line=cargo:rustc-link-lib=python3.9\nextra_build_script_line=cargo:rustc-link-search=${WORKSPACE}/standalone-py/python/install/lib\n" +''' + +[tasks.write-pyo3-config-console.windows] +script_runner = "@duckscript" +script = "" + [tasks.write-pyo3-config] script_runner = "@duckscript" cwd = "standalone-py" condition = { files_not_exist = ["${PYO3_CONFIG_FILE}"] } script = ''' -writefile pyo3_config.txt "implementation=CPython\nversion=3.9\nshared=true\nabi3=false\nlib_name=python3.9\nlib_dir=${WORKSPACE}/standalone-py/python/install/lib\nexecutable=${WORKSPACE}/standalone-py/python/install/bin/python3.9\npointer_width=64\nbuild_flags=WITH_THREAD\nsuppress_build_script_link_lines=false\n" +writefile pyo3_config.txt "implementation=CPython\nversion=3.9\nshared=true\nabi3=false\nlib_name=python3.9\nlib_dir=${WORKSPACE}/standalone-py/python/install/lib\nexecutable=${WORKSPACE}/standalone-py/python/install/bin/python3.9\npointer_width=64\nbuild_flags=WITH_THREAD\nsuppress_build_script_link_lines=false\nextra_build_script_line=\n" ''' [tasks.write-pyo3-config.windows] @@ -260,7 +275,7 @@ script_runner = "@duckscript" cwd = "standalone-py" condition = { files_not_exist = ["${PYO3_CONFIG_FILE}"] } script = ''' -writefile pyo3_config.txt "implementation=CPython\nversion=3.9\nshared=true\nabi3=false\nlib_name=python39\nlib_dir=${WORKSPACE}\\standalone-py\\python\\install\\libs\nexecutable=${WORKSPACE}\\standalone-py\\python\\install\\python.exe\npointer_width=64\nbuild_flags=WITH_THREAD\nsuppress_build_script_link_lines=false\n" +writefile pyo3_config.txt "implementation=CPython\nversion=3.9\nshared=true\nabi3=false\nlib_name=python39\nlib_dir=${WORKSPACE}\\standalone-py\\python\\install\\libs\nexecutable=${WORKSPACE}\\standalone-py\\python\\install\\python.exe\npointer_width=64\nbuild_flags=WITH_THREAD\nsuppress_build_script_link_lines=false\nextra_build_script_line=\n" ''' [tasks.get-standalone-py] @@ -305,10 +320,19 @@ cd ../../.. exec --fail-on-error ${DIST_PYTHON} ./get-pip.py ''' -[tasks.build-console] +[tasks.call-build-console-bin] +private = true command = "cargo" args = ["build", "--release", "-vv", "--bin", "console"] +[tasks.build-console] +env = { PYO3_CONFIG_FILE = "${CONSOLE_PYO3_CONFIG_FILE}" } +dependencies = ["write-pyo3-config-console"] +run_task = "call-build-console-bin" + +[tasks.build-console.windows] +dependencies = ["call-build-console-bin"] + [tasks.build-dist-install-console] dependencies = ["build-console"] script_runner = "@duckscript" diff --git a/console_backend/Cargo.toml b/console_backend/Cargo.toml index ba20d6cca..8d2c53a07 100644 --- a/console_backend/Cargo.toml +++ b/console_backend/Cargo.toml @@ -16,7 +16,10 @@ capnp = "0.14" chrono = { version = "0.4", features = ["serde"] } csv = "1" paste = "1" -pyo3 = { version = "0.13", features = ["extension-module"], optional = true } +pyo3 = { version = "0.15", features = [ + "extension-module", + "macros", +], default-features = false, optional = true } serde = { version = "1.0.123", features = ["derive"] } tempfile = "3.2.0" ordered-float = "2.0" diff --git a/console_backend/src/server.rs b/console_backend/src/server.rs index 6416b28d3..7c2835ead 100644 --- a/console_backend/src/server.rs +++ b/console_backend/src/server.rs @@ -43,7 +43,7 @@ impl ServerEndpoint { ServerEndpoint { server_send: None } } - #[text_signature = "($self, bytes, /)"] + #[pyo3(text_signature = "($self, bytes, /)")] pub fn shutdown(&mut self) -> PyResult<()> { if let Some(server_send) = self.server_send.take() { drop(server_send); @@ -55,7 +55,7 @@ impl ServerEndpoint { } } - #[text_signature = "($self, bytes, /)"] + #[pyo3(text_signature = "($self, bytes, /)")] pub fn send_message(&mut self, bytes: &PyBytes) -> PyResult<()> { let byte_vec: Vec = bytes.extract().unwrap(); if let Some(server_send) = &self.server_send { @@ -80,7 +80,7 @@ impl Server { } } - #[text_signature = "($self, /)"] + #[pyo3(text_signature = "($self, /)")] pub fn fetch_message(&mut self, py: Python) -> Option { let result = py.allow_threads(move || loop { if let Some(client_recv) = &self.client_recv { @@ -109,7 +109,7 @@ impl Server { result.map(|result| PyBytes::new(py, &result).into()) } - #[text_signature = "($self, /)"] + #[pyo3(text_signature = "($self, /)")] pub fn start(&mut self) -> PyResult { attach_console(); let (client_send, client_recv) = channel::unbounded(); diff --git a/entrypoint/Cargo.toml b/entrypoint/Cargo.toml index 30bd32da8..6ce84274b 100644 --- a/entrypoint/Cargo.toml +++ b/entrypoint/Cargo.toml @@ -4,10 +4,11 @@ name = "console" version = "0.1.0" description = "Starts the console with the correct python installation" edition = "2018" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -pyo3 = { version = "0.14.5", features = ["auto-initialize"] } +pyo3 = { version = "0.15", features = [ + "auto-initialize", +], default-features = false } [[bin]] name = "console" diff --git a/standalone-py/.gitignore b/standalone-py/.gitignore index 9ecce32c2..f08d02ae0 100644 --- a/standalone-py/.gitignore +++ b/standalone-py/.gitignore @@ -1,4 +1,4 @@ *.*~ -pyo3_config.txt +pyo3_config*.txt py39.* python/