Skip to content

Commit 2ad1192

Browse files
authored
Switch default project manager to uv (#511)
* Switch default project manager to uv * Update CI tests for new order * Skip if no tests to run * Move if * Fix if * Fix if * Skip pixi lib test * Fix pyo3 number choice * Add mac to tests
1 parent 73cf782 commit 2ad1192

File tree

2 files changed

+136
-31
lines changed

2 files changed

+136
-31
lines changed

.github/workflows/testing.yml

Lines changed: 122 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,78 @@ jobs:
4949
uses: Swatinem/[email protected]
5050
- name: Run cargo test
5151
run: cargo test --locked
52+
uv-linting:
53+
strategy:
54+
fail-fast: false
55+
matrix:
56+
project_type: ["application", "lib"]
57+
runs-on: ubuntu-latest
58+
steps:
59+
- uses: actions/checkout@v4
60+
- name: Install Rust
61+
run: |
62+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
63+
- name: Cache Rust dependencies
64+
uses: Swatinem/[email protected]
65+
- name: Install uv
66+
run: curl -LsSf https://astral.sh/uv/install.sh | sh
67+
- name: Set up Python
68+
uses: actions/setup-python@v5
69+
with:
70+
python-version: "${{ env.MIN_PYTHON_VERSION }}"
71+
- name: Build package
72+
run: cargo build --release
73+
- name: Run creation
74+
run: |
75+
./scripts/ci_run.sh ${{ matrix.project_type }} 1
76+
- name: Install Dependencies
77+
working-directory: ${{ env.WORKING_DIR }}
78+
run: |
79+
uv lock
80+
uv sync --frozen
81+
- name: MyPy
82+
working-directory: ${{ env.WORKING_DIR }}
83+
run: uv run mypy .
84+
- name: ruff
85+
working-directory: ${{ env.WORKING_DIR }}
86+
run: uv run ruff check .
87+
uv-test:
88+
strategy:
89+
fail-fast: false
90+
matrix:
91+
project_type: ["application", "lib"]
92+
os: [ubuntu-latest, macos-latest]
93+
runs-on: ${{ matrix.os }}
94+
steps:
95+
- uses: actions/checkout@v4
96+
- name: Install Rust
97+
run: |
98+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
99+
- name: Cache Rust dependencies
100+
uses: Swatinem/[email protected]
101+
- name: Install uv
102+
run: curl -LsSf https://astral.sh/uv/install.sh | sh
103+
- name: Set up Python
104+
uses: actions/setup-python@v5
105+
with:
106+
python-version: "3.11"
107+
- name: Build package
108+
run: cargo build --release
109+
- name: Run creation
110+
run: |
111+
./scripts/ci_run.sh ${{ matrix.project_type }} 1
112+
- name: Install Dependencies
113+
working-directory: ${{ env.WORKING_DIR }}
114+
run: |
115+
uv lock
116+
uv sync --frozen
117+
- name: Pre-commit install
118+
working-directory: ${{ env.WORKING_DIR }}
119+
run: uv run pre-commit install
120+
- name: Test with pytest
121+
working-directory: ${{ env.WORKING_DIR }}
122+
if: matrix.project_type == 'application'
123+
run: uv run pytest
52124
poetry-linting:
53125
strategy:
54126
fail-fast: false
@@ -76,7 +148,7 @@ jobs:
76148
run: cargo build --release
77149
- name: Run creation
78150
run: |
79-
./scripts/ci_run.sh ${{ matrix.project_type }} 1
151+
./scripts/ci_run.sh ${{ matrix.project_type }} 2
80152
- name: Install Dependencies
81153
working-directory: ${{ env.WORKING_DIR }}
82154
run: poetry install
@@ -101,7 +173,7 @@ jobs:
101173
- name: Cache Rust dependencies
102174
uses: Swatinem/[email protected]
103175
- name: Install Poetry
104-
run: pipx install poetry pre-commit
176+
run: pipx install poetry
105177
- name: Configure poetry
106178
run: |
107179
poetry config virtualenvs.create true
@@ -114,7 +186,7 @@ jobs:
114186
run: cargo build --release
115187
- name: Run creation
116188
run: |
117-
./scripts/ci_run.sh ${{ matrix.project_type }} 1
189+
./scripts/ci_run.sh ${{ matrix.project_type }} 2
118190
- name: Install Dependencies
119191
working-directory: ${{ env.WORKING_DIR }}
120192
run: poetry install
@@ -146,7 +218,7 @@ jobs:
146218
- name: Build package
147219
run: cargo build --release
148220
- name: Run creation
149-
run: ./scripts/ci_run.sh ${{ matrix.project_type }} 2
221+
run: ./scripts/ci_run.sh ${{ matrix.project_type }} 3
150222
- name: Install Dependencies
151223
working-directory: ${{ env.WORKING_DIR }}
152224
run: |
@@ -188,12 +260,11 @@ jobs:
188260
- name: Build package
189261
run: cargo build --release
190262
- name: Run creation
191-
run: ./scripts/ci_run.sh ${{ matrix.project_type }} 2
263+
run: ./scripts/ci_run.sh ${{ matrix.project_type }} 3
192264
- name: Install Dependencies
193265
working-directory: ${{ env.WORKING_DIR }}
194266
run: |
195267
python -m pip install -U pip
196-
pipx install pre-commit
197268
python -m pip install -r requirements-dev.txt
198269
python -m pip install -e .
199270
maturin build --out dist
@@ -225,34 +296,32 @@ jobs:
225296
run: cargo build --release
226297
- name: Run creation
227298
run: |
228-
./scripts/ci_run.sh ${{ matrix.project_type }} 3
299+
./scripts/ci_run.sh ${{ matrix.project_type }} 4
229300
- name: Install Dependencies
230301
working-directory: ${{ env.WORKING_DIR }}
231302
run: |
232303
python -m pip install -U pip
233-
pipx install pre-commit
234304
python -m pip install -r requirements-dev.txt
235305
- name: MyPy
236306
working-directory: ${{ env.WORKING_DIR }}
237307
run: mypy .
238308
- name: ruff
239309
working-directory: ${{ env.WORKING_DIR }}
240310
run: ruff check .
241-
uv-linting:
311+
setuptools-test:
242312
strategy:
243313
fail-fast: false
244314
matrix:
245315
project_type: ["application", "lib"]
246-
runs-on: ubuntu-latest
316+
os: [ubuntu-latest, macos-latest]
317+
runs-on: ${{ matrix.os }}
247318
steps:
248319
- uses: actions/checkout@v4
249320
- name: Install Rust
250321
run: |
251322
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
252323
- name: Cache Rust dependencies
253324
uses: Swatinem/[email protected]
254-
- name: Install uv
255-
run: curl -LsSf https://astral.sh/uv/install.sh | sh
256325
- name: Set up Python
257326
uses: actions/setup-python@v5
258327
with:
@@ -265,14 +334,15 @@ jobs:
265334
- name: Install Dependencies
266335
working-directory: ${{ env.WORKING_DIR }}
267336
run: |
268-
uv lock
269-
uv sync --locked
270-
- name: MyPy
337+
python -m pip install -U pip
338+
python -m pip install -r requirements-dev.txt
339+
- name: Pre-commit install
271340
working-directory: ${{ env.WORKING_DIR }}
272-
run: uv run mypy .
273-
- name: ruff
341+
run: pre-commit install
342+
- name: Test with pytest
274343
working-directory: ${{ env.WORKING_DIR }}
275-
run: uv run ruff check .
344+
if: matrix.project_type == 'application'
345+
run: pytest
276346
pixi-linting:
277347
strategy:
278348
fail-fast: false
@@ -305,3 +375,37 @@ jobs:
305375
- name: ruff
306376
working-directory: ${{ env.WORKING_DIR }}
307377
run: pixi run -e dev ruff check .
378+
pixi-test:
379+
strategy:
380+
fail-fast: false
381+
matrix:
382+
project_type: ["application", "lib"]
383+
os: [ubuntu-latest, macos-latest]
384+
runs-on: ${{ matrix.os }}
385+
steps:
386+
- uses: actions/checkout@v4
387+
- name: Install Rust
388+
run: |
389+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
390+
- name: Cache Rust dependencies
391+
uses: Swatinem/[email protected]
392+
- name: Build package
393+
run: cargo build --release
394+
- name: Run creation
395+
run: |
396+
./scripts/ci_run.sh ${{ matrix.project_type }} 5
397+
- name: Install Pixi
398+
uses: prefix-dev/[email protected]
399+
with:
400+
manifest-path: ${{ env.WORKING_DIR }}/pyproject.toml
401+
pixi-version: v0.30.0
402+
- name: Set up Python
403+
working-directory: ${{ env.WORKING_DIR }}
404+
run: pixi add python=="${{ env.MIN_PYTHON_VERSION }}.*"
405+
- name: Pre-commit install
406+
working-directory: ${{ env.WORKING_DIR }}
407+
run: pixi run -e dev pre-commit install
408+
- name: Test with pytest
409+
working-directory: ${{ env.WORKING_DIR }}
410+
if: matrix.project_type == 'application'
411+
run: pixi run -e dev pytest

src/project_info.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,12 @@ impl fmt::Display for LicenseType {
7070
}
7171
}
7272

73-
#[derive(Clone, Debug, Deserialize, Serialize, ValueEnum, PartialEq, Eq)]
73+
#[derive(Clone, Debug, Default, Deserialize, Serialize, ValueEnum, PartialEq, Eq)]
7474
pub enum ProjectManager {
7575
Maturin,
7676
Poetry,
7777
Setuptools,
78+
#[default]
7879
Uv,
7980
Pixi,
8081
}
@@ -324,31 +325,31 @@ fn dependabot_schedule_prompt(
324325
fn project_manager_prompt(default: Option<ProjectManager>) -> Result<ProjectManager> {
325326
let default_str = match default {
326327
Some(d) => match d {
327-
ProjectManager::Maturin => "2".to_string(),
328-
ProjectManager::Poetry => "1".to_string(),
329-
ProjectManager::Setuptools => "3".to_string(),
330-
ProjectManager::Uv => "4".to_string(),
328+
ProjectManager::Uv => "1".to_string(),
329+
ProjectManager::Poetry => "2".to_string(),
330+
ProjectManager::Maturin => "3".to_string(),
331+
ProjectManager::Setuptools => "4".to_string(),
331332
ProjectManager::Pixi => "5".to_string(),
332333
},
333334
None => "poetry".to_string(),
334335
};
335336
let prompt_text =
336-
"Project Manager\n 1 - Poetry\n 2 - Maturin\n 3 - setuptools\n 4 - uv\n 5 - Pixi\n Choose from[1, 2, 3, 4, 5]"
337+
"Project Manager\n 1 - uv\n 2 - Poetry\n 3 - Maturin\n 4 - setuptools\n 5 - Pixi\n Choose from[1, 2, 3, 4, 5]"
337338
.to_string();
338339
let prompt = Prompt {
339340
prompt_text,
340341
default: Some(default_str),
341342
};
342343
let input = prompt.show_prompt()?;
343344

344-
if input == "1" || input.is_empty() {
345+
if input == "1" {
346+
Ok(ProjectManager::Uv)
347+
} else if input == "2" || input.is_empty() {
345348
Ok(ProjectManager::Poetry)
346-
} else if input == "2" {
347-
Ok(ProjectManager::Maturin)
348349
} else if input == "3" {
349-
Ok(ProjectManager::Setuptools)
350+
Ok(ProjectManager::Maturin)
350351
} else if input == "4" {
351-
Ok(ProjectManager::Uv)
352+
Ok(ProjectManager::Setuptools)
352353
} else if input == "5" {
353354
Ok(ProjectManager::Pixi)
354355
} else {
@@ -513,9 +514,9 @@ pub fn get_project_info(use_defaults: bool) -> Result<ProjectInfo> {
513514
};
514515

515516
let project_manager = if use_defaults {
516-
config.project_manager.unwrap_or(ProjectManager::Poetry)
517+
config.project_manager.unwrap_or_default()
517518
} else {
518-
let default = config.project_manager.unwrap_or(ProjectManager::Poetry);
519+
let default = config.project_manager.unwrap_or_default();
519520
project_manager_prompt(Some(default))?
520521
};
521522

0 commit comments

Comments
 (0)