Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
"editor.formatOnSave": true,
"[rust]": {
"editor.defaultFormatter": "rust-lang.rust-analyzer"
},
"[toml]": {
"editor.defaultFormatter": "tamasfe.even-better-toml"
}
}
120 changes: 120 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion crates/pet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ pet-venv = { path = "../pet-venv" }
pet-virtualenv = { path = "../pet-virtualenv" }
pet-pipenv = { path = "../pet-pipenv" }
pet-global-virtualenvs = { path = "../pet-global-virtualenvs" }
log = "0.4.21"
log = "0.4.21"
clap = { version = "4.5.4", features = ["derive"] }
2 changes: 1 addition & 1 deletion crates/pet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub fn find_and_report_envs_jsonrpc() {
locators::find_and_report_envs(&jsonrpc_reporter);
}
pub fn find_and_report_envs_stdio() {
stdio::initialize_logger(log::LevelFilter::Trace);
stdio::initialize_logger(log::LevelFilter::Info);
let jsonrpc_reporter = stdio::create_reporter();
locators::find_and_report_envs(&jsonrpc_reporter);
}
13 changes: 8 additions & 5 deletions crates/pet/src/locators.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

use log::{error, info, warn};
use log::{error, info};
use pet_conda::Conda;
use pet_core::os_environment::{Environment, EnvironmentApi};
use pet_core::python_environment::PythonEnvironment;
Expand Down Expand Up @@ -190,16 +190,19 @@ fn find_in_global_virtual_env_dirs() -> Option<LocatorResult> {
// Before venv, as all venvs are also virtualenvwrapper environments.
// Before virtualenv as this is more specific.
// All venvs are also virtualenvs environments.
let mut found = false;
for locator in &venv_type_locators {
if let Some(env) = locator.as_ref().from(&env) {
environments.push(env);
found = true;
break;
} else {
// We have no idea what this is.
// Lets keep track of this and we can resolve this later.
warn!("Unknown environment: {:?}", env);
}
}
if !found {
// We have no idea what this is.
// We have check all of the resolvers.
error!("Unknown Global Virtual Environment: {:?}", env);
}
}
}
Some(LocatorResult {
Expand Down
40 changes: 22 additions & 18 deletions crates/pet/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

use pet::find_and_report_envs_stdio;
use clap::{Parser, Subcommand};
use pet::{find_and_report_envs_jsonrpc, find_and_report_envs_stdio};

fn main() {
// initialize_logger(LevelFilter::Trace);

// log::info!("Starting Native Locator");
// let now = SystemTime::now();
// let mut dispatcher = create_dispatcher();
#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
pub struct Cli {
#[command(subcommand)]
command: Option<Commands>,
}

find_and_report_envs_stdio();
// find_and_report_envs_jsonrpc();
#[derive(Subcommand, Debug)]
enum Commands {
/// Finds the environments and reports them to the standard output.
Find,
/// Starts the JSON RPC Server (note: today server shuts down immediately, that's a bug).
Server,
}

// match now.elapsed() {
// Ok(elapsed) => {
// log::info!("Native Locator took {} milliseconds.", elapsed.as_millis());
// }
// Err(e) => {
// log::error!("Error getting elapsed time: {:?}", e);
// }
// }
fn main() {
let cli = Cli::parse();
println!("{:?}", cli);

// dispatcher.exit();
match cli.command {
Some(Commands::Server) => find_and_report_envs_jsonrpc(),
_ => find_and_report_envs_stdio(),
}
}