Parse the `home=` value from pyvenv.cfg
(cfg_path: &Path)
| 73 | |
| 74 | /// Parse the `home=` value from pyvenv.cfg |
| 75 | fn read_home(cfg_path: &Path) -> Result<String, Box<dyn core::error::Error>> { |
| 76 | let content = fs::read_to_string(cfg_path)?; |
| 77 | |
| 78 | for line in content.lines() { |
| 79 | let line = line.trim(); |
| 80 | // Skip comments and empty lines |
| 81 | if line.is_empty() || line.starts_with('#') { |
| 82 | continue; |
| 83 | } |
| 84 | |
| 85 | // Look for "home = <path>" or "home=<path>" |
| 86 | if let Some(rest) = line.strip_prefix("home") { |
| 87 | let rest = rest.trim_start(); |
| 88 | if let Some(value) = rest.strip_prefix('=') { |
| 89 | return Ok(value.trim().to_string()); |
| 90 | } |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | Err("'home' key not found in pyvenv.cfg".into()) |
| 95 | } |
| 96 | |
| 97 | /// Launch the Python process and wait for it to complete |
| 98 | fn launch_process(exe: &Path, args: &[String]) -> Result<u32, Box<dyn core::error::Error>> { |