From 53508224a8bf4f0dcc586143e2cab5af31392d0b Mon Sep 17 00:00:00 2001 From: Chris Pattison Date: Thu, 6 Aug 2020 17:14:42 -0700 Subject: [PATCH 1/6] Basic packaging --- rmview/__init__.py | 0 rmview/__main__.py | 8 ++++++++ {src => rmview}/connection.py | 0 {src => rmview}/rfb.py | 0 {src => rmview}/rmparams.py | 0 {src => rmview}/rmview.py | 10 +++++----- {src => rmview}/viewer.py | 0 {src => rmview}/workers.py | 4 ++-- setup.py | 7 +++++++ 9 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 rmview/__init__.py create mode 100644 rmview/__main__.py rename {src => rmview}/connection.py (100%) rename {src => rmview}/rfb.py (100%) rename {src => rmview}/rmparams.py (100%) rename {src => rmview}/rmview.py (98%) rename {src => rmview}/viewer.py (100%) rename {src => rmview}/workers.py (99%) create mode 100644 setup.py diff --git a/rmview/__init__.py b/rmview/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/rmview/__main__.py b/rmview/__main__.py new file mode 100644 index 0000000..3a3d519 --- /dev/null +++ b/rmview/__main__.py @@ -0,0 +1,8 @@ +from .rmview import * + +if __name__ == '__main__': + log.setLevel(logging.INFO) + QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling) + ecode = rMViewApp(sys.argv).exec_() + print('\nBye!') + sys.exit(ecode) diff --git a/src/connection.py b/rmview/connection.py similarity index 100% rename from src/connection.py rename to rmview/connection.py diff --git a/src/rfb.py b/rmview/rfb.py similarity index 100% rename from src/rfb.py rename to rmview/rfb.py diff --git a/src/rmparams.py b/rmview/rmparams.py similarity index 100% rename from src/rmparams.py rename to rmview/rmparams.py diff --git a/src/rmview.py b/rmview/rmview.py similarity index 98% rename from src/rmview.py rename to rmview/rmview.py index 78877a8..b14ea77 100644 --- a/src/rmview.py +++ b/rmview/rmview.py @@ -2,12 +2,12 @@ from PyQt5.QtGui import * from PyQt5.QtWidgets import * from PyQt5.QtCore import * -import resources -from workers import FrameBufferWorker, PointerWorker -from connection import rMConnect -from viewer import QtImageViewer +from . import resources +from .workers import FrameBufferWorker, PointerWorker +from .connection import rMConnect +from .viewer import QtImageViewer -from rmparams import * +from .rmparams import * import sys import os diff --git a/src/viewer.py b/rmview/viewer.py similarity index 100% rename from src/viewer.py rename to rmview/viewer.py diff --git a/src/workers.py b/rmview/workers.py similarity index 99% rename from src/workers.py rename to rmview/workers.py index 42f866e..1c2c630 100644 --- a/src/workers.py +++ b/rmview/workers.py @@ -2,7 +2,7 @@ from PyQt5.QtGui import * from PyQt5.QtWidgets import * from PyQt5.QtCore import * -from rmparams import * +from .rmparams import * import paramiko import struct @@ -17,7 +17,7 @@ from twisted.internet.protocol import Protocol from twisted.internet import protocol, reactor from twisted.application import internet, service -from rfb import * +from .rfb import * try: IMG_FORMAT = QImage.Format_Grayscale16 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..1e712b1 --- /dev/null +++ b/setup.py @@ -0,0 +1,7 @@ +from setuptools import setup, find_packages + +setup( + name='rmview', + packages=['rmview'], + install_requires=['pyqt5', 'paramiko', 'twisted'] +) From 413b055503419e3267f903e40495fb621d936c19 Mon Sep 17 00:00:00 2001 From: Chris Pattison Date: Thu, 6 Aug 2020 17:32:26 -0700 Subject: [PATCH 2/6] Entry point --- rmview/__main__.py | 6 +----- rmview/rmview.py | 5 ++++- setup.py | 9 ++++++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/rmview/__main__.py b/rmview/__main__.py index 3a3d519..ff75ebb 100644 --- a/rmview/__main__.py +++ b/rmview/__main__.py @@ -1,8 +1,4 @@ from .rmview import * if __name__ == '__main__': - log.setLevel(logging.INFO) - QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling) - ecode = rMViewApp(sys.argv).exec_() - print('\nBye!') - sys.exit(ecode) + rmViewMain() \ No newline at end of file diff --git a/rmview/rmview.py b/rmview/rmview.py index b14ea77..3ea42f4 100644 --- a/rmview/rmview.py +++ b/rmview/rmview.py @@ -262,9 +262,12 @@ class rMViewApp(QApplication): QMessageBox.critical(self.viewer, "Error", 'Please check your reMarkable is properly configured, see the documentation for instructions.\n\n%s' % e) self.quit() -if __name__ == '__main__': +def rmViewMain(): log.setLevel(logging.INFO) QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling) ecode = rMViewApp(sys.argv).exec_() print('\nBye!') sys.exit(ecode) + +if __name__ == '__main__': + rmViewMain() diff --git a/setup.py b/setup.py index 1e712b1..cd44e48 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,10 @@ from setuptools import setup, find_packages setup( - name='rmview', - packages=['rmview'], - install_requires=['pyqt5', 'paramiko', 'twisted'] + name='rmview', + packages=['rmview'], + install_requires=['pyqt5', 'paramiko', 'twisted'], + entry_points={ + 'console_scripts':['rmview = rmview.rmview:rmViewMain'] + } ) From 5d3d87da3bd7cae2d0a0f007b434ee0e249cb956 Mon Sep 17 00:00:00 2001 From: Chris Pattison Date: Thu, 6 Aug 2020 17:40:29 -0700 Subject: [PATCH 3/6] package info --- setup.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/setup.py b/setup.py index cd44e48..6aa76f0 100644 --- a/setup.py +++ b/setup.py @@ -2,6 +2,14 @@ from setuptools import setup, find_packages setup( name='rmview', + version='0.1', + url='https://github.com/bordaigorl/rmview', + description='rMview: a fast live viewer for reMarkable', + author='bordaigorl', + author_email='emanuele.dosualdo@gmail.com', + classifiers=[ + 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)', + ], packages=['rmview'], install_requires=['pyqt5', 'paramiko', 'twisted'], entry_points={ From 6ccc6575d42838545c4a3c1bb4aaa284123bbe7e Mon Sep 17 00:00:00 2001 From: Chris Pattison Date: Thu, 6 Aug 2020 17:46:01 -0700 Subject: [PATCH 4/6] /src layout --- setup.cfg | 7 +++++++ {rmview => src/rmview}/__init__.py | 0 {rmview => src/rmview}/__main__.py | 0 {rmview => src/rmview}/connection.py | 0 {rmview => src/rmview}/rfb.py | 0 {rmview => src/rmview}/rmparams.py | 0 {rmview => src/rmview}/rmview.py | 0 {rmview => src/rmview}/viewer.py | 0 {rmview => src/rmview}/workers.py | 0 9 files changed, 7 insertions(+) create mode 100644 setup.cfg rename {rmview => src/rmview}/__init__.py (100%) rename {rmview => src/rmview}/__main__.py (100%) rename {rmview => src/rmview}/connection.py (100%) rename {rmview => src/rmview}/rfb.py (100%) rename {rmview => src/rmview}/rmparams.py (100%) rename {rmview => src/rmview}/rmview.py (100%) rename {rmview => src/rmview}/viewer.py (100%) rename {rmview => src/rmview}/workers.py (100%) diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..76abe14 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,7 @@ +[options] +package_dir= + =src +packages=find: + +[options.packages.find] +where=src \ No newline at end of file diff --git a/rmview/__init__.py b/src/rmview/__init__.py similarity index 100% rename from rmview/__init__.py rename to src/rmview/__init__.py diff --git a/rmview/__main__.py b/src/rmview/__main__.py similarity index 100% rename from rmview/__main__.py rename to src/rmview/__main__.py diff --git a/rmview/connection.py b/src/rmview/connection.py similarity index 100% rename from rmview/connection.py rename to src/rmview/connection.py diff --git a/rmview/rfb.py b/src/rmview/rfb.py similarity index 100% rename from rmview/rfb.py rename to src/rmview/rfb.py diff --git a/rmview/rmparams.py b/src/rmview/rmparams.py similarity index 100% rename from rmview/rmparams.py rename to src/rmview/rmparams.py diff --git a/rmview/rmview.py b/src/rmview/rmview.py similarity index 100% rename from rmview/rmview.py rename to src/rmview/rmview.py diff --git a/rmview/viewer.py b/src/rmview/viewer.py similarity index 100% rename from rmview/viewer.py rename to src/rmview/viewer.py diff --git a/rmview/workers.py b/src/rmview/workers.py similarity index 100% rename from rmview/workers.py rename to src/rmview/workers.py From 94de29192a88970767264a58e0a74ff7e91e6e38 Mon Sep 17 00:00:00 2001 From: Chris Pattison Date: Thu, 6 Aug 2020 18:12:14 -0700 Subject: [PATCH 5/6] Codegen resources.py --- setup.py | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 6aa76f0..bf8c88b 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,35 @@ +from setuptools.command.install import install +from setuptools.command.develop import develop +from setuptools.command.egg_info import egg_info + from setuptools import setup, find_packages +import sys + +def genResources(): + from PyQt5.pyrcc_main import main as pyrcc_main + saved_argv = sys.argv + # Use current environment to find pyrcc but use the public interface + sys.argv = ['pyrcc5', '-o', 'src/resources.py', 'resources.qrc'] + pyrcc_main() + sys.argv = saved_argv + +# https://stackoverflow.com/questions/19569557/pip-not-picking-up-a-custom-install-cmdclass +class genResourcesInstall(install): + def run(self): + genResources() + install.run(self) + +class genResourcesDevelop(develop): + def run(self): + genResources() + develop.run(self) + +class genResourcesEggInfo(egg_info): + def run(self): + genResources() + egg_info.run(self) + setup( name='rmview', version='0.1', @@ -13,6 +43,11 @@ setup( packages=['rmview'], install_requires=['pyqt5', 'paramiko', 'twisted'], entry_points={ - 'console_scripts':['rmview = rmview.rmview:rmViewMain'] + 'console_scripts':['rmview = rmview.rmview:rmViewMain'] + }, + cmdclass={ + 'install': genResourcesInstall, + 'develop': genResourcesDevelop, + 'egg_info': genResourcesEggInfo, } ) From b93dc4ca904d76f2cb1ce2b0a0ccc15fef664266 Mon Sep 17 00:00:00 2001 From: Chris Pattison Date: Thu, 6 Aug 2020 18:31:37 -0700 Subject: [PATCH 6/6] Fix codegen --- pyproject.toml | 2 ++ setup.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..2589976 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,2 @@ +[build-system] +requires = ["setuptools", "PyQt5"] diff --git a/setup.py b/setup.py index bf8c88b..1dd772b 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ def genResources(): from PyQt5.pyrcc_main import main as pyrcc_main saved_argv = sys.argv # Use current environment to find pyrcc but use the public interface - sys.argv = ['pyrcc5', '-o', 'src/resources.py', 'resources.qrc'] + sys.argv = ['pyrcc5', '-o', 'src/rmview/resources.py', 'resources.qrc'] pyrcc_main() sys.argv = saved_argv