Skip to content

Commit 1eac67f

Browse files
committed
Fix setuptools pre-commit and pixi install
1 parent fa3c1e0 commit 1eac67f

File tree

3 files changed

+23
-32
lines changed

3 files changed

+23
-32
lines changed

.github/workflows/testing.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -383,16 +383,16 @@ jobs:
383383
uses: dtolnay/rust-toolchain@stable
384384
- name: Cache Rust dependencies
385385
uses: Swatinem/[email protected]
386-
- name: Build package
387-
run: cargo build --release
388-
- name: Run creation
389-
run: ./scripts/ci_run.sh ${{ matrix.project_type }} 5
390-
shell: bash
391386
- name: Install Pixi
392387
uses: prefix-dev/[email protected]
393388
with:
394389
manifest-path: ${{ env.WORKING_DIR }}/pyproject.toml
395390
pixi-version: v0.57.0
391+
- name: Build package
392+
run: cargo build --release
393+
- name: Run creation
394+
run: ./scripts/ci_run.sh ${{ matrix.project_type }} 5
395+
shell: bash
396396
- name: Set up Python
397397
working-directory: ${{ env.WORKING_DIR }}
398398
run: pixi add python=="${{ env.MIN_PYTHON_VERSION }}.*"
@@ -418,16 +418,16 @@ jobs:
418418
uses: dtolnay/rust-toolchain@stable
419419
- name: Cache Rust dependencies
420420
uses: Swatinem/[email protected]
421-
- name: Build package
422-
run: cargo build --release
423-
- name: Run creation
424-
run: ./scripts/ci_run.sh ${{ matrix.project_type }} 5
425-
shell: bash
426421
- name: Install Pixi
427422
uses: prefix-dev/[email protected]
428423
with:
429424
manifest-path: ${{ env.WORKING_DIR }}/pyproject.toml
430425
pixi-version: v0.57.0
426+
- name: Build package
427+
run: cargo build --release
428+
- name: Run creation
429+
run: ./scripts/ci_run.sh ${{ matrix.project_type }} 5
430+
shell: bash
431431
- name: Set up Python
432432
working-directory: ${{ env.WORKING_DIR }}
433433
run: pixi add python=="${{ env.MIN_PYTHON_VERSION }}.*"

src/dev_dependency_installer.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -193,13 +193,7 @@ fn setuptools_precommit_autoupdate(project_info: &ProjectInfo) -> Result<()> {
193193
bail!("Virtual environment not found at {}", venv_path.display());
194194
}
195195

196-
let precommit_bin = if cfg!(windows) {
197-
venv_path.join("Scripts").join("pre-commit.exe")
198-
} else {
199-
venv_path.join("bin").join("pre-commit")
200-
};
201-
202-
let output = std::process::Command::new(&precommit_bin)
196+
let output = std::process::Command::new(".venv/bin/pre-commit")
203197
.args(["autoupdate"])
204198
.current_dir(base_dir)
205199
.output()?;
@@ -285,13 +279,7 @@ fn setuptools_precommit_install(project_info: &ProjectInfo) -> Result<()> {
285279
bail!("Virtual environment not found at {}", venv_path.display());
286280
}
287281

288-
let precommit_bin = if cfg!(windows) {
289-
venv_path.join("Scripts").join("pre-commit.exe")
290-
} else {
291-
venv_path.join("bin").join("pre-commit")
292-
};
293-
294-
let output = std::process::Command::new(&precommit_bin)
282+
let output = std::process::Command::new(".venv/bin/pre-commit")
295283
.args(["install"])
296284
.current_dir(base_dir)
297285
.output()?;

src/fastapi/fastapi_installer.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,17 @@ fn poetry_fastapi_dependency_installer(project_info: &ProjectInfo) -> Result<()>
102102
}
103103

104104
fn setuptools_fastapi_dependency_installer(project_info: &ProjectInfo) -> Result<()> {
105-
let venv_output = std::process::Command::new("python")
106-
.args(["-m", "venv", ".venv"])
107-
.current_dir(project_info.base_dir())
108-
.output()?;
109-
110-
if !venv_output.status.success() {
111-
let stderr = String::from_utf8_lossy(&venv_output.stderr);
112-
bail!("Failed to create virtual environment: {stderr}");
105+
let venv_path = project_info.base_dir().join(".venv");
106+
if !venv_path.exists() {
107+
let venv_output = std::process::Command::new("python")
108+
.args(["-m", "venv", ".venv"])
109+
.current_dir(project_info.base_dir())
110+
.output()?;
111+
112+
if !venv_output.status.success() {
113+
let stderr = String::from_utf8_lossy(&venv_output.stderr);
114+
bail!("Failed to create virtual environment: {stderr}");
115+
}
113116
}
114117

115118
let dependencies = FASTAPI_BASE_DEPENDENCIES.to_vec();

0 commit comments

Comments
 (0)