From 02f365b93f62919cd0908172fb7cf1bd8023e74c Mon Sep 17 00:00:00 2001 From: Timmy Welch Date: Tue, 19 Apr 2022 14:45:36 -0700 Subject: [PATCH] Fix Makefile make check now uses a venv make CI uses the environment Fix rar test --- Makefile | 46 ++++++++++++++++++++++++++------------ tests/test_comicarchive.py | 2 +- 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index d10cde0..6eb400a 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,15 @@ PIP ?= pip3 PYTHON ?= python3 VERSION_STR := $(shell $(PYTHON) setup.py --version) +SITE_PACKAGES := $(shell $(PYTHON) -c 'import sysconfig; print(sysconfig.get_paths()["purelib"])') +PACKAGE_PATH = $(SITE_PACKAGES)/comictagger-$(VERSION_STR).dist-info + +VENV := $(shell echo $${VIRTUAL_ENV-venv}) +PY3 := $(shell command -v python3 2> /dev/null) +PYTHON_VENV := $(VENV)/bin/python +INSTALL_STAMP := $(VENV)/.install.stamp + + ifeq ($(OS),Windows_NT) OS_VERSION=win-$(PROCESSOR_ARCHITECTURE) APP_NAME=comictagger.exe @@ -15,33 +24,33 @@ else FINAL_NAME=ComicTagger-$(VERSION_STR) endif -.PHONY: all clean pydist upload dist CI +.PHONY: all clean pydist upload dist CI check all: clean dist +$(PYTHON_VENV): + @if [ -z $(PY3) ]; then echo "Python 3 could not be found."; exit 2; fi + $(PY3) -m venv $(VENV) + clean: - rm -rf *~ *.pyc *.pyo - rm -rf scripts/*.pyc - cd comictaggerlib; rm -f *~ *.pyc *.pyo + find . -type d -name "__pycache__" | xargs rm -rf {}; + rm -rf $(INSTALL_STAMP) rm -rf dist MANIFEST - rm -rf *.deb - rm -rf logdict*.log $(MAKE) -C mac clean rm -rf build - rm -rf comictaggerlib/ui/__pycache__ rm comictaggerlib/ctversion.py -CI: +CI: ins black . isort . flake8 . pytest -check: - black --check . - isort --check . - flake8 . - pytest +check: install + $(VENV)/bin/black --check . + $(VENV)/bin/isort --check . + $(VENV)/bin/flake8 . + $(VENV)/bin/pytest pydist: CI make clean @@ -55,7 +64,16 @@ upload: $(PYTHON) setup.py register $(PYTHON) setup.py sdist --formats=gztar upload +install: $(INSTALL_STAMP) +$(INSTALL_STAMP): $(PYTHON_VENV) requirements.txt requirements_dev.txt + $(PYTHON_VENV) -m pip install -r requirements_dev.txt + $(PYTHON_VENV) -m pip install -e . + touch $(INSTALL_STAMP) + +ins: $(PACKAGE_PATH) +$(PACKAGE_PATH): + $(PIP) -m pip install . + dist: CI - $(PIP) install . pyinstaller -y comictagger.spec cd dist && zip -r $(FINAL_NAME).zip $(APP_NAME) diff --git a/tests/test_comicarchive.py b/tests/test_comicarchive.py index 5cd8644..548ed03 100644 --- a/tests/test_comicarchive.py +++ b/tests/test_comicarchive.py @@ -9,7 +9,7 @@ from comicapi.genericmetadata import GenericMetadata, PageType, md_test thisdir = dirname(abspath(__file__)) -@pytest.mark.xfail(rar_support, reason="rar support") +@pytest.mark.xfail(not rar_support, reason="rar support") def test_getPageNameList(): ComicArchive.logo_data = b"" c = ComicArchive(join(thisdir, "data", "fake_cbr.cbr"))