Skip to content

Commit 9076a16

Browse files
committed
swtich from pipenv to uv to handle python dependencies for tests
1 parent eaf85ae commit 9076a16

File tree

11 files changed

+2287
-2280
lines changed

11 files changed

+2287
-2280
lines changed

.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
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 which jupyter))/ -type f -name "jupyter.exe" -o -name "jupyter")
160+
uv run 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
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 which jupyter))/ -type f -name "jupyter.exe" -o -name "jupyter")
184+
uv run 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

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.

tests/Pipfile.lock

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

tests/configure-test-env.ps1

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,13 @@ try { $null = gcm python -ea stop; $python=$true } catch {
2323
}
2424

2525
If ( $py -and $python) {
26-
Write-Host "Setting up python environnement with pipenv"
27-
try { $null = gcm pipenv -ea stop; $pipenv=$true } catch {
28-
Write-Host -ForegroundColor red "No pipenv found in PATH - Installing pipenv running ``pip install pipenv``"
26+
Write-Host "Setting up python environnement with uv"
27+
try { $null = gcm uv -ea stop; $uv=$true } catch {
28+
Write-Host -ForegroundColor red "No uv found in PATH - Install uv please: https://docs.astral.sh/uv/getting-started/installation/"
2929
}
30-
If ($null -eq $pipenv) {
31-
python -m pip install pipenv
32-
try { $null = gcm pyenv -ea stop; $pyenv=$true } catch { }
33-
If ($pyenv) {
34-
pyenv rehash
35-
}
36-
}
37-
# our default is pipenv to use its own virtualenv and be in project directory
38-
$Env:PIPENV_IGNORE_VIRTUALENVS=1
39-
$Env:PIPENV_VENV_IN_PROJECT=1
40-
pipenv install
41-
$pipenv=$true
30+
# install from lockfile
31+
uv sync
32+
$uv=$true
4233
}
4334

4435
# Check Julia environment ---

tests/configure-test-env.sh

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,14 @@ then
2828
fi
2929
if [ -n $python_exists ]
3030
then
31-
pipenv_exist=$(command -v pipenv)
32-
if [ -z $pipenv_exist ]
31+
uv_exist=$(command -v uv)
32+
if [ -z $uv_exist ]
33+
echo "Setting up python environnement with uv"
34+
# create or sync the virtual env in the project
35+
uv sync
3336
then
34-
echo "No pipenv found - Installing pipenv running ``pip install pipenv``..."
35-
$python_exists -m pip install pipenv
36-
echo "...pipenv installed"
37+
echo "No uv found - Install uv please: https://docs.astral.sh/uv/getting-started/installation/"
3738
fi
38-
# specific for pyenv shim
39-
[[ -n $(command -v pyenv) ]] && pyenv rehash
40-
echo "Setting up python environnement with pipenv"
41-
# our default is pipenv to use its own virtualenv and be in project directory
42-
export PIPENV_IGNORE_VIRTUALENVS=1
43-
export PIPENV_VENV_IN_PROJECT=1
44-
pipenv install
4539
fi
4640

4741
# Check Julia environment ---

tests/pyproject.toml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[project]
2+
name = "tests"
3+
version = "0.1.0"
4+
description = "Quarto Tests"
5+
requires-python = ">=3.12"
6+
dependencies = [
7+
"bokeh>=3.6.0",
8+
"ipyleaflet>=0.19.2",
9+
"itables>=2.2.3",
10+
"jupyter-cache>=1.0.0",
11+
"jupyter>=1.1.1",
12+
"matplotlib>=3.9.2",
13+
"pandas>=2.2.3",
14+
"seaborn>=0.13.2",
15+
"shiny>=1.2.0",
16+
]

tests/run-tests.ps1

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,16 @@ $DENO_ARGS += -split $QUARTO_IMPORT_MAP_ARG
138138
$DENO_ARGS += $TESTS_TO_RUN
139139

140140
# Activate python virtualenv
141-
# set QUARTO_TESTS_FORCE_NO_PIPENV env var to not activate the virtualenv managed by pipenv for the project
142-
If ($null -eq $Env:QUARTO_TESTS_FORCE_NO_PIPENV) {
141+
# set QUARTO_TESTS_FORCE_NO_VENV env var to not activate the virtualenv located in the project
142+
# QUARTO_TESTS_FORCE_NO_PIPENV is there for backward compatibility
143+
If ($null -eq $Env:QUARTO_TESTS_FORCE_NO_VENV -and $null -ne $Env:QUARTO_TESTS_FORCE_NO_PIPENV) {
144+
$Env:QUARTO_TESTS_FORCE_NO_VENV = $Env:QUARTO_TESTS_FORCE_NO_PIPENV
145+
}
146+
If ($null -eq $Env:QUARTO_TESTS_FORCE_NO_VENV) {
143147
# Save possible activated virtualenv for later restauration
144148
$OLD_VIRTUAL_ENV=$VIRTUAL_ENV
145-
Write-Host "> Activating virtualenv for Python tests in Quarto"
146-
. "$(pipenv --venv)/Scripts/activate.ps1"
149+
Write-Host "> Activating virtualenv from .venv for Python tests in Quarto"
150+
. $(Join-Path $QUARTO_ROOT "tests" ".venv/Scripts/activate.ps1")
147151
Write-Host "> Using Python from " -NoNewline; Write-Host "$((gcm python).Source)" -ForegroundColor Blue;
148152
Write-Host "> VIRTUAL_ENV: " -NoNewline; Write-Host "$($env:VIRTUAL_ENV)" -ForegroundColor Blue;
149153
$quarto_venv_activated = $true

tests/run-tests.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,17 @@ then
3333
fi
3434

3535
# Activating python virtualenv
36-
# set QUARTO_TESTS_FORCE_NO_PIPENV env var to not activate the virtualenv managed by pipenv for the project
37-
if [[ -z $QUARTO_TESTS_FORCE_NO_PIPENV ]]
36+
# set QUARTO_TESTS_FORCE_NO_VENV env var to not activate the virtualenv located in the project
37+
# QUARTO_TESTS_FORCE_NO_PIPENV is there for backward compatibility
38+
if [[ -z $QUARTO_TESTS_FORCE_NO_VENV && -n $QUARTO_TESTS_FORCE_NO_PIPENV ]]; then
39+
export QUARTO_TESTS_FORCE_NO_VENV=$QUARTO_TESTS_FORCE_NO_PIPENV
40+
fi
41+
if [[ -z $QUARTO_TESTS_FORCE_NO_VENV ]]
3842
then
3943
# Save possible activated virtualenv for later restauration
4044
OLD_VIRTUAL_ENV=$VIRTUAL_ENV
41-
echo "> Activating virtualenv for Python tests in Quarto"
42-
source "$(pipenv --venv)/bin/activate"
45+
echo "> Activating virtualenv from .venv for Python tests in Quarto"
46+
source "$QUARTO_ROOT/tests/bin/activate"
4347
echo "> Using Python from $(which python)"
4448
echo "> VIRTUAL_ENV: ${VIRTUAL_ENV}"
4549
quarto_venv_activated="true"

0 commit comments

Comments
 (0)