Skip to content

Commit 02502cb

Browse files
committed
Fix setuptools install
1 parent 4d73a3a commit 02502cb

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

src/dev_dependency_installer.rs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ fn poetry_dev_dependency_installer(project_info: &ProjectInfo) -> Result<()> {
6666
}
6767

6868
fn setuptools_dev_dependency_installer(project_info: &ProjectInfo) -> Result<()> {
69-
let venv_path = project_info.base_dir().join(".venv");
69+
let base_dir = project_info.base_dir().canonicalize()?;
70+
let venv_path = base_dir.join(".venv");
7071
if !venv_path.exists() {
7172
let venv_output = std::process::Command::new("python")
7273
.args(["-m", "venv", ".venv"])
@@ -80,9 +81,9 @@ fn setuptools_dev_dependency_installer(project_info: &ProjectInfo) -> Result<()>
8081
}
8182

8283
let python_bin = if cfg!(windows) {
83-
".venv/Scripts/python.exe"
84+
venv_path.join("Scripts").join("python.exe")
8485
} else {
85-
".venv/bin/python"
86+
venv_path.join("bin").join("python")
8687
};
8788

8889
let packages = determine_dev_packages(project_info)?;
@@ -92,7 +93,7 @@ fn setuptools_dev_dependency_installer(project_info: &ProjectInfo) -> Result<()>
9293
let package_refs: Vec<&str> = package_specs.iter().map(|s| s.as_str()).collect();
9394
args.extend(package_refs);
9495

95-
let output = std::process::Command::new(python_bin)
96+
let output = std::process::Command::new(&python_bin)
9697
.args(args)
9798
.current_dir(project_info.base_dir())
9899
.output()?;
@@ -169,21 +170,21 @@ fn poetry_precommit_autoupdate(project_info: &ProjectInfo) -> Result<()> {
169170
}
170171

171172
fn setuptools_precommit_autoupdate(project_info: &ProjectInfo) -> Result<()> {
172-
let base_dir = project_info.base_dir();
173+
let base_dir = project_info.base_dir().canonicalize()?;
173174
let venv_path = base_dir.join(".venv");
174175

175176
if !venv_path.exists() {
176177
bail!("Virtual environment not found at {}", venv_path.display());
177178
}
178179

179-
let precommit_bin = if cfg!(windows) {
180-
".venv/Scripts/pre-commit.exe"
180+
let python_bin = if cfg!(windows) {
181+
venv_path.join("Scripts").join("python.exe")
181182
} else {
182-
".venv/bin/pre-commit"
183+
venv_path.join("bin").join("python")
183184
};
184185

185-
let output = std::process::Command::new(precommit_bin)
186-
.args(["autoupdate"])
186+
let output = std::process::Command::new(&python_bin)
187+
.args(["-m", "pre_commit", "autoupdate"])
187188
.current_dir(base_dir)
188189
.output()?;
189190

@@ -246,21 +247,21 @@ fn poetry_precommit_install(project_info: &ProjectInfo) -> Result<()> {
246247
}
247248

248249
fn setuptools_precommit_install(project_info: &ProjectInfo) -> Result<()> {
249-
let base_dir = project_info.base_dir();
250+
let base_dir = project_info.base_dir().canonicalize()?;
250251
let venv_path = base_dir.join(".venv");
251252

252253
if !venv_path.exists() {
253254
bail!("Virtual environment not found at {}", venv_path.display());
254255
}
255256

256-
let precommit_bin = if cfg!(windows) {
257-
".venv/Scripts/pre-commit.exe"
257+
let python_bin = if cfg!(windows) {
258+
venv_path.join("Scripts").join("python.exe")
258259
} else {
259-
".venv/bin/pre-commit"
260+
venv_path.join("bin").join("python")
260261
};
261262

262-
let output = std::process::Command::new(precommit_bin)
263-
.args(["install"])
263+
let output = std::process::Command::new(&python_bin)
264+
.args(["-m", "pre_commit", "install"])
264265
.current_dir(base_dir)
265266
.output()?;
266267

0 commit comments

Comments
 (0)