mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-05-05 13:11:49 +02:00
Compare commits
10 commits
019116361f
...
5ff2b08b4a
Author | SHA1 | Date | |
---|---|---|---|
![]() |
5ff2b08b4a | ||
![]() |
39f96f0c12 | ||
![]() |
7e5d2c936c | ||
![]() |
067c741847 | ||
![]() |
deaeb7c682 | ||
![]() |
b74fbab6db | ||
![]() |
f8f12d37c5 | ||
![]() |
02a1cb6591 | ||
![]() |
63be5463ae | ||
![]() |
d36779aece |
13 changed files with 48 additions and 25 deletions
6
BUILD.md
6
BUILD.md
|
@ -113,7 +113,7 @@ Install Poetry using `pipx`:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
pipx install poetry
|
pipx install poetry
|
||||||
pipx inject poetry poetry-plugin-export
|
pipx inject poetry
|
||||||
```
|
```
|
||||||
|
|
||||||
Clone this repository:
|
Clone this repository:
|
||||||
|
@ -326,7 +326,7 @@ cd dangerzone
|
||||||
Install Python dependencies:
|
Install Python dependencies:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
python3 -m pip install poetry poetry-plugin-export
|
python3 -m pip install poetry
|
||||||
poetry install
|
poetry install
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -387,7 +387,7 @@ Install Microsoft Visual C++ 14.0 or greater. Get it with ["Microsoft C++ Build
|
||||||
Install [poetry](https://python-poetry.org/). Open PowerShell, and run:
|
Install [poetry](https://python-poetry.org/). Open PowerShell, and run:
|
||||||
|
|
||||||
```
|
```
|
||||||
python -m pip install poetry poetry-plugin-export
|
python -m pip install poetry
|
||||||
```
|
```
|
||||||
|
|
||||||
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:
|
||||||
|
|
|
@ -123,7 +123,7 @@ Here is what you need to do:
|
||||||
|
|
||||||
# In case of a new Python installation or minor version upgrade, e.g., from
|
# In case of a new Python installation or minor version upgrade, e.g., from
|
||||||
# 3.11 to 3.12, reinstall Poetry
|
# 3.11 to 3.12, reinstall Poetry
|
||||||
python3 -m pip install poetry poetry-plugin-export
|
python3 -m pip install poetry
|
||||||
|
|
||||||
# You can verify the correct Python version is used
|
# You can verify the correct Python version is used
|
||||||
poetry debug info
|
poetry debug info
|
||||||
|
@ -141,7 +141,7 @@ Here is what you need to do:
|
||||||
poetry env remove --all
|
poetry env remove --all
|
||||||
|
|
||||||
# Install the dependencies
|
# Install the dependencies
|
||||||
poetry install --sync
|
poetry sync
|
||||||
```
|
```
|
||||||
|
|
||||||
- [ ] Build the container image and the OCR language data
|
- [ ] Build the container image and the OCR language data
|
||||||
|
@ -205,7 +205,7 @@ The Windows release is performed in a Windows 11 virtual machine (as opposed to
|
||||||
```bash
|
```bash
|
||||||
# In case of a new Python installation or minor version upgrade, e.g., from
|
# In case of a new Python installation or minor version upgrade, e.g., from
|
||||||
# 3.11 to 3.12, reinstall Poetry
|
# 3.11 to 3.12, reinstall Poetry
|
||||||
python3 -m pip install poetry poetry-plugin-export
|
python3 -m pip install poetry
|
||||||
|
|
||||||
# You can verify the correct Python version is used
|
# You can verify the correct Python version is used
|
||||||
poetry debug info
|
poetry debug info
|
||||||
|
@ -223,7 +223,7 @@ The Windows release is performed in a Windows 11 virtual machine (as opposed to
|
||||||
poetry env remove --all
|
poetry env remove --all
|
||||||
|
|
||||||
# Install the dependencies
|
# Install the dependencies
|
||||||
poetry install --sync
|
poetry sync
|
||||||
```
|
```
|
||||||
|
|
||||||
- [ ] Copy the container image into the VM
|
- [ ] Copy the container image into the VM
|
||||||
|
|
|
@ -4,6 +4,12 @@ import sys
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
# Call freeze_support() to avoid passing unknown options to the subprocess.
|
||||||
|
# See https://github.com/freedomofpress/dangerzone/issues/873
|
||||||
|
import multiprocessing
|
||||||
|
|
||||||
|
multiprocessing.freeze_support()
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from . import vendor # type: ignore [attr-defined]
|
from . import vendor # type: ignore [attr-defined]
|
||||||
|
|
|
@ -52,7 +52,11 @@ def print_header(s: str) -> None:
|
||||||
@click.option(
|
@click.option(
|
||||||
"--set-container-runtime",
|
"--set-container-runtime",
|
||||||
required=False,
|
required=False,
|
||||||
help="The path to the container runtime you want to set in the settings",
|
help=(
|
||||||
|
"The name or full path of the container runtime you want Dangerzone to use."
|
||||||
|
" You can specify the value 'default' if you want to take back your choice, and"
|
||||||
|
" let Dangerzone use the default runtime for this OS"
|
||||||
|
)
|
||||||
)
|
)
|
||||||
@click.version_option(version=get_version(), message="%(version)s")
|
@click.version_option(version=get_version(), message="%(version)s")
|
||||||
@errors.handle_document_errors
|
@errors.handle_document_errors
|
||||||
|
@ -69,10 +73,16 @@ def cli_main(
|
||||||
display_banner()
|
display_banner()
|
||||||
if set_container_runtime:
|
if set_container_runtime:
|
||||||
settings = Settings()
|
settings = Settings()
|
||||||
container_runtime = settings.set_custom_runtime(
|
if set_container_runtime == "default":
|
||||||
set_container_runtime, autosave=True
|
settings.unset_custom_runtime()
|
||||||
)
|
click.echo(
|
||||||
click.echo(f"Set the settings container_runtime to {container_runtime}")
|
"Instructed Dangerzone to use the default container runtime for this OS"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
container_runtime = settings.set_custom_runtime(
|
||||||
|
set_container_runtime, autosave=True
|
||||||
|
)
|
||||||
|
click.echo(f"Set the settings container_runtime to {container_runtime}")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
elif not filenames:
|
elif not filenames:
|
||||||
raise click.UsageError("Missing argument 'FILENAMES...'")
|
raise click.UsageError("Missing argument 'FILENAMES...'")
|
||||||
|
|
|
@ -10,6 +10,7 @@ from typing import List, Optional
|
||||||
import click
|
import click
|
||||||
import colorama
|
import colorama
|
||||||
|
|
||||||
|
|
||||||
# FIXME: See https://github.com/freedomofpress/dangerzone/issues/320 for more details.
|
# FIXME: See https://github.com/freedomofpress/dangerzone/issues/320 for more details.
|
||||||
if typing.TYPE_CHECKING:
|
if typing.TYPE_CHECKING:
|
||||||
from PySide2 import QtCore, QtGui, QtWidgets
|
from PySide2 import QtCore, QtGui, QtWidgets
|
||||||
|
|
|
@ -3,7 +3,6 @@ import os
|
||||||
import platform
|
import platform
|
||||||
import tempfile
|
import tempfile
|
||||||
import typing
|
import typing
|
||||||
from multiprocessing import freeze_support
|
|
||||||
from multiprocessing.pool import ThreadPool
|
from multiprocessing.pool import ThreadPool
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
@ -229,6 +228,8 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||||
self.handle_docker_desktop_version_check(is_version_valid, version)
|
self.handle_docker_desktop_version_check(is_version_valid, version)
|
||||||
except errors.UnsupportedContainerRuntime as e:
|
except errors.UnsupportedContainerRuntime as e:
|
||||||
pass # It's catched later in the flow.
|
pass # It's catched later in the flow.
|
||||||
|
except errors.NoContainerTechException as e:
|
||||||
|
pass # It's catched later in the flow.
|
||||||
|
|
||||||
self.show()
|
self.show()
|
||||||
|
|
||||||
|
@ -1236,9 +1237,6 @@ class DocumentsListWidget(QtWidgets.QListWidget):
|
||||||
def start_conversion(self) -> None:
|
def start_conversion(self) -> None:
|
||||||
if not self.thread_pool_initized:
|
if not self.thread_pool_initized:
|
||||||
max_jobs = self.dangerzone.isolation_provider.get_max_parallel_conversions()
|
max_jobs = self.dangerzone.isolation_provider.get_max_parallel_conversions()
|
||||||
# Call freeze_support() to avoid passing unknown options to the subprocess.
|
|
||||||
# See https://github.com/freedomofpress/dangerzone/issues/873
|
|
||||||
freeze_support()
|
|
||||||
self.thread_pool = ThreadPool(max_jobs)
|
self.thread_pool = ThreadPool(max_jobs)
|
||||||
|
|
||||||
for doc in self.docs_list:
|
for doc in self.docs_list:
|
||||||
|
|
|
@ -52,6 +52,10 @@ class Settings:
|
||||||
self.save()
|
self.save()
|
||||||
return container_runtime
|
return container_runtime
|
||||||
|
|
||||||
|
def unset_custom_runtime(self) -> None:
|
||||||
|
self.settings.pop("container_runtime")
|
||||||
|
self.save()
|
||||||
|
|
||||||
def get(self, key: str) -> Any:
|
def get(self, key: str) -> Any:
|
||||||
return self.settings[key]
|
return self.settings[key]
|
||||||
|
|
||||||
|
|
|
@ -331,7 +331,7 @@ Install Poetry using `pipx`:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
pipx install poetry
|
pipx install poetry
|
||||||
pipx inject poetry poetry-plugin-export
|
pipx inject poetry
|
||||||
```
|
```
|
||||||
|
|
||||||
Clone this repository:
|
Clone this repository:
|
||||||
|
@ -397,7 +397,7 @@ Install Microsoft Visual C++ 14.0 or greater. Get it with ["Microsoft C++ Build
|
||||||
Install [poetry](https://python-poetry.org/). Open PowerShell, and run:
|
Install [poetry](https://python-poetry.org/). Open PowerShell, and run:
|
||||||
|
|
||||||
```
|
```
|
||||||
python -m pip install poetry poetry-plugin-export
|
python -m pip install poetry
|
||||||
```
|
```
|
||||||
|
|
||||||
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:
|
||||||
|
@ -835,8 +835,8 @@ class QAWindows(QABase):
|
||||||
"Install Poetry and the project's dependencies", ref=REF_BUILD, auto=True
|
"Install Poetry and the project's dependencies", ref=REF_BUILD, auto=True
|
||||||
)
|
)
|
||||||
def install_poetry(self):
|
def install_poetry(self):
|
||||||
self.run("python", "-m", "pip", "install", "poetry", "poetry-plugin-export")
|
self.run("python", "-m", "pip", "install", "poetry")
|
||||||
self.run("poetry", "install", "--sync")
|
self.run("poetry", "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):
|
||||||
|
|
|
@ -42,7 +42,8 @@ doit <task>
|
||||||
## Tips and tricks
|
## Tips and tricks
|
||||||
|
|
||||||
* You can run `doit list --all -s` to see the full list of tasks, their
|
* You can run `doit list --all -s` to see the full list of tasks, their
|
||||||
dependencies, and whether they are up to date.
|
dependencies, and whether they are up to date (U) or will run (R). Note that
|
||||||
|
certain small tasks are always configured to run.
|
||||||
* You can run `doit info <task>` to see which dependencies are missing.
|
* You can run `doit info <task>` to see which dependencies are missing.
|
||||||
* You can pass the following environment variables to the script, in order to
|
* You can pass the following environment variables to the script, in order to
|
||||||
affect some global parameters:
|
affect some global parameters:
|
||||||
|
|
2
dodo.py
2
dodo.py
|
@ -206,7 +206,7 @@ def task_build_image():
|
||||||
|
|
||||||
def task_poetry_install():
|
def task_poetry_install():
|
||||||
"""Setup the Poetry environment"""
|
"""Setup the Poetry environment"""
|
||||||
return {"actions": ["poetry install --sync"], "clean": ["poetry env remove --all"]}
|
return {"actions": ["poetry sync"], "clean": ["poetry env remove --all"]}
|
||||||
|
|
||||||
|
|
||||||
def task_macos_build_dmg():
|
def task_macos_build_dmg():
|
||||||
|
|
|
@ -5,7 +5,7 @@ import subprocess
|
||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
BUILD_CONTEXT = "dangerzone/"
|
BUILD_CONTEXT = "dangerzone"
|
||||||
IMAGE_NAME = "dangerzone.rocks/dangerzone"
|
IMAGE_NAME = "dangerzone.rocks/dangerzone"
|
||||||
if platform.system() in ["Darwin", "Windows"]:
|
if platform.system() in ["Darwin", "Windows"]:
|
||||||
CONTAINER_RUNTIME = "docker"
|
CONTAINER_RUNTIME = "docker"
|
||||||
|
@ -122,7 +122,8 @@ def main():
|
||||||
|
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
[
|
[
|
||||||
"./dev_scripts/repro-build.py",
|
sys.executable,
|
||||||
|
str(Path("dev_scripts") / "repro-build.py"),
|
||||||
"build",
|
"build",
|
||||||
"--runtime",
|
"--runtime",
|
||||||
args.runtime,
|
args.runtime,
|
||||||
|
|
|
@ -51,6 +51,8 @@ def main():
|
||||||
if files == expected_files:
|
if files == expected_files:
|
||||||
logger.info("Skipping tessdata download, language data already exists")
|
logger.info("Skipping tessdata download, language data already exists")
|
||||||
return
|
return
|
||||||
|
elif not files:
|
||||||
|
logger.info("Tesseract dir is empty, proceeding to download language data")
|
||||||
else:
|
else:
|
||||||
logger.info(f"Found {tessdata_dir} but contents do not match")
|
logger.info(f"Found {tessdata_dir} but contents do not match")
|
||||||
return 1
|
return 1
|
||||||
|
|
|
@ -13,7 +13,7 @@ setup(
|
||||||
description="Dangerzone",
|
description="Dangerzone",
|
||||||
options={
|
options={
|
||||||
"build_exe": {
|
"build_exe": {
|
||||||
"packages": ["dangerzone", "dangerzone.gui"],
|
"packages": ["dangerzone", "dangerzone.gui", "pymupdf._wxcolors"],
|
||||||
"excludes": ["test", "tkinter"],
|
"excludes": ["test", "tkinter"],
|
||||||
"include_files": [("share", "share"), ("LICENSE", "LICENSE")],
|
"include_files": [("share", "share"), ("LICENSE", "LICENSE")],
|
||||||
"include_msvcr": True,
|
"include_msvcr": True,
|
||||||
|
|
Loading…
Reference in a new issue