mirror of
https://github.com/naruxde/revpipyload.git
synced 2025-11-08 15:13:52 +01:00
build: Fix Makefile targets to match GNU coding standards
- Rename target clean-all to distclean - Add uninstall target - Install target has to run tests Signed-off-by: Sven Sager <akira@narux.de>
This commit is contained in:
51
Makefile
51
Makefile
@@ -4,6 +4,8 @@ MAKEFLAGS = --no-print-directory --no-builtin-rules
|
||||
|
||||
# Variables
|
||||
PACKAGE = revpipyload
|
||||
APP_NAME = RevPiPyLoad
|
||||
APP_IDENT = org.revpimodio.revpipyload
|
||||
|
||||
# Set path to create the virtual environment with package name
|
||||
ifdef PYTHON3_VENV
|
||||
@@ -16,39 +18,60 @@ endif
|
||||
SYSTEM_PYTHON = python3
|
||||
PYTHON = $(or $(wildcard $(VENV_PATH)/bin/python), $(SYSTEM_PYTHON))
|
||||
|
||||
all: build
|
||||
APP_VERSION = $(shell "$(PYTHON)" src/$(PACKAGE) --version | cut -d ' ' -f 2)
|
||||
|
||||
all: test build
|
||||
|
||||
.PHONY: all
|
||||
|
||||
## Environment
|
||||
venv-info:
|
||||
echo Using path: "$(VENV_PATH)"
|
||||
@echo Environment for $(APP_NAME) $(APP_VERSION)
|
||||
@echo Using path: "$(VENV_PATH)"
|
||||
exit 0
|
||||
|
||||
venv:
|
||||
$(SYSTEM_PYTHON) -m venv "$(VENV_PATH)"
|
||||
source $(VENV_PATH)/bin/activate && \
|
||||
# Start with empty environment
|
||||
"$(SYSTEM_PYTHON)" -m venv "$(VENV_PATH)"
|
||||
source "$(VENV_PATH)/bin/activate" && \
|
||||
python3 -m pip install --upgrade pip && \
|
||||
python3 -m pip install -r requirements.txt
|
||||
exit 0
|
||||
|
||||
.PHONY: venv-info venv
|
||||
venv-ssp:
|
||||
# Include system installed site-packages and add just missing modules
|
||||
"$(SYSTEM_PYTHON)" -m venv --system-site-packages "$(VENV_PATH)"
|
||||
source "$(VENV_PATH)/bin/activate" && \
|
||||
python3 -m pip install --upgrade pip && \
|
||||
python3 -m pip install -r requirements.txt
|
||||
exit 0
|
||||
|
||||
## Build, install
|
||||
.PHONY: venv-info venv venv-ssp
|
||||
|
||||
## Build steps
|
||||
build:
|
||||
$(PYTHON) -m setup sdist
|
||||
$(PYTHON) -m setup bdist_wheel
|
||||
"$(PYTHON)" -m setup sdist
|
||||
"$(PYTHON)" -m setup bdist_wheel
|
||||
|
||||
install: build
|
||||
$(PYTHON) -m pip install dist/$(PACKAGE)-*.whl
|
||||
"$(PYTHON)" -m pip install dist/$(PACKAGE)-$(APP_VERSION)-*.whl
|
||||
|
||||
.PHONY: build install
|
||||
uninstall:
|
||||
"$(PYTHON)" -m pip uninstall --yes $(PACKAGE)
|
||||
|
||||
.PHONY: test build install uninstall
|
||||
|
||||
## Clean
|
||||
clean:
|
||||
rm -rf build dist src/*.egg-info *.spec
|
||||
# PyTest caches
|
||||
rm -rf .pytest_cache
|
||||
# Build artifacts
|
||||
rm -rf build dist src/*.egg-info
|
||||
# PyInstaller created files
|
||||
rm -rf *.spec
|
||||
|
||||
clean-all: clean
|
||||
rm -R $(VENV_PATH)
|
||||
distclean: clean
|
||||
# Virtual environment
|
||||
rm -rf "$(VENV_PATH)"
|
||||
|
||||
.PHONY: clean clean-all
|
||||
.PHONY: clean distclean
|
||||
|
||||
@@ -17,14 +17,7 @@ if __package__ == "":
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
|
||||
if len(sys.argv) == 2 and "--version" in sys.argv:
|
||||
# Catch --version, if this is the only argument (sys.argv[0] is always the script name)
|
||||
from revpipyload import __version__
|
||||
|
||||
print(__version__)
|
||||
sys.exit(0)
|
||||
|
||||
else:
|
||||
# Use absolut import in the __main__ module
|
||||
from revpipyload.revpipyload import main
|
||||
|
||||
# Run the main application of this package
|
||||
|
||||
@@ -10,6 +10,8 @@ import sys
|
||||
from argparse import ArgumentParser
|
||||
from configparser import ConfigParser
|
||||
|
||||
from . import __version__
|
||||
|
||||
conf = ConfigParser()
|
||||
forked = False
|
||||
globalconffile = None
|
||||
@@ -42,6 +44,11 @@ def configure():
|
||||
parser = ArgumentParser(
|
||||
description="RevolutionPi Python Loader"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--version",
|
||||
action="version",
|
||||
version="%(prog)s {0}".format(__version__)
|
||||
)
|
||||
parser.add_argument(
|
||||
"-d", "--daemon", action="store_true", dest="daemon",
|
||||
help="Run program as a daemon in background"
|
||||
|
||||
Reference in New Issue
Block a user