From 315556640817010d433a02311d1ba45c05872cc5 Mon Sep 17 00:00:00 2001 From: Max Stabel Date: Thu, 9 Feb 2023 19:43:09 +0100 Subject: [PATCH] Migrate from setuptools to hatch --- .github/workflows/windows-binary.yml | 3 + README.md | 64 +++++++------- hatch_build.py | 11 +++ pyproject.toml | 120 ++++++++++++++++++++++++++- setup.cfg | 10 --- setup.py | 54 ------------ src/rmview/__about__.py | 1 + 7 files changed, 170 insertions(+), 93 deletions(-) create mode 100644 hatch_build.py delete mode 100644 setup.cfg delete mode 100644 setup.py create mode 100644 src/rmview/__about__.py diff --git a/.github/workflows/windows-binary.yml b/.github/workflows/windows-binary.yml index fcb4ba0..b348753 100644 --- a/.github/workflows/windows-binary.yml +++ b/.github/workflows/windows-binary.yml @@ -1,5 +1,8 @@ name: Windows Binary Package +permissions: + contents: write + on: push: tags: diff --git a/README.md b/README.md index 213abe0..7369232 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,14 @@ [![Demo](https://raw.githubusercontent.com/bordaigorl/rmview/vnc/screenshot.png)][demo] +
+ +| | | +| ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| CI/CD | [![CD - Build Windows](https://github.com/bordaigorl/rmview/actions/workflows/windows-binary.yml/badge.svg)](https://github.com/bordaigorl/rmview/actions/workflows/windows-binary.yml) | +| Meta | [![Hatch project](https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg)](https://github.com/pypa/hatch) [![linting - Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v0.json)](https://github.com/charliermarsh/ruff) [![code style - Black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) [![types - Mypy](https://img.shields.io/badge/types-Mypy-blue.svg)](https://github.com/python/mypy) [![License - GPL-3.0-only](https://img.shields.io/badge/license-GPL-9400d3.svg)](https://spdx.org/licenses/GPL-3.0-only.html) | + +
## Features @@ -18,10 +26,10 @@ ## Compatibility -| | ScreenShare | VNC Server | rm2fb | -| -------------- | :----------------: | :----------------: | :----------------: | -| RM1/2 < v2.9 | :x: | :white_check_mark: | :white_check_mark: | -| RM1/2 >= v2.9 | :white_check_mark: | :x: | :x: | +| | ScreenShare | VNC Server | rm2fb | +| ------------- | :----------------: | :----------------: | :----------------: | +| RM1/2 < v2.9 | :x: | :white_check_mark: | :white_check_mark: | +| RM1/2 >= v2.9 | :white_check_mark: | :x: | :x: | > :warning: **Update 2.9+ users** :warning:: @@ -101,19 +109,19 @@ The supported configuration settings are below. Look in file `example.json` for an example configuration. All the settings are optional. -| Setting key | Values | Default | -| ------------------------ | ------------------------------------------------------- | ------------- | -| `ssh` | Connection parameters (see below) | `{}` | -| `backend` | `"auto"`, `"screenshare"`, `"vncserver"` | `"auto"` | -| `orientation` | `"landscape"`, `"portrait"`, `"auto"` | `"landscape"` | -| `pen_size` | diameter of pointer in px | `15` | -| `pen_color` | color of pointer and trail | `"red"` | -| `pen_trail` | persistence of trail in ms | `200` | -| `background_color` | color of window | `"white"` | -| `invert_colors` | if true, start the tablet with inverted colors | `false` | -| `hide_pen_on_press` | if true, the pointer is hidden while writing | `true` | -| `show_pen_on_lift` | if true, the pointer is shown when lifting the pen | `true` | -| `forward_mouse_events` | Send mouse events to tablet (see below) | `false` | +| Setting key | Values | Default | +| ---------------------- | -------------------------------------------------- | ------------- | +| `ssh` | Connection parameters (see below) | `{}` | +| `backend` | `"auto"`, `"screenshare"`, `"vncserver"` | `"auto"` | +| `orientation` | `"landscape"`, `"portrait"`, `"auto"` | `"landscape"` | +| `pen_size` | diameter of pointer in px | `15` | +| `pen_color` | color of pointer and trail | `"red"` | +| `pen_trail` | persistence of trail in ms | `200` | +| `background_color` | color of window | `"white"` | +| `invert_colors` | if true, start the tablet with inverted colors | `false` | +| `hide_pen_on_press` | if true, the pointer is hidden while writing | `true` | +| `show_pen_on_lift` | if true, the pointer is shown when lifting the pen | `true` | +| `forward_mouse_events` | Send mouse events to tablet (see below) | `false` | **PLEASE NOTE:** When `backend` is `auto`, if the tablet is using version 2.9 and above then `screenshare` is used; @@ -129,17 +137,17 @@ This option is only available if using `"backend": "vncserver"`, which in turn i Connection parameters are provided as a dictionary with the following keys (all optional): -| Parameter | Values | Comments | -| ----------------- | ------------------------------------------------------- | ------------------------------------- | -| `address` | IP of remarkable | tool prompts for it if missing | -| `auth_method` | Either `"password"` or `"key"` | defaults to password if key not given | -| `username` | Username for ssh access on reMarkable | default: `"root"` | -| `password` | Password provided by reMarkable | not needed if key provided | -| `key` | Local path to key for ssh | not needed if password provided | -| `timeout` | Connection timeout in seconds | default: 1 | -| `host_key_policy` | `"ask"`, `"ignore_new"`, `"ignore_all"`, `"auto_add"` | default: `"ask"` (description below) | -| `tunnel` | True to connect to VNC server over a local SSH tunnel | default: `false` (description below) | -| `tunnel_compression` | True to enable compression for SSH tunnel | default: `false` (description below) | +| Parameter | Values | Comments | +| -------------------- | ----------------------------------------------------- | ------------------------------------- | +| `address` | IP of remarkable | tool prompts for it if missing | +| `auth_method` | Either `"password"` or `"key"` | defaults to password if key not given | +| `username` | Username for ssh access on reMarkable | default: `"root"` | +| `password` | Password provided by reMarkable | not needed if key provided | +| `key` | Local path to key for ssh | not needed if password provided | +| `timeout` | Connection timeout in seconds | default: 1 | +| `host_key_policy` | `"ask"`, `"ignore_new"`, `"ignore_all"`, `"auto_add"` | default: `"ask"` (description below) | +| `tunnel` | True to connect to VNC server over a local SSH tunnel | default: `false` (description below) | +| `tunnel_compression` | True to enable compression for SSH tunnel | default: `false` (description below) | The `address` parameter can be either: - a single string, in which case the address is used for connection diff --git a/hatch_build.py b/hatch_build.py new file mode 100644 index 0000000..602a751 --- /dev/null +++ b/hatch_build.py @@ -0,0 +1,11 @@ +from hatchling.builders.hooks.plugin.interface import BuildHookInterface +from PyQt5 import pyrcc_main as pyrcc + + +class CustomHook(BuildHookInterface): + def initialize(self, version, build_data): + pyrcc.processResourceFile( + filenamesIn=["resources.qrc"], + filenameOut="src/rmview/resources.py", + listFiles=False, + ) diff --git a/pyproject.toml b/pyproject.toml index 713930e..ce78b53 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,2 +1,120 @@ [build-system] -requires = ["setuptools", "wheel", "PyQt5"] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "rmview" +description = "rMview: a fast live viewer for reMarkable" +readme = "README.md" +license = "GPL-3.0-only" +requires-python = ">=3.8" +authors = [ + { name = "bordaigorl", email = "emanuele.dosualdo@gmail.com" }, +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: End Users/Desktop", + "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", + "Framework :: Hatch", + "Framework :: Twisted", + "Operating System :: Microsoft :: Windows", + "Operating System :: MacOS", + "Operating System :: Unix", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Topic :: System :: Hardware", + "Topic :: Utilities", + +] +keywords = [ + "reMarkable", + "reMarkable-tablet", + "pyqt5", + "vnc", + "stream", + "mirror", + "ssh", +] +dependencies = [ + "paramiko", + "pyjwt", + "pyqt5", + "twisted[tls]", +] +dynamic = ["version"] + +[project.optional-dependencies] +tunnel = [ + "sshtunnel", +] + +[project.urls] +Source = "https://github.com/bordaigorl/rmview" +Tracker = "https://github.com/bordaigorl/rmview/issues" +Discussions = "https://github.com/bordaigorl/rmview/discussions" +Demo = "https://www.reddit.com/r/RemarkableTablet/comments/gtjrqt/rmview_now_with_support_for_vnc/" + +[project.gui-scripts] +rmview = "rmview.rmview:rmViewMain" + +[tool.hatch.version] +path = "src/rmview/__about__.py" + +[tool.hatch.envs.default] +path=".venv" +dependencies = [ + "black", + "ruff", + "mypy", + "coverage[toml]", + "pytest", + "pytest-cov", + "pytest-xdist", +] + +[tool.hatch.build] +artifacts = [ + "src/rmview/resources.py" # Generated by custom build hook below +] + +[tool.hatch.build.hooks.custom] +dependencies = ["pyqt5"] + +[tool.hatch.build.targets.sdist] +exclude = ["/.github"] + +[tool.hatch.build.targets.wheel] +packages = ["src/rmview"] + +[tool.pytest.ini_options] +addopts="-n4 --cov" + +[tool.ruff] +line-length = 120 +select = [ + "A", + "B", + "C", + "DTZ", + "E", + "EM", + "F", + "FBT", + "I", + "ICN", + "ISC", + "N", + "PLC", + "PLE", + "PLR", + "PLW", + "Q", + "RUF", + "S", + "SIM", + "T", + "TID", + "UP", + "W", + "YTT", +] \ No newline at end of file diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 8440f46..0000000 --- a/setup.cfg +++ /dev/null @@ -1,10 +0,0 @@ -[pycodestyle] -max-line-length = 88 - -[options] -package_dir= - =src -packages=find: - -[options.packages.find] -where=src diff --git a/setup.py b/setup.py deleted file mode 100644 index 3b0df23..0000000 --- a/setup.py +++ /dev/null @@ -1,54 +0,0 @@ -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/rmview/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='3.0', - 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', 'rmview.screenstream'], - install_requires=['pyqt5', 'paramiko', 'twisted[tls]', 'pyjwt'], - extras_require = { 'tunnel': ['sshtunnel'] }, - entry_points={ - 'console_scripts':['rmview = rmview.rmview:rmViewMain'] - }, - cmdclass={ - 'install': genResourcesInstall, - 'develop': genResourcesDevelop, - 'egg_info': genResourcesEggInfo, - } -) diff --git a/src/rmview/__about__.py b/src/rmview/__about__.py new file mode 100644 index 0000000..f749372 --- /dev/null +++ b/src/rmview/__about__.py @@ -0,0 +1 @@ +__version__ = "3.1.3"