Skip to content

Commit a0825aa

Browse files
committed
chore: Migrate to uv; upgrade to Python >= 3.12
Use `pip lock -e .[dev]` to generate `pylock.toml` . We still need requirements.txt for dependabot features. Add Python dependency CI as uv would ignore dependency conflicts. Bug: #297 Change-Id: I11257ed10d04f2c1a58180ca039d019d4db82699
1 parent fd5c993 commit a0825aa

File tree

10 files changed

+513
-18
lines changed

10 files changed

+513
-18
lines changed

.github/workflows/black.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
python-version: ["3.11"]
14+
python-version: ["3.12"]
1515
steps:
1616
- if: github.event_name != 'pull_request'
1717
uses: actions/checkout@v6
@@ -23,18 +23,22 @@ jobs:
2323
uses: actions/setup-python@v6
2424
with:
2525
python-version: ${{ matrix.python-version }}
26+
- name: Install uv
27+
uses: astral-sh/setup-uv@v5
28+
- name: Setup venv
29+
run: |
30+
uv venv
2631
- name: Install dependencies
2732
run: |
28-
python -m pip install --upgrade pip
29-
pip install -r requirements.txt
30-
pip install -r requirements_dev.txt
33+
uv pip sync pylock.toml
3134
- name: Formatting the code with Black
3235
run: |
33-
black $(git ls-files '*.py')
36+
uv run black $(git ls-files '*.py')
3437
- name: Git config
3538
run: |
3639
git config --local user.name "github-actions[bot]"
3740
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
41+
git config --local advice.addIgnoredFile false
3842
- name: Git diff
3943
run: |
4044
git diff HEAD || true

.github/workflows/dependencies.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Python dependencies
2+
3+
on:
4+
pull_request:
5+
push:
6+
workflow_dispatch:
7+
8+
jobs:
9+
build:
10+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == true
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ["3.12"]
15+
steps:
16+
- if: github.event_name != 'pull_request'
17+
uses: actions/checkout@v6
18+
- if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == true
19+
uses: actions/checkout@v6
20+
with:
21+
ref: ${{ github.event.pull_request.head.ref }}
22+
- name: Set up Python ${{ matrix.python-version }}
23+
uses: actions/setup-python@v6
24+
with:
25+
python-version: ${{ matrix.python-version }}
26+
- name: Install dependencies
27+
run: |
28+
python -m pip install --upgrade pip
29+
pip install -r requirements.txt
30+
pip install -r requirements_dev.txt
31+
pip install -e .[dev]

.github/workflows/pylint.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,21 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
python-version: ["3.11", "3.12"]
14+
python-version: ["3.12"]
1515
steps:
1616
- uses: actions/checkout@v6
1717
- name: Set up Python ${{ matrix.python-version }}
1818
uses: actions/setup-python@v6
1919
with:
2020
python-version: ${{ matrix.python-version }}
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@v5
23+
- name: Setup venv
24+
run: |
25+
uv venv
2126
- name: Install dependencies
2227
run: |
23-
python -m pip install --upgrade pip
24-
pip install -r requirements.txt
25-
pip install -r requirements_dev.txt
28+
uv pip sync pylock.toml
2629
- name: Analysing the code with Pylint
2730
run: |
28-
pylint $(git ls-files '*.py')
31+
uv run pylint $(git ls-files '*.py')

.github/workflows/unittest.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,23 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
python-version: ["3.11", "3.12"]
14+
python-version: ["3.12"]
1515
steps:
1616
- uses: actions/checkout@v6
1717
- name: Set up Python ${{ matrix.python-version }}
1818
uses: actions/setup-python@v6
1919
with:
2020
python-version: ${{ matrix.python-version }}
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@v5
23+
- name: Setup venv
24+
run: |
25+
uv venv
2126
- name: Install dependencies
2227
run: |
23-
python -m pip install --upgrade pip
24-
pip install -r requirements.txt
25-
pip install -r requirements_dev.txt
28+
uv pip sync pylock.toml
29+
uv pip install -e .[dev]
2630
- name: Analysing the code with Python unittest
2731
run: |
28-
python -m unittest $(git ls-files 'cog/tests/*.py')
32+
uv run python -m unittest $(git ls-files 'cog/tests/*.py')
33+
uv run python -m unittest $(git ls-files 'tests/unittest/*.py')

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
**/__pycache__
1414
*.egg-info/
1515
build/lib/
16+
## uv
17+
uv.lock
1618
## Linux
1719
flakLog.out
1820
nohup.out

0 commit comments

Comments
 (0)