Skip to content

Commit

Permalink
Fixes #98. Linting. Generate the UI resources before linting
Browse files Browse the repository at this point in the history
- resource generation occurs as the very first thing when cruiz starts now
- this avoids needing any graphical resources on CI machines
  • Loading branch information
markfinal committed Jul 15, 2023
1 parent 9d01028 commit 9520160
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
6 changes: 6 additions & 0 deletions cruiz/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@

import os

from cruiz.resourcegeneration import generate_resources

# resource generation be invoked before resources and MainWindow are imported
generate_resources()


os.environ.setdefault("QT_API", "pyside6")

from cruiz.entrypoint import main # noqa: E402
Expand Down
5 changes: 0 additions & 5 deletions cruiz/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

from qtpy import QtCore, QtWidgets

from cruiz.resourcegeneration import generate_resources


CONAN_SPEC = importlib.util.find_spec("conans")
if CONAN_SPEC is None:
Expand All @@ -36,9 +34,6 @@

logger = logging.getLogger(__name__)

# resource generation be invoked before resources and MainWindow are imported
generate_resources()

import cruiz.pyside6.resources # noqa: F401, E402

from cruiz.application import Application # noqa: E402
Expand Down
4 changes: 4 additions & 0 deletions cruiz/resourcegeneration.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import pathlib
import platform
import subprocess
import sys
import typing

SUBDIR = "pyside6"
Expand Down Expand Up @@ -80,3 +81,6 @@ def generate_resources() -> None:
logger.debug("Checking for out-of-date resources...")
_ensure_resource_file_is_up_to_date(current_dir / SUBDIR, resources_dir)
_ensure_ui_files_are_up_to_date(current_dir / SUBDIR, resources_dir)
if "CRUIZ_GENERATE_RESOURCES_ONLY" in os.environ:
print("Completed resource generation...exiting")
sys.exit(0)
3 changes: 3 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
skipsdist = true

[testenv]
setenv =
lint: CRUIZ_GENERATE_RESOURCES_ONLY = 1
deps =
lint: -r{toxinidir}/requirements_dev.txt
lint: -r{toxinidir}/requirements.txt
commands =
lint: python -m cruiz
lint: flake8 cruiz
lint: mypy --install-types --non-interactive cruiz

0 comments on commit 9520160

Please sign in to comment.