Skip to content

Commit

Permalink
python3: Package with pyproject/hatch
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Schaefer <[email protected]>
  • Loading branch information
JohnAZoidberg committed Nov 17, 2023
1 parent 5c62a33 commit 067f507
Show file tree
Hide file tree
Showing 10 changed files with 111 additions and 9 deletions.
15 changes: 14 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,20 @@ jobs:
uses: JohnAZoidberg/pyinstaller-action@dont-clean
with:
python_ver: '3.11'
spec: qmk_gui.py
spec: python/qmk_hid/gui.py
requirements: 'requirements.txt'
upload_exe_with_name: 'qmk_gui.exe'
options: --onefile, --name "qmk_gui", --windowed, --add-data "releases;releases" --icon=res/logo_cropped_transparent_keyboard_48x48.ico --add-data 'res;res'

package-python:
name: Package Python
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3

- run: |
cd python
python3 -m pip install --upgrade build
python3 -m pip install --upgrade hatch
python3 -m pip install --upgrade twine
python3 -m build
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
target/

# Python
__pycache__
venv/

# pyinstaller
qmk_gui.spec
build/
dist/

# Hatch
_version.py
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Tested to work on Windows and Linux, without any drivers or admin privileges.
###### GUI

There is also an easy to use GUI tool that does not require commandline interaction.
On Linux install Python requirements via `python3 -m install -r requirements.txt` and run `qmk_gui.py`.
On Windows download the `qmk_gui.exe` and run it.

See [GUI README](python/README.md)

## Running

Expand Down
14 changes: 14 additions & 0 deletions python/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Python

## Installing

Pre-requisites: Python with pip

```sh
python3 -m pip install qmk_hid
```

## GUI

On Linux install Python requirements via `python3 -m install -r requirements.txt` and run `qmk_gui.py`.
On Windows download the `qmk_gui.exe` and run it.
70 changes: 70 additions & 0 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
[build-system]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

[project]
name = "qmk_hid"
# TODO: Dynamic version from git (requires tags)
#dynamic = ["version"]
version = "0.1.8"
description = 'A GUI tool to control QMK keyboard, specifically of the Framework Laptop 16'
# TODO: Custom README for python project
readme = "README.md"
requires-python = ">=3.7"
license = { text = "MIT" }
keywords = [
"hatch",
]
authors = [
{ name = "Daniel Schaefer", email = "[email protected]" },
]
classifiers = [
"Development Status :: 4 - Beta",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
]
dependencies = [
"hidapi==0.14.0",
"PySimpleGUI==4.60.5",
"pywin32; os_name == 'nt'",
]

[project.urls]
Issues = "https://github.com/FrameworkComputer/qmk_hid/issues"
Source = "https://github.com/FrameworkComputer/qmk_hid"

# TODO: Figure out how to add a runnable-script
#[project.scripts]
#qmk_hid = "qmk_hid.gui:main_cli"

[project.gui-scripts]
qmk_gui = "qmk_hid.gui:main"

#[tool.hatch.version]
#source = "vcs"
#
#[tool.hatch.build.hooks.vcs]
#version-file = "qmk_hid/_version.py"

[tool.hatch.build.targets.sdist]
exclude = [
"/.github",
]

# TODO: Maybe typing with mypy
# [tool.hatch.build.targets.wheel.hooks.mypyc]
# enable-by-default = false
# dependencies = ["hatch-mypyc>=0.14.1"]
# require-runtime-dependencies = true
# mypy-args = [
# "--no-warn-unused-ignores",
# ]
#
# [tool.mypy]
# disallow_untyped_defs = false
# follow_imports = "normal"
# ignore_missing_imports = true
# pretty = true
# show_column_numbers = true
# warn_no_return = false
# warn_unused_ignores = true
Empty file added python/qmk_hid/__init__.py
Empty file.
Binary file not shown.
10 changes: 5 additions & 5 deletions qmk_gui.py → python/qmk_hid/gui.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,10 @@ def get_numlock_state():
pass


def main(devices):
def main():
devices = find_devs(show=False, verbose=False)
# print("Found {} devices".format(len(devices)))

device_checkboxes = []
for dev in devices:
device_info = "{}\nSerial No: {}\nFW Version: {}\n".format(
Expand Down Expand Up @@ -636,7 +639,4 @@ def flash_firmware(dev, fw_path):


if __name__ == "__main__":
devices = find_devs(show=False, verbose=False)
print("Found {} devices".format(len(devices)))

main(devices)
main()
File renamed without changes.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
hidapi==0.14.0
PySimpleGUI==4.60.5
pywin32
pywin32; sys_platform = 'windows'

0 comments on commit 067f507

Please sign in to comment.