From 1ea46e17046546d82de9ca036a5394c516499e02 Mon Sep 17 00:00:00 2001 From: Paul Jimenez Date: Fri, 18 Jan 2019 21:26:54 -0500 Subject: [PATCH] build the ui into a wheel, using a venv to pollute the global packagespace less --- README.md | 9 ++++----- ui/.gitignore | 1 + ui/Makefile | 25 +++++++++++++++++-------- ui/requirements.txt | 6 ------ ui/setup.py | 12 ++++++++++-- 5 files changed, 32 insertions(+), 21 deletions(-) delete mode 100644 ui/requirements.txt diff --git a/README.md b/README.md index 24c349b5bd..361af55e61 100644 --- a/README.md +++ b/README.md @@ -55,14 +55,13 @@ The new `opensnitchd` service will log to `/var/log/opensnitchd.log`, save the r The user interface is a Python 3 software running as a `gRPC` server on a unix socket, to order to install its dependencies: cd ui - sudo pip3 install -r requirements.txt + make -You will also need to install the package `python-pyqt5` for your system (if anyone finds a way to make this work from -the `requirements.txt` file feel free to send a PR). +This build a python wheel package and puts it into the `dist` directory. You can install it via -The UI is pip installable itself: + sudo pip3 install dist/*.whl - sudo pip3 install . +which will also cause it to install all of its dependencies. This will install the `opensnitch-ui` command on your system (you can auto startup it by `cp opensnitch_ui.desktop ~/.config/autostart/`). diff --git a/ui/.gitignore b/ui/.gitignore index a244087086..dc43051afa 100644 --- a/ui/.gitignore +++ b/ui/.gitignore @@ -3,3 +3,4 @@ build dist *.egg-info __pycache__ +/vbuildtools diff --git a/ui/Makefile b/ui/Makefile index 29c1d35805..d28db12a48 100644 --- a/ui/Makefile +++ b/ui/Makefile @@ -1,14 +1,23 @@ -all: opensnitch/resources_rc.py +all: wheel -install: - @pip3 install . +.PHONY: install +install: wheel + @pip3 install dist/opensnitch_ui*.whl -opensnitch/resources_rc.py: deps - @pyrcc5 -o opensnitch/resources_rc.py opensnitch/res/resources.qrc +opensnitch/res/resources_rc.qrc: opensnitch/resources_rc.py vbuildtools + @vbuildtools/bin/pyrcc5 -o opensnitch/resources_rc.py opensnitch/res/resources.qrc -deps: - @sudo pip3 install -r requirements.txt +vbuildtools: + python3 -m venv vbuildtools + # install build dependencies ; runtime dependencies go in setup.py + vbuildtools/bin/pip install pyqt5 wheel +.PHONY: wheel +wheel: vbuildtools + vbuildtools/bin/python setup.py bdist_wheel + +.PHONY: clean clean: - @rm -rf *.pyc + @rm -rf *.pyc vbuildtools @rm -rf opensnitch/resources_rc.py + diff --git a/ui/requirements.txt b/ui/requirements.txt deleted file mode 100644 index 08f6647434..0000000000 --- a/ui/requirements.txt +++ /dev/null @@ -1,6 +0,0 @@ -grpcio==1.0.0 -grpcio-tools==1.10.1 -pyinotify==0.9.6 -unicode_slugify==0.1.3 -pyqt5==5.10.1 -configparser==3.5.0 diff --git a/ui/setup.py b/ui/setup.py index d546ea8b10..50a249cc70 100644 --- a/ui/setup.py +++ b/ui/setup.py @@ -7,7 +7,7 @@ sys.path.append(path) from opensnitch.version import version - + setup(name='opensnitch-ui', version=version, description='Prompt service and UI for the opensnitch application firewall.', @@ -20,5 +20,13 @@ package_data={'': ['*.*']}, data_files=[('/usr/share/applications', ['opensnitch_ui.desktop']), ('/usr/share/kservices5', ['kcm_opensnitch.desktop'])], - scripts = [ 'bin/opensnitch-ui' ], + scripts=[ 'bin/opensnitch-ui' ], + install_requires=[ + 'grpcio==1.0.0', + 'grpcio-tools==1.10.1', + 'pyinotify==0.9.6', + 'unicode_slugify==0.1.3', + 'pyqt5==5.10.1', + 'configparser==3.5.0', + ], zip_safe=False)