Fix uv replacement in qa.py script

This commit is contained in:
Alexis Métaireau 2025-01-06 15:51:29 +01:00
parent e1357ca2fe
commit 20f1e43471
No known key found for this signature in database
GPG key ID: C65C7A89A8FFC56E
3 changed files with 35 additions and 48 deletions

View file

@ -160,7 +160,7 @@ Clone this repository:
git clone https://github.com/freedomofpress/dangerzone/ git clone https://github.com/freedomofpress/dangerzone/
``` ```
Change to the `dangerzone` folder, and install the uv dependencies: Change to the `dangerzone` folder, and install the `uv` dependencies:
``` ```
cd dangerzone cd dangerzone
@ -426,7 +426,7 @@ Install git from [here](https://git-scm.com/download/win), open a Windows termin
git clone https://github.com/freedomofpress/dangerzone/ git clone https://github.com/freedomofpress/dangerzone/
``` ```
Change to the `dangerzone` folder, and install the uv dependencies: Change to the `dangerzone` folder, and install the `uv` dependencies:
``` ```
cd dangerzone cd dangerzone

View file

@ -19,8 +19,9 @@ lint: ## Check the code for linting, formatting, and typing issues with ruff and
.PHONY: fix .PHONY: fix
fix: ## apply all the suggestions from ruff fix: ## apply all the suggestions from ruff
ruff check --fix ruff check --fix
ruff format .PHONY: test ruff format .
.PHONY: test
test: test:
# Make each GUI test run as a separate process, to avoid segfaults due to # Make each GUI test run as a separate process, to avoid segfaults due to
# shared state. # shared state.
@ -41,6 +42,7 @@ test-large-init: test-large-requirements
cd $(LARGE_TEST_REPO_DIR) && $(MAKE) clone-docs cd $(LARGE_TEST_REPO_DIR) && $(MAKE) clone-docs
TEST_LARGE_RESULTS:=$(LARGE_TEST_REPO_DIR)/results/junit/commit_$(GIT_DESC).junit.xml TEST_LARGE_RESULTS:=$(LARGE_TEST_REPO_DIR)/results/junit/commit_$(GIT_DESC).junit.xml
.PHONY: test-large .PHONY: test-large
test-large: test-large-init ## Run large test set test-large: test-large-init ## Run large test set
python -m pytest --tb=no tests/test_large_set.py::TestLargeSet -v $(JUNIT_FLAGS) --junitxml=$(TEST_LARGE_RESULTS) python -m pytest --tb=no tests/test_large_set.py::TestLargeSet -v $(JUNIT_FLAGS) --junitxml=$(TEST_LARGE_RESULTS)

View file

@ -282,14 +282,14 @@ sudo apt install -y podman dh-python build-essential make libqt6gui6 \
Install `uv` using `pipx` (recommended) and add it to your `$PATH`: Install `uv` using `pipx` (recommended) and add it to your `$PATH`:
_(See also a list of [alternative installation _(See also a list of [alternative installation
methods](https://python-`uv`.org/docs/#installation))_ methods](https://docs.astral.sh/uv/getting-started/installation/))_
```sh ```sh
pipx ensurepath pipx ensurepath
pipx install `uv` pipx install uv
``` ```
After this, restart the terminal window, for the ``uv command to be in your After this, restart the terminal window, for the `uv` command to be in your
`$PATH`. `$PATH`.
@ -301,42 +301,37 @@ git clone https://github.com/freedomofpress/dangerzone/
Change to the `dangerzone` folder, and install the `uv` dependencies: Change to the `dangerzone` folder, and install the `uv` dependencies:
> **Note**: due to an issue with [`uv`](https://github.com/python-`uv`/`uv`/issues/1917), if it prompts for your keyring, disable the keyring with `keyring --disable` and run the command again.
``` ```
cd dangerzone cd dangerzone
`uv` install uv sync
``` ```
Build the latest container: Build the latest container:
```sh ```sh
python3 ./install/common/build-image.py uv run ./install/common/build-image.py
``` ```
Download the OCR language data: Download the OCR language data:
```sh ```sh
python3 ./install/common/download-tessdata.py uv run ./install/common/download-tessdata.py
``` ```
Run from source tree: Run from source tree:
```sh ```sh
# start a shell in the virtual environment
`uv` shell
# run the CLI # run the CLI
./dev_scripts/dangerzone-cli --help uv run ./dev_scripts/dangerzone-cli --help
# run the GUI # run the GUI
./dev_scripts/dangerzone uv run ./dev_scripts/dangerzone
``` ```
Create a .deb: Create a .deb:
```sh ```sh
./install/linux/build-deb.py uv run ./install/linux/build-deb.py
``` ```
""" """
@ -345,7 +340,7 @@ CONTENT_BUILD_FEDORA = r"""## Fedora
Install dependencies: Install dependencies:
```sh ```sh
sudo dnf install -y rpm-build podman python3 python3-devel python3-`uv`-core \ sudo dnf install -y rpm-build podman python3 python3-devel python3-uv \
pipx qt6-qtbase-gui pipx qt6-qtbase-gui
``` ```
@ -365,7 +360,7 @@ sudo dnf install -y rpm-build podman python3 python3-devel python3-`uv`-core \
sudo dnf install -y python3.12 sudo dnf install -y python3.12
``` ```
`uv` will automatically pick up the correct version when running. uv will automatically pick up the correct version when running.
</details> </details>
</td> </td>
</tr> </tr>
@ -374,7 +369,7 @@ sudo dnf install -y rpm-build podman python3 python3-devel python3-`uv`-core \
Install `uv` using `pipx`: Install `uv` using `pipx`:
```sh ```sh
pipx install `uv` pipx install uv
``` ```
Clone this repository: Clone this repository:
@ -385,11 +380,9 @@ git clone https://github.com/freedomofpress/dangerzone/
Change to the `dangerzone` folder, and install the `uv` dependencies: Change to the `dangerzone` folder, and install the `uv` dependencies:
> **Note**: due to an issue with [`uv`](https://github.com/python-`uv`/`uv`/issues/1917), if it prompts for your keyring, disable the keyring with `keyring --disable` and run the command again.
``` ```
cd dangerzone cd dangerzone
`uv` install uv sync
``` ```
Build the latest container: Build the latest container:
@ -407,14 +400,11 @@ python3 ./install/common/download-tessdata.py
Run from source tree: Run from source tree:
```sh ```sh
# start a shell in the virtual environment
`uv` shell
# run the CLI # run the CLI
./dev_scripts/dangerzone-cli --help uv run ./dev_scripts/dangerzone-cli --help
# run the GUI # run the GUI
./dev_scripts/dangerzone uv run ./dev_scripts/dangerzone
``` ```
> [!NOTE] > [!NOTE]
@ -424,7 +414,7 @@ Run from source tree:
Create a .rpm: Create a .rpm:
```sh ```sh
./install/linux/build-rpm.py uv run ./install/linux/build-rpm.py
``` ```
""" """
@ -437,10 +427,10 @@ Install the latest version of Python 3.12 (64-bit) [from python.org](https://www
Install Microsoft Visual C++ 14.0 or greater. Get it with ["Microsoft C++ Build Tools"](https://visualstudio.microsoft.com/visual-cpp-build-tools/) and make sure to select "Desktop development with C++" when installing. Install Microsoft Visual C++ 14.0 or greater. Get it with ["Microsoft C++ Build Tools"](https://visualstudio.microsoft.com/visual-cpp-build-tools/) and make sure to select "Desktop development with C++" when installing.
Install [`uv`](https://python-`uv`.org/). Open PowerShell, and run: Install [uv](https://docs.astral.sh/uv/getting-started/installation/). Open PowerShell, and run:
``` ```
python -m pip install `uv` python -m pip install uv
``` ```
Install git from [here](https://git-scm.com/download/win), open a Windows terminal (`cmd.exe`) and clone this repository: Install git from [here](https://git-scm.com/download/win), open a Windows terminal (`cmd.exe`) and clone this repository:
@ -453,7 +443,7 @@ Change to the `dangerzone` folder, and install the `uv` dependencies:
``` ```
cd dangerzone cd dangerzone
`uv` install uv sync
``` ```
Build the dangerzone container image: Build the dangerzone container image:
@ -471,14 +461,11 @@ python3 .\install\common\download-tessdata.py
After that you can launch dangerzone during development with: After that you can launch dangerzone during development with:
``` ```
# start a shell in the virtual environment
`uv` shell
# run the CLI # run the CLI
.\dev_scripts\dangerzone-cli.bat --help uv run .\dev_scripts\dangerzone-cli.bat --help
# run the GUI # run the GUI
.\dev_scripts\dangerzone.bat uv run .\dev_scripts\dangerzone.bat
``` ```
""" """
@ -877,9 +864,9 @@ class QAWindows(QABase):
@QABase.task( @QABase.task(
"Install `uv` and the project's dependencies", ref=REF_BUILD, auto=True "Install `uv` and the project's dependencies", ref=REF_BUILD, auto=True
) )
def install_`uv`(self): def install_uv(self):
self.run("python", "-m", "pip", "install", "`uv`") self.run("python", "-m", "pip", "install", "uv")
self.run("`uv`", "install", "--sync") self.run("uv", "sync")
@QABase.task("Build Dangerzone container image", ref=REF_BUILD, auto=True) @QABase.task("Build Dangerzone container image", ref=REF_BUILD, auto=True)
def build_image(self): def build_image(self):
@ -888,13 +875,11 @@ class QAWindows(QABase):
@QABase.task("Run tests", ref="REF_BUILD", auto=True) @QABase.task("Run tests", ref="REF_BUILD", auto=True)
def run_tests(self): def run_tests(self):
# NOTE: Windows does not have Makefile by default. # NOTE: Windows does not have Makefile by default.
self.run( self.run("uv", "run", "pytest", "-v", "--ignore", r"tests\test_large_set.py")
"`uv`", "run", "pytest", "-v", "--ignore", r"tests\test_large_set.py"
)
@QABase.task("Build Dangerzone .exe", ref="REF_BUILD", auto=True) @QABase.task("Build Dangerzone .exe", ref="REF_BUILD", auto=True)
def build_dangerzone_exe(self): def build_dangerzone_exe(self):
self.run("`uv`", "run", "python", r".\setup-windows.py", "build") self.run("uv", "run", r".\setup-windows.py", "build")
@classmethod @classmethod
def get_id(cls): def get_id(cls):
@ -903,7 +888,7 @@ class QAWindows(QABase):
def start(self): def start(self):
self.install_python() self.install_python()
self.install_docker() self.install_docker()
self.install_`uv`() self.install_uv()
self.build_image() self.build_image()
self.download_tessdata() self.download_tessdata()
self.run_tests() self.run_tests()
@ -935,9 +920,9 @@ class QALinux(QABase):
args_str = " ".join(args) args_str = " ".join(args)
self.container_run("bash", "-c", f"cd dangerzone; {args_str}") self.container_run("bash", "-c", f"cd dangerzone; {args_str}")
def `uv`_run(self, *args): def uv_run(self, *args):
"""Run a command via `uv` inside a Dangerzone environment.""" """Run a command via `uv` inside a Dangerzone environment."""
self.shell_run("`uv`", "run", *args) self.shell_run("uv", "run", *args)
@QABase.task( @QABase.task(
"Create Dangerzone build environment", "Create Dangerzone build environment",
@ -964,7 +949,7 @@ class QALinux(QABase):
@QABase.task("Run tests", ref="REF_BUILD", auto=True) @QABase.task("Run tests", ref="REF_BUILD", auto=True)
def run_tests(self): def run_tests(self):
self.`uv`_run("make", "test") self.uv_run("make", "test")
def build_package(self): def build_package(self):
"""Build the Dangerzone .deb/.rpm package""" """Build the Dangerzone .deb/.rpm package"""