Skip to content

Commit f8a4e35

Browse files
authored
Merge pull request #11317 from quarto-dev/tests/python-env/use-uv
2 parents 952196e + 4a58848 commit f8a4e35

File tree

14 files changed

+2619
-2295
lines changed

14 files changed

+2619
-2295
lines changed

.github/workflows/actions/quarto-dev/action.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ runs:
4949
# Convert the list to an array
5050
$modifiedFilesArray = $modifiedFiles -split "`n" | ForEach-Object { $_.Trim() }
5151
52-
If ($modifiedFilesArray -contains "tests/Pipfile.lock") {
53-
Write-Output "::warning::test/Pipfile.lock has been modified."
54-
$modifiedFilesArray = $modifiedFilesArray | Where-Object { $_ -notmatch "Pipfile.lock" }
52+
If ($modifiedFilesArray -contains "tests/uv.lock") {
53+
Write-Output "::warning::test/uv.lock has been modified."
54+
$modifiedFilesArray = $modifiedFilesArray | Where-Object { $_ -notmatch "uv.lock" }
5555
}
5656
5757
# Count the number of modified files

.github/workflows/test-ff-matrix.yml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -114,18 +114,17 @@ jobs:
114114
env:
115115
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
116116

117-
- name: Set up Python
118-
uses: actions/setup-python@v4
117+
- name: Install uv for Python
118+
uses: astral-sh/setup-uv@v3
119119
with:
120-
python-version: "3.12"
121-
cache: "pipenv"
122-
cache-dependency-path: "./tests/Pipfile.lock"
120+
version: "0.4.30"
121+
enable-cache: true
122+
cache-dependency-glob: "tests/uv.lock"
123123

124-
- name: Restore Python Dependencies
124+
- name: Install Python and Dependencies
125125
working-directory: tests
126126
run: |
127-
python -m pip install pipenv
128-
pipenv install
127+
uv sync --frozen
129128
130129
- uses: ./.github/workflows/actions/quarto-dev
131130

@@ -157,8 +156,8 @@ jobs:
157156
run: |
158157
# Setup IJulia with the jupyter from the Python environment
159158
# https://julialang.github.io/IJulia.jl/stable/manual/installation/
160-
export JUPYTER=$(find $(dirname $(pipenv run which jupyter))/ -type f -name "jupyter.exe" -o -name "jupyter")
161-
pipenv run julia --color=yes --project=. -e "import Pkg; Pkg.instantiate(); Pkg.build(\"IJulia\"); Pkg.precompile()"
159+
export JUPYTER=$(find $(dirname $(uv run --frozen which jupyter))/ -type f -name "jupyter.exe" -o -name "jupyter")
160+
uv run --frozen julia --color=yes --project=. -e "import Pkg; Pkg.instantiate(); Pkg.build(\"IJulia\"); Pkg.precompile()"
162161
echo "Julia Jupyter:"
163162
julia --project=. -e "import IJulia;println(IJulia.JUPYTER);println(IJulia.find_jupyter_subcommand(\"notebook\"))"
164163

.github/workflows/test-smokes.yml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -140,18 +140,17 @@ jobs:
140140
env:
141141
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
142142

143-
- name: Set up Python
144-
uses: actions/setup-python@v5
143+
- name: Install uv for Python
144+
uses: astral-sh/setup-uv@v3
145145
with:
146-
python-version: "3.12"
147-
cache: "pipenv"
148-
cache-dependency-path: "./tests/Pipfile.lock"
146+
version: "0.4.30"
147+
enable-cache: true
148+
cache-dependency-glob: "tests/uv.lock"
149149

150-
- name: Restore Python Dependencies
150+
- name: Install Python and Dependencies
151151
working-directory: tests
152152
run: |
153-
python -m pip install pipenv==2024.3.0
154-
pipenv install
153+
uv sync --frozen
155154
156155
- uses: ./.github/workflows/actions/quarto-dev
157156

@@ -181,8 +180,8 @@ jobs:
181180
run: |
182181
# Setup IJulia with the jupyter from the Python environment
183182
# https://julialang.github.io/IJulia.jl/stable/manual/installation/
184-
export JUPYTER=$(find $(dirname $(pipenv run which jupyter))/ -type f -name "jupyter.exe" -o -name "jupyter")
185-
pipenv run julia --color=yes --project=. -e "import Pkg; Pkg.instantiate(); Pkg.build(\"IJulia\"); Pkg.precompile()"
183+
export JUPYTER=$(find $(dirname $(uv run --frozen which jupyter))/ -type f -name "jupyter.exe" -o -name "jupyter")
184+
uv run --frozen julia --color=yes --project=. -e "import Pkg; Pkg.instantiate(); Pkg.build(\"IJulia\"); Pkg.precompile()"
186185
echo "Julia Jupyter:"
187186
julia --project=. -e "import IJulia;println(IJulia.JUPYTER);println(IJulia.find_jupyter_subcommand(\"notebook\"))"
188187

dev-docs/configuring-test-deps.md

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,20 @@
1616

1717
## Python
1818

19-
- Install `pyenv`
20-
- Install a specic version e.g `pyenv install 3.12.1`
21-
- Configure `tests` to use a specific version
19+
- Install `uv`
20+
21+
About uv: https://docs.astral.sh/uv/
22+
23+
`uv` will handle the python versions and virtual environments based on the `.python-version` we have in `tests/` folder.
24+
25+
To set the version to use to
2226

2327
```
2428
cd tests
25-
pyenv local 3.12.1
29+
echo '3.12.7' > .python-version
2630
```
2731

28-
This way when calling `python` in `tests` folder it will always be Python 3.12.1 version
32+
This `uv run` and `uv sync` will create the right virtual environment and use it.
2933

3034
## R
3135

@@ -43,4 +47,35 @@
4347

4448
# Installing the dependencies in each languages packages
4549

46-
- From `tests` folder, run `configure-test-env` scripts to restore dependencies for each tools
50+
- From `tests` folder, run `configure-test-env.sh` or `configure-test-env.ps1` scripts to restore dependencies for each tools
51+
52+
# Adding some tests dependencies
53+
54+
## Python
55+
56+
- Use `uv add` to add the deps to `pyproject.toml`, install related dependencies in the virtual environment and lock the versions in `uv.lock`.
57+
Example:
58+
```
59+
cd tests
60+
uv add jupyter
61+
```
62+
63+
## R
64+
65+
- Add the dependencies in `DESCRIPTION` file
66+
- Run `renv::install(<package>)` to install the dependencies
67+
- Run `renv::snapshot()` to lock the versions in `renv.lock`
68+
69+
## Julia
70+
71+
- Run Julia in the `tests/` project and add the dependencies
72+
Example:
73+
```bash
74+
cd tests
75+
julia --project=.
76+
```
77+
then in Julia console
78+
```julia
79+
using Pkg
80+
Pkg.add("DataFrames")
81+
```

tests/.python-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.12.1
1+
3.12.7

tests/Pipfile

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)