From 2422da0e5fa9192424a88c199b7cfb00741cf739 Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Wed, 22 Nov 2023 13:28:08 -0800 Subject: [PATCH] Dont use user. --- CHANGELOG.md | 10 +++++++++ Cargo.lock | 20 ++++++++++++------ Cargo.toml | 2 +- README.md | 4 ---- rust-toolchain.toml | 2 +- src/proto.rs | 50 +++++---------------------------------------- 6 files changed, 31 insertions(+), 57 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 97c43e1..4193451 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## 0.3.0 + +#### 💥 Breaking + +- Removed `--user` from global package installation via `proto install-global`. Packages are now installed into the tool directory for the current Python version: `.proto/tools/python/3.12.0/install/bin`. + +#### ⚙️ Internal + +- Updated dependencies. + ## 0.2.1 #### 🐞 Fixes diff --git a/Cargo.lock b/Cargo.lock index cca91e4..8cde653 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2017,9 +2017,9 @@ dependencies = [ [[package]] name = "proto_core" -version = "0.23.2" +version = "0.23.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44b64578ff10a1a39d3a3d94e0725c0ecdc5858ec6c42844289530dd15981b22" +checksum = "37b4467e6e2819e74fc2247ff2d69486713414386fcc6549d172748bbcfa2a57" dependencies = [ "cached", "extism", @@ -2038,6 +2038,7 @@ dependencies = [ "starbase_events", "starbase_styles", "starbase_utils", + "system_env", "thiserror", "tinytemplate", "tracing", @@ -2076,9 +2077,9 @@ dependencies = [ [[package]] name = "proto_pdk_test_utils" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e903c50774be861c179391305e68f529d758bb8255eb91c1c688c28c7d770bf" +checksum = "2a2d0ec151cb028a169a2a87f184f54e3c6bda24c62a1cc22154df26be485343" dependencies = [ "extism", "proto_core", @@ -2591,6 +2592,12 @@ dependencies = [ "digest", ] +[[package]] +name = "shell-words" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" + [[package]] name = "shellexpand" version = "2.1.2" @@ -2844,12 +2851,13 @@ dependencies = [ [[package]] name = "system_env" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5430c2b1d8315d22edaebbd40617f9110ccfd95e95684802d0d17907f44966" +checksum = "63476c953552c18056a153eaabc04d2987bc64f07633acc80d6a65a8574f1a3b" dependencies = [ "serde", "serde_json", + "shell-words", "thiserror", ] diff --git a/Cargo.toml b/Cargo.toml index 908b5b6..5dbba7d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ regex = { version = "1.10.2", default-features = false, features = ["std"] } serde = "1.0.193" [dev-dependencies] -proto_pdk_test_utils = { version = "0.11.0" } # , path = "../../proto/crates/pdk-test-utils" } +proto_pdk_test_utils = { version = "0.11.1" } # , path = "../../proto/crates/pdk-test-utils" } starbase_sandbox = "0.1.12" tokio = { version = "1.34.0", features = ["full"] } diff --git a/README.md b/README.md index 497e67a..8b91997 100644 --- a/README.md +++ b/README.md @@ -8,10 +8,6 @@ This will install a pre-built version from [indygreg/python-build-standalone](ht Building from source directly (with `python-build`), and supporting Python 2, will be fully supported in the future. -### Global packages - -When globals are installed with `proto install-global python`, we install them using `pip --user`, which installs them to `~/.local/lib/pythonX.Y/site-packages` or `~/.local/bin` on Linux and macOS, and `~/AppData/Roaming/Python/PythonXY/Scripts` on Windows. - ## Contributing Build the plugin: diff --git a/rust-toolchain.toml b/rust-toolchain.toml index f172dde..89705a9 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] profile = "default" -channel = "1.73.0" +channel = "1.74.0" diff --git a/src/proto.rs b/src/proto.rs index 5e80a49..bc39401 100644 --- a/src/proto.rs +++ b/src/proto.rs @@ -126,53 +126,13 @@ pub fn download_prebuilt( })) } -// https://docs.python.org/2/library/site.html#site.USER_SITE -fn get_globals_dirs(env: &HostEnvironment, spec: &VersionSpec) -> Vec { - let mut dirs = vec![]; - - if let VersionSpec::Version(version) = spec { - // %APPDATA% == ~/AppData/Roaming - if env.os == HostOS::Windows { - let version_stamp = format!("{}{}", version.major, version.minor); - - dirs.push(format!( - "$HOME/AppData/Roaming/Python/Python{}/site-packages", - version_stamp - )); - dirs.push(format!( - "$HOME/AppData/Roaming/Python/Python{}/Scripts", - version_stamp - )); - } else { - let version_dot_stamp = format!("{}.{}", version.major, version.minor); - - if env.os == HostOS::MacOS { - dirs.push(format!( - "$HOME/Library/Python/{}/lib/python/site-packages", - version_dot_stamp - )); - } - - dirs.push(format!( - "$HOME/.local/lib/python{}/site-packages", - version_dot_stamp - )); - } - } - - if env.os != HostOS::Windows { - dirs.push("$HOME/.local/bin".to_owned()); - } - - dirs -} #[plugin_fn] pub fn locate_executables( Json(input): Json, ) -> FnResult> { let env = get_proto_environment()?; - let mut exe_path = env.os.get_exe_name("install/bin/python3"); + let mut exe_path = env.os.for_native("install/bin/python3", "install/python.exe").to_owned(); // Manifest is only available for pre-builts let manifest_path = input.context.tool_dir.join("PYTHON.json"); @@ -182,7 +142,7 @@ pub fn locate_executables( } Ok(Json(LocateExecutablesOutput { - globals_lookup_dirs: get_globals_dirs(&env, &input.context.version), + globals_lookup_dirs: vec![env.os.for_native("$TOOL_DIR/install/bin", "$TOOL_DIR/install/Scripts").into()], primary: Some(ExecutableConfig::new(exe_path)), secondary: HashMap::from_iter([ // pip @@ -203,7 +163,7 @@ pub fn locate_executables( pub fn install_global( Json(input): Json, ) -> FnResult> { - let result = exec_command!(inherit, "pip", ["install", "--user", &input.dependency]); + let result = exec_command!(inherit, "pip", ["install", &input.dependency]); Ok(Json(InstallGlobalOutput::from_exec_command(result))) } @@ -223,7 +183,7 @@ pub fn uninstall_global( #[plugin_fn] pub fn locate_bins(Json(input): Json) -> FnResult> { let env = get_proto_environment()?; - let mut bin_path = env.os.get_exe_name("install/bin/python3"); + let mut bin_path = env.os.for_native("install/bin/python3", "install/python.exe").to_owned(); // Manifest is only available for pre-builts let manifest_path = input.context.tool_dir.join("PYTHON.json"); @@ -237,7 +197,7 @@ pub fn locate_bins(Json(input): Json) -> FnResult