zocker-160 / keyboard-center

Application for mapping macro keys on Logitech keyboards
GNU General Public License v3.0
66 stars 3 forks source link

Support building from pyproject.toml metadata #69

Closed aurtzy closed 2 weeks ago

aurtzy commented 3 weeks ago

Fixes https://github.com/zocker-160/keyboard-center/issues/67.

This adds support for Python packaging build systems based on PEP 517.

The directory structure is reorganized to follow flat-layout, which is automatically recognized by setuptools: https://setuptools.pypa.io/en/latest/userguide/package_discovery.html#flat-layout

Move main.py to __init__.py and turn its contents into a function that can be called from an entrypoint script.

A MANIFEST.in file is added so keyboard-center assets are included in the expected installation directory.

Use relative imports to import internal Python modules.


I added some basic information to pyproject.toml, but feel free to suggest additions/edits that I can include in this pull request. Python dependencies have been specified in this file, but I'm not sure how to declare dependencies providing .so files like hidapi at the moment (if even possible).

The project.gui-scripts field at the end of pyproject.toml should actually allow for packaging systems to manage this automatically, so I think the starter script that was mentioned in the linked issue could be removed entirely - this may depend on the packaging system used, though.

These changes are not as well tested as I'd like. Guix is still limited to Python 3.10 at the moment unfortunately, so I had some issues on my end testing this and would appreciate feedback on that end since I don't use much of the featureset either.

...on the bright side, this means I also have working (and perhaps slightly more tested) changes for v1 that I wouldn't mind backporting as well if there's plans to continue maintenance on it :)

Are there any thoughts on adding documentation for installation/building/development? The Arch Wiki, for example, shows one way of installing that we could include in the README. The best method of installing (python) dependencies for development from pyproject.toml that I know of right now is to do pip install .; pip uninstall keyboard-center - apparently that's still a WIP PEP or something.

zocker-160 commented 3 weeks ago

First of all thank you very much for this. The file conflicts are new because of my changes to fix the config file bug.

Are relative imports required when using this new directory structure?

aurtzy commented 3 weeks ago

No - absolute imports should be valid as well, like import keyboard_center.lib.hid (keyboard_center is now considered the top-level module).

I can change them to absolute if you'd prefer when I rebase these changes.

zocker-160 commented 3 weeks ago

ok good, you can leave it as is relative imports are fine for now, but I do prefer absolute imports, because I then can reorganize modules without having to update all the imports again.

zocker-160 commented 2 weeks ago

thank you very much for this, very appreciated!

zocker-160 commented 2 weeks ago

ah and to answer your questions: