Skip to content

Commit f81ccf9

Browse files
committed
use uv as pip replacement
1 parent a8ae070 commit f81ccf9

File tree

7 files changed

+77
-39
lines changed

7 files changed

+77
-39
lines changed

.github/workflows/dockers.yml

+8-4
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,16 @@ jobs:
8484
- name: Install python dependencies
8585
run: |
8686
python -m pip install --upgrade pip
87-
pip install wheel
88-
pip install -r Browser/dev-requirements.txt
87+
pip install -U uv
88+
uv venv
89+
uv pip install wheel --python python3.9
90+
uv pip install -r Browser/dev-requirements.txt --python python3.9
8991
- name: Install invoke deps
90-
run: invoke deps
92+
run: |
93+
invoke deps
9194
- name: build testing docker image
92-
run: invoke docker-tester
95+
run: |
96+
invoke docker-tester
9397
- name: set permissions
9498
run: chmod -R 777 atest/
9599
- name: Run tests with latest stable docker image

.github/workflows/on-push.yml

+28-13
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,22 @@ jobs:
3838
with:
3939
python-version: 3.9
4040
cache: 'pip'
41-
- name: Install python dependencies
41+
- name: Install python dependencies in Linux
42+
if: matrix.os == 'ubuntu-latest'
43+
run: |
44+
python -m pip install --upgrade pip
45+
pip install uv
46+
uv venv
47+
uv pip install wheel --python python3.9
48+
uv pip install -r Browser/dev-requirements.txt --python python3.9
49+
- name: Install python dependencies in Windows
50+
if: matrix.os != 'ubuntu-latest'
4251
run: |
4352
python -m pip install --upgrade pip
44-
pip install wheel
45-
pip install -r Browser/dev-requirements.txt
53+
pip install uv
54+
uv venv
55+
uv pip install wheel --python python3.9
56+
uv pip install -r Browser/dev-requirements.txt --python 3.9
4657
- name: Build Protos and check with tsc
4758
if: matrix.os == 'ubuntu-latest'
4859
run: |
@@ -144,8 +155,10 @@ jobs:
144155
- name: Install python dependencies
145156
run: |
146157
python -m pip install --upgrade pip
147-
pip install wheel
148-
pip install -r Browser/dev-requirements.txt
158+
pip install uv
159+
uv venv
160+
uv pip install wheel --python ${{ matrix.python-version }}
161+
uv pip install -r Browser/dev-requirements.txt --python ${{ matrix.python-version }}
149162
- name: Build Protos and check with tsc
150163
run: |
151164
inv node-build
@@ -173,7 +186,7 @@ jobs:
173186
- name: Run pytests
174187
if: matrix.shard == 1
175188
run: |
176-
invoke utest
189+
invoke utest
177190
- name: Run Robot Framework tests on linux
178191
if: matrix.os == 'ubuntu-latest'
179192
run: |
@@ -200,7 +213,7 @@ jobs:
200213
# flaky-tests-detection install is here because dependencies takes long
201214
# time to install and not needed for the test-install
202215
run : |
203-
pip install flaky-tests-detection requests python-dateutil
216+
uv pip install flaky-tests-detection requests python-dateutil --python ${{ matrix.python-version }}
204217
python download_file.py --project MarketSquare --repo robotframework-browser --token ${{ secrets.GITHUB_TOKEN }}
205218
inv copy-xunit
206219
- name: Flaky tests detection
@@ -256,17 +269,19 @@ jobs:
256269
cache: 'pip'
257270
- name: Install Robot Framework Browser on unix-like
258271
run: |
259-
pip install ./robotframework_browser-*-py3-none-any.whl
272+
pip install -U uv
273+
uv pip install ./robotframework_browser-*-py3-none-any.whl --python ${{ matrix.python-version }}
260274
if: matrix.os != 'windows-latest'
261275
- name: Install Robot Framework Browser on windows
262276
run: |
263-
pip install (gci *.whl)
277+
pip install -U uv
278+
uv pip install (gci *.whl)--python ${{ matrix.python-version }}
264279
if: matrix.os == 'windows-latest'
265280
- name: Install node deps and python deps for test running
266281
run: |
267282
rfbrowser init
268-
pip install wheel
269-
pip install -r Browser/dev-requirements.txt
283+
uv pip install wheel --python ${{ matrix.python-version }}
284+
uv pip install -r Browser/dev-requirements.txt --python ${{ matrix.python-version }}
270285
- name: Test on unix-like os - serial mode
271286
if: matrix.os == 'ubuntu-latest'
272287
env:
@@ -290,7 +305,7 @@ jobs:
290305
# flaky-tests-detection install is here because dependencies takes long
291306
# time to install and not needed for the test-install
292307
run: |
293-
pip install flaky-tests-detection
308+
uv pip install flaky-tests-detection --python ${{ matrix.python-version }}
294309
python download_file.py --project MarketSquare --repo robotframework-browser --token ${{ secrets.GITHUB_TOKEN }}
295310
inv copy-xunit
296311
- name: Flaky tests detection
@@ -301,7 +316,7 @@ jobs:
301316
if: ${{ matrix.os != 'windows-latest' }}
302317
run: |
303318
rfbrowser clean-node
304-
pip uninstall --yes robotframework-browser
319+
uv pip uninstall robotframework-browser --python ${{ matrix.python-version }}
305320
- uses: actions/upload-artifact@v4
306321
if: ${{ always() }}
307322
with:

.github/workflows/on-release.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ jobs:
2323
run: |
2424
npm ci
2525
python -m pip install --upgrade pip
26-
pip install -r Browser/dev-requirements.txt
26+
pip install -U uv
27+
uv venv
28+
uv pip install -r Browser/dev-requirements.txt --python python3.8
2729
inv build
2830
- name: Build docs
2931
run: |

Browser/entry.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,13 @@ def _node_info():
202202
_write_marker()
203203

204204

205-
def _log_install_dir():
206-
logging.info(
207-
f"Installation directory `{INSTALLATION_DIR!s}` does not contain the required files for. "
208-
"unknown reason. Investigate the npm output and fix possible problems."
209-
"\nPrinting contents:\n"
210-
)
205+
def _log_install_dir(error_msg=True):
206+
if error_msg:
207+
logging.info(
208+
f"Installation directory `{INSTALLATION_DIR!s}` does not contain the required files for. "
209+
"unknown reason. Investigate the npm output and fix possible problems."
210+
"\nPrinting contents:\n"
211+
)
211212
for line in _walk_install_dir():
212213
logging.info(line)
213214
_write_marker()
@@ -364,7 +365,7 @@ def clean_node():
364365
_write_marker()
365366
_python_info()
366367
_node_info()
367-
_log_install_dir()
368+
_log_install_dir(False)
368369
_write_marker()
369370

370371
if not NODE_MODULES.is_dir():

Browser/pyproject.toml

+7-7
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ lint.select = [
6363
"SIM",
6464
"RUF"
6565
]
66+
[tool.ruff.lint.per-file-ignores]
67+
"tasks.py" = [
68+
"T201",
69+
"PTH123",
70+
"PTH120"
71+
]
72+
"bootstrap.py" = ["T201"]
6673

6774
[tool.robotidy]
6875
src = ["atest"]
@@ -74,10 +81,3 @@ configure = [
7481
"RenameKeywords:enabled=True",
7582
"RenameTestCases:capitalize_each_word=True:enabled=True"
7683
]
77-
78-
[tool.ruff.lint.per-file-ignores]
79-
"tasks.py" = [
80-
"T201",
81-
"PTH123",
82-
"PTH120"
83-
]

bootstrap.py

+14-3
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,35 @@
22
33
Also installs the needed dependencies.
44
"""
5+
56
import platform
67
import subprocess
78
from pathlib import Path
89
from venv import EnvBuilder
910

10-
venv_dir = Path(".") / ".venv"
11+
venv_dir = Path(__file__).parent / ".venv"
1112
if not platform.platform().startswith("Windows"):
1213
venv_python = venv_dir / "bin" / "python"
1314
else:
1415
venv_python = venv_dir / "Scripts" / "python.exe"
15-
src_dir = Path(".") / "Browser"
16+
src_dir = Path(__file__).parent / "Browser"
1617

1718
if not venv_dir.exists():
1819
print(f"Creating virtualenv in {venv_dir}")
1920
EnvBuilder(with_pip=True).create(venv_dir)
2021

22+
subprocess.run([venv_python, "-m", "pip", "install", "-U", "uv"], check=True)
2123
subprocess.run(
22-
[venv_python, "-m", "pip", "install", "-r", str(src_dir / "dev-requirements.txt"),]
24+
[
25+
venv_python,
26+
"-m",
27+
"uv",
28+
"pip",
29+
"install",
30+
"-r",
31+
str(src_dir / "dev-requirements.txt"),
32+
],
33+
check=True,
2334
)
2435

2536
activate_script = (

tasks.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,12 @@
8686
@task
8787
def deps(c):
8888
c.run("pip install -U pip")
89-
c.run("pip install -r Browser/dev-requirements.txt")
89+
c.run("pip install -U uv")
90+
uv_cmd = "uv pip install -r Browser/dev-requirements.txt"
91+
if IN_CI:
92+
print(f"Install packages to Python found from {sys.executable}.")
93+
uv_cmd = f"{uv_cmd} --python {sys.executable}"
94+
c.run(uv_cmd)
9095
if os.environ.get("CI"):
9196
shutil.rmtree("node_modules", ignore_errors=True)
9297

@@ -598,11 +603,11 @@ def _add_skips(default_args, include_mac=False):
598603
@task
599604
def lint_python(c, fix=False):
600605
print("Run mypy:")
601-
c.run("mypy --exclude .venv --config-file Browser/mypy.ini Browser/")
606+
c.run("mypy --exclude .venv --config-file Browser/mypy.ini Browser/ bootstrap.py")
602607
print("Run black:")
603-
c.run("black --config Browser/pyproject.toml tasks.py Browser/")
608+
c.run("black --config Browser/pyproject.toml tasks.py Browser/ bootstrap.py")
604609
print("Run ruff:")
605-
ruff_cmd = "ruff check --config Browser/pyproject.toml Browser/"
610+
ruff_cmd = "ruff check --config Browser/pyproject.toml Browser/ bootstrap.py"
606611
if fix:
607612
ruff_cmd = f"{ruff_cmd} --fix"
608613
if IN_CI:

0 commit comments

Comments
 (0)