Skip to content

Commit 94946c4

Browse files
committed
chore: Only use process_group on unix systems
1 parent 816b204 commit 94946c4

1 file changed

Lines changed: 29 additions & 15 deletions

File tree

crates/tower-uv/src/lib.rs

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ impl Uv {
9595
// that's easy.
9696
if cwd.join("pyproject.toml").exists() {
9797
debug!("Executing UV ({:?}) sync in {:?}", &self.uv_path, cwd);
98-
let child = Command::new(&self.uv_path)
99-
.kill_on_drop(true)
98+
let mut cmd = Command::new(&self.uv_path);
99+
cmd.kill_on_drop(true)
100100
.stdin(Stdio::null())
101101
.stdout(Stdio::piped())
102102
.stderr(Stdio::piped())
@@ -105,17 +105,22 @@ impl Uv {
105105
.arg("never")
106106
.arg("--no-progress")
107107
.arg("sync")
108-
.envs(env_vars)
109-
.process_group(0)
110-
.spawn()?;
108+
.envs(env_vars);
109+
110+
#[cfg(unix)]
111+
{
112+
cmd.process_group(0);
113+
}
114+
115+
let child = cmd.spawn()?;
111116

112117
Ok(child)
113118
} else if cwd.join("requirements.txt").exists() {
114119
debug!("Executing UV ({:?}) sync with requirements in {:?}", &self.uv_path, cwd);
115120

116121
// If there is a requirements.txt, then we can use that to sync.
117-
let child = Command::new(&self.uv_path)
118-
.kill_on_drop(true)
122+
let mut cmd = Command::new(&self.uv_path);
123+
cmd.kill_on_drop(true)
119124
.stdin(Stdio::null())
120125
.stdout(Stdio::piped())
121126
.stderr(Stdio::piped())
@@ -126,9 +131,14 @@ impl Uv {
126131
.arg("install")
127132
.arg("-r")
128133
.arg(cwd.join("requirements.txt"))
129-
.envs(env_vars)
130-
.process_group(0)
131-
.spawn()?;
134+
.envs(env_vars);
135+
136+
#[cfg(unix)]
137+
{
138+
cmd.process_group(0);
139+
}
140+
141+
let child = cmd.spawn()?;
132142

133143
Ok(child)
134144
} else {
@@ -142,8 +152,8 @@ impl Uv {
142152
pub async fn run(&self, cwd: &PathBuf, program: &PathBuf, env_vars: &HashMap<String, String>) -> Result<Child, Error> {
143153
debug!("Executing UV ({:?}) run {:?} in {:?}", &self.uv_path, program, cwd);
144154

145-
let child = Command::new(&self.uv_path)
146-
.kill_on_drop(true)
155+
let mut cmd = Command::new(&self.uv_path);
156+
cmd.kill_on_drop(true)
147157
.stdin(Stdio::null())
148158
.stdout(Stdio::piped())
149159
.stderr(Stdio::piped())
@@ -153,10 +163,14 @@ impl Uv {
153163
.arg("--no-progress")
154164
.arg("run")
155165
.arg(program)
156-
.envs(env_vars)
157-
.process_group(0)
158-
.spawn()?;
166+
.envs(env_vars);
167+
168+
#[cfg(unix)]
169+
{
170+
cmd.process_group(0);
171+
}
159172

173+
let child = cmd.spawn()?;
160174
Ok(child)
161175
}
162176

0 commit comments

Comments
 (0)