(cwd: Option<&String>)
| 19 | const VENV_COMPAT_SCRIPT: &str = include_str!("venv_compat.sh"); |
| 20 | |
| 21 | pub fn symlink_libpython(cwd: Option<&String>) -> anyhow::Result<()> { |
| 22 | let rwx = std::fs::Permissions::from_mode(0o777); |
| 23 | let mut script_file = tempfile::Builder::new() |
| 24 | .suffix(".sh") |
| 25 | .permissions(rwx) |
| 26 | .tempfile()?; |
| 27 | script_file.write_all(VENV_COMPAT_SCRIPT.as_bytes())?; |
| 28 | |
| 29 | let mut cmd = Command::new("bash"); |
| 30 | cmd.arg(script_file.path()); |
| 31 | |
| 32 | if let Some(cwd) = cwd { |
| 33 | cmd.current_dir(cwd); |
| 34 | } |
| 35 | |
| 36 | debug!("Running the venv compat script"); |
| 37 | let output = cmd.output()?; |
| 38 | |
| 39 | let stdout = String::from_utf8(output.stdout)?; |
| 40 | debug!("Script output: {stdout}"); |
| 41 | |
| 42 | if !output.status.success() { |
| 43 | let stderr = String::from_utf8(output.stderr)?; |
| 44 | bail!("Failed to execute script: {stdout} {stderr}"); |
| 45 | } |
| 46 | |
| 47 | Ok(()) |
| 48 | } |
| 49 | |
| 50 | #[cfg(test)] |
| 51 | mod tests { |
no test coverage detected