From 8186121508fe7e1c04f2192b430565e4c64fb70a Mon Sep 17 00:00:00 2001 From: "dries.k" Date: Mon, 21 Mar 2022 18:58:59 +0100 Subject: [PATCH] install as a pip package --- .gitignore | 1 + MANIFEST.in | 3 + README.md | 37 ++++++++---- entry_point.py | 5 -- gotify-tray.spec | 2 +- gotify_tray/__main__.py | 3 + gotify_tray/gui/designs/__init__.py | 0 gotify_tray/gui/images/__init__.py | 0 setup.py | 87 +++++++++++++++++++++++++++++ 9 files changed, 121 insertions(+), 17 deletions(-) create mode 100644 MANIFEST.in delete mode 100644 entry_point.py create mode 100644 gotify_tray/__main__.py create mode 100644 gotify_tray/gui/designs/__init__.py create mode 100644 gotify_tray/gui/images/__init__.py create mode 100644 setup.py diff --git a/.gitignore b/.gitignore index 93f3b55..307fb99 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .idea .vscode __pycache__ +*.egg-info build dist inno-output diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..f0eddcc --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,3 @@ +include README.md version.txt +include gotifytray/gui/images/*.png +include gotifytray/gui/images/*.svg diff --git a/README.md b/README.md index 7283662..18c2eaa 100644 --- a/README.md +++ b/README.md @@ -34,9 +34,26 @@ $ pip install -r requirements.txt ### Run from source ``` -$ python entry_point.py +$ python -m gotify_tray ``` +### Create and install a pip package + +- Create the pip package: + ``` + $ python -m build + ``` + +- Install the pip package: + ``` + $ pip install dist/gotify_tray-0.1.3-py3-none-any.whl + ``` + +- Launch: + ``` + $ gotify-tray + ``` + ### Create a pyinstaller executable ``` @@ -45,6 +62,13 @@ $ pyinstaller gotify-tray.spec ``` An executable is created at `dist/gotify-tray/`. +### Inno setup (Windows) + +Create an installer for windows with inno setup from pyinstaller output: + +``` +$ iscc gotify-tray.iss +``` ### Create a deb package @@ -56,15 +80,6 @@ $ make build $ sudo make install ``` -### (Inno setup (Windows)) - -Create an installer for windows with inno setup: - -``` -$ iscc gotify-tray.iss -``` - - ## Images Windows 10 | KDE @@ -75,7 +90,7 @@ Windows 10 | KDE ## Requirements -- python 3.9 +- python >=3.9 - PyQt6 - requests - websocket-client diff --git a/entry_point.py b/entry_point.py deleted file mode 100644 index 8881836..0000000 --- a/entry_point.py +++ /dev/null @@ -1,5 +0,0 @@ -from gotify_tray import start_gui - - -if __name__ == "__main__": - start_gui() diff --git a/gotify-tray.spec b/gotify-tray.spec index e51b539..fd27d06 100644 --- a/gotify-tray.spec +++ b/gotify-tray.spec @@ -2,7 +2,7 @@ block_cipher = None -a = Analysis(['entry_point.py'], +a = Analysis(['gotify_tray/__main__.py'], pathex=[os.getcwd()], binaries=[], datas=[('gotify_tray/gui/images', 'gotify_tray/gui/images')], diff --git a/gotify_tray/__main__.py b/gotify_tray/__main__.py new file mode 100644 index 0000000..e9ca9da --- /dev/null +++ b/gotify_tray/__main__.py @@ -0,0 +1,3 @@ +from gotify_tray.gui import start_gui + +start_gui() diff --git a/gotify_tray/gui/designs/__init__.py b/gotify_tray/gui/designs/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/gotify_tray/gui/images/__init__.py b/gotify_tray/gui/images/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..9340870 --- /dev/null +++ b/setup.py @@ -0,0 +1,87 @@ +import io +import os + +from setuptools import find_packages, setup + + +# Package meta-data. +NAME = 'gotify-tray' +DESCRIPTION = 'A tray notification application for receiving messages from a Gotify server.' +URL = 'https://github.com/seird/gotify-tray' +EMAIL = "k.dries@protonmail.com" +REQUIRES_PYTHON = '>=3.9.0' +with open("version.txt", "r") as f: + VERSION = f.read() + +# What packages are required for this module to be executed? +REQUIRED = [ + 'requests', 'PyQt6', 'websocket-client' +] + +# What packages are optional? +EXTRAS = { + # 'socks5 proxy': ['pysocks'], +} + +# The rest you shouldn't have to touch too much :) +# ------------------------------------------------ +# Except, perhaps the License and Trove Classifiers! +# If you do change the License, remember to change the Trove Classifier for that! + +here = os.path.abspath(os.path.dirname(__file__)) + +# Import the README and use it as the long-description. +# Note: this will only work if 'README.md' is present in your MANIFEST.in file! +try: + with io.open(os.path.join(here, 'README.md'), encoding='utf-8') as f: + long_description = '\n' + f.read() +except FileNotFoundError: + long_description = DESCRIPTION + +# Load the package's __version__.py module as a dictionary. +about = {} +if not VERSION: + project_slug = NAME.lower().replace("-", "_").replace(" ", "_") + with open(os.path.join(here, project_slug, '__version__.py')) as f: + exec(f.read(), about) +else: + about['__version__'] = VERSION + + +# Where the magic happens: +setup( + name=NAME, + version=about['__version__'], + description=DESCRIPTION, + long_description=long_description, + long_description_content_type='text/markdown', + author=EMAIL, + author_email=EMAIL, + python_requires=REQUIRES_PYTHON, + url=URL, + # packages=find_packages(exclude=["tests", "*.tests", "*.tests.*", "tests.*"]), + # If your package is a single module, use this instead of 'packages': + packages=find_packages(), + package_data={ + 'gotify_tray.gui.images': ['*.svg', '*.png'] + }, + data_files = [ + ], + + entry_points={ + 'console_scripts': ['gotify-tray=gotify_tray:start_gui'], + }, + install_requires=REQUIRED, + extras_require=EXTRAS, + include_package_data=True, + license='GPLv3', + classifiers=[ + # Trove classifiers + # Full list: https://pypi.python.org/pypi?%3Aaction=list_classifiers + 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10' + ] +)