Skip to content

Commit 29462e0

Browse files
committed
back out OsString additions and added string literal disignation to
targets
1 parent 40c2802 commit 29462e0

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

rust/origen/cli/src/commands/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ pub fn launch(
2020
);
2121

2222
if let Some(t) = targets {
23-
let _t: Vec<String> = t.iter().map(|__t| format!("'{}'", __t)).collect();
23+
// added r prefix to the string to force python to interpret as a string literal
24+
let _t: Vec<String> = t.iter().map(|__t| format!("r'{}'", __t)).collect();
2425
cmd += &format!(", targets=[{}]", &_t.join(",")).to_string();
2526
}
2627

rust/origen/cli/src/commands/setup.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use origen::core::term::*;
66
use std::fs;
77
use std::io;
88
use std::path::PathBuf;
9-
use std::ffi::OsString;
109
use std::process::Command;
1110

1211
const POETRY_INSTALLER: &str =
@@ -65,7 +64,7 @@ pub fn run() {
6564
fs::read_to_string(&get_poetry_file).expect("Unable to read Poetry install file");
6665
let new_data = data.replace(
6766
"/bin/env python",
68-
&format!("/bin/env {}", PYTHON_CONFIG.command.clone().into_string().unwrap()),
67+
&format!("/bin/env {}", PYTHON_CONFIG.command),
6968
);
7069
fs::write(&get_poetry_file, new_data).expect("Unable to write Poetry install file");
7170

@@ -80,8 +79,8 @@ pub fn run() {
8079
// Have to use --preview here to get a 1.0.0 pre version, can only use versions for
8180
// official releases
8281
Command::new(&PYTHON_CONFIG.poetry_command)
83-
.arg(OsString::from("self:update"))
84-
.arg(OsString::from("--preview"))
82+
.arg("self:update")
83+
.arg("--preview")
8584
.status()
8685
.expect("Something wend wrong updating Poetry");
8786
}
@@ -92,8 +91,8 @@ pub fn run() {
9291
print!("Are the app's deps. installed? ... ");
9392

9493
let status = Command::new(&PYTHON_CONFIG.poetry_command)
95-
.arg(OsString::from("install"))
96-
.arg(OsString::from("--no-root"))
94+
.arg("install")
95+
.arg("--no-root")
9796
.status();
9897

9998
if status.is_ok() {

rust/origen/cli/src/python.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Responsible for managing Python execution
22

33
use std::process::Command;
4-
use std::ffi::OsString;
54
use origen::STATUS;
65
use semver::Version;
76
use std::path::PathBuf;
@@ -22,7 +21,7 @@ lazy_static! {
2221

2322
pub struct Config {
2423
pub available: bool,
25-
pub command: OsString,
24+
pub command: String,
2625
pub version: Version,
2726
pub error: String,
2827
pub poetry_command: PathBuf,
@@ -41,7 +40,7 @@ impl Default for Config {
4140
if version >= Version::parse(MIN_PYTHON_VERSION).unwrap() {
4241
return Config {
4342
available: true,
44-
command: OsString::from(cmd.to_string()),
43+
command: cmd.to_string(),
4544
version: version,
4645
error: "".to_string(),
4746
poetry_command: poetry_cmd,
@@ -57,7 +56,7 @@ impl Default for Config {
5756
}
5857
Config {
5958
available: false,
60-
command: OsString::new(),
59+
command: String::new(),
6160
version: Version::parse("0.0.0").unwrap(),
6261
error: msg,
6362
poetry_command: PathBuf::new(),
@@ -67,7 +66,7 @@ impl Default for Config {
6766

6867
/// Get the Python version from the given command
6968
fn get_version(command: &str) -> Option<Version> {
70-
match Command::new(OsString::from(command)).arg("--version").output() {
69+
match Command::new(command).arg("--version").output() {
7170
Ok(output) => return extract_version(std::str::from_utf8(&output.stdout).unwrap()),
7271
Err(_e) => return None,
7372
}
@@ -105,7 +104,7 @@ pub fn run(code: &str) {
105104
.arg("run")
106105
.arg(&PYTHON_CONFIG.command)
107106
.arg("-c")
108-
.arg(OsString::from(&code))
107+
.arg(&code)
109108
.status();
110109
}
111110

0 commit comments

Comments
 (0)