Skip to content

Commit

Permalink
Bump the minimum python version to 3.9
Browse files Browse the repository at this point in the history
The minimum python version when installing from source is now python
3.9, as Pyside6 6.7.1 dropped support for python 3.8 (see #780 for more
information).

On Debian-derivatives distributions, the minimum Python version is now
set to 3.8. In practice, because Pyside6 is not packaged for Debian, we
use Pyside2 [0], which is why we can relax the python version requirement.

In practice, when installing from source on an environment where
python3.9 is not the default python, poetry will look for it and use it
if available

> For various reasons, this Python version might not be compatible with
> the python range supported by the project. In this case, Poetry will
> try to find one that is and use it.
>
> [Poetry docs](https://python-poetry.org/docs/managing-environments/)

On Ubuntu Focal (20.04) where Python 3.9 is not installed by default,
it is possible to install it using the `python3.9` package.

Additionally, In version 1.24.3, PyMuPDF changed its package name from `fitz`
to `pymupdf` [2], resulting in a breakage on how it is installed in our
container. This is now fixed.

[0] More information on how Pyside6 packaging affects dangerzone on #221
[1] See [the current status of Pyside6 packaging](https://repology.org/
project/python:pyside6/packages)
[2] PyMuPDF changelog: https://pymupdf.readthedocs.io/en/latest/changes.html#change-log
  • Loading branch information
almet committed Jun 4, 2024
1 parent 2aee6f4 commit 014582e
Show file tree
Hide file tree
Showing 9 changed files with 266 additions and 216 deletions.
24 changes: 24 additions & 0 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,30 @@ Install dependencies:
</tr>
</table>


<table>
<tr>
<td>
<details>
<summary><i>:memo: Expand this section if you are on Ubuntu 20.04 (Focal).</i></summary>
</br>

The default Python version that ships with Ubuntu Focal (3.8) is not
compatible with PySide6, which requires Python 3.9 of greater.

You can install Python 3.9 using the `python3.9` package.

```bash
sudo apt install -y python3.9
```

Poetry will automatically pick up the correct version when running.
</details>
</td>
</tr>
</table>


```sh
sudo apt install -y podman dh-python build-essential fakeroot make libqt6gui6 \
pipx python3 python3-dev python3-stdeb python3-all
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ARG REQUIREMENTS_TXT
# Install PyMuPDF via hash-checked requirements file
COPY ${REQUIREMENTS_TXT} /tmp/requirements.txt
RUN apk --no-cache add linux-headers g++ linux-headers gcc make python3-dev py3-pip clang-dev
RUN pip install --break-system-packages --require-hashes -r /tmp/requirements.txt
RUN pip install -vv --break-system-packages --require-hashes -r /tmp/requirements.txt


###########################################
Expand Down Expand Up @@ -62,6 +62,7 @@ RUN apk --no-cache -U upgrade && \
font-noto-cjk

COPY --from=pymupdf-build /usr/lib/python3.12/site-packages/fitz/ /usr/lib/python3.12/site-packages/fitz
COPY --from=pymupdf-build /usr/lib/python3.12/site-packages/pymupdf/ /usr/lib/python3.12/site-packages/pymupdf
COPY --from=tessdata-dl /usr/share/tessdata/ /usr/share/tessdata
COPY --from=h2orestart-dl /libreoffice_ext/ /libreoffice_ext

Expand Down
2 changes: 1 addition & 1 deletion dev_scripts/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y python-all curl wget gnupg2 \
&& apt-get install -y python-all python3.9 curl wget gnupg2 \
&& rm -rf /var/lib/apt/lists/*
RUN . /etc/os-release \
&& sh -c "echo 'deb http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_$VERSION_ID/ /' \
Expand Down
24 changes: 24 additions & 0 deletions dev_scripts/qa.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,30 @@
</tr>
</table>
<table>
<tr>
<td>
<details>
<summary><i>:memo: Expand this section if you are on Ubuntu 20.04 (Focal).</i></summary>
</br>
The default Python version that ships with Ubuntu Focal (3.8) is not
compatible with PySide6, which requires Python 3.9 of greater.
You can install Python 3.9 using the `python3.9` package.
```bash
sudo apt install -y python3.9
```
Poetry will automatically pick up the correct version when running.
</details>
</td>
</tr>
</table>
```sh
sudo apt install -y podman dh-python build-essential fakeroot make libqt6gui6 \
pipx python3 python3-dev python3-stdeb python3-all
Expand Down
423 changes: 212 additions & 211 deletions poetry.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ include = [
]

[tool.poetry.dependencies]
python = ">=3.8,<3.13"
python = ">=3.9,<3.13"
click = "*"
appdirs = "*"
PySide6 = "^6.4.1"
PySide6 = "^6.7.1"
colorama = "*"
pyxdg = {version = "*", platform = "linux"}
requests = "*"
Expand Down
2 changes: 1 addition & 1 deletion stdeb.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Package3: dangerzone
Depends3: podman, python3, python3-pyside2.qtcore, python3-pyside2.qtgui, python3-pyside2.qtwidgets, python3-pyside2.qtsvg, python3-appdirs, python3-click, python3-xdg, python3-colorama, python3-requests, python3-markdown, python3-packaging
Build-Depends: dh-python, python3, python3-setuptools, python3-stdeb
Suite: bionic
X-Python3-Version: >= 3.6
X-Python3-Version: >= 3.8
# Do not trigger testing when we build the package. Assume that the user
# has tested the package already. For more info, see:
# https://github.com/freedomofpress/dangerzone/issues/292#issuecomment-1349967888
Expand Down
Binary file added tests/test_docs/unsafe/sample-bmp.bmp
Binary file not shown.
Binary file added tests/test_docs/unsafe/sample-pdf.pdf
Binary file not shown.

0 comments on commit 014582e

Please sign in to comment.