Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert klippy to a python package #371

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

kageurufu
Copy link
Contributor

  1. Fix all imports within klippy to be relative, or absolute klippy.mod

  2. For compatibility with external extras that will probably still use the old import names (e.g. a bare import stepper instead of from klippy import stepper), klippy/compat.py hot patches sys.modules before starting the Printer reactor. Any module currently in sys.modules under the klippy. package namespace are inserted a second time with the leading namespace stripped.

    • To keep compatibility with klippy.xxx being used, klippy/__init__.py does from klippy.printer import *, ensuring all legacy values exist
  3. For compatibility with running python klippy/klippy.py (every current printer's systemd service, as well as any KIAUH install), a shim klippy/klippy.py is in place that patches sys.path before importing and calling klippy.printer.main()

Checklist

  • pr title makes sense
  • squashed to 1 commit
  • added a test case if possible
    • the existing ci-build.sh verifies python klippy/klippy.py still works, and scripts/test-klippy.py uses the new python -m klippy
  • if new feature, added to the readme
  • ci is happy and green

@kageurufu kageurufu force-pushed the python_package branch 2 times, most recently from e7d2f18 to a270fa4 Compare September 24, 2024 23:20
@kageurufu kageurufu marked this pull request as ready for review September 24, 2024 23:20
@kageurufu kageurufu requested a review from a team as a code owner September 24, 2024 23:20
@kageurufu
Copy link
Contributor Author

I feel like this works, its ready.

We need to validate more extras than just Beacon and Shaketune, but those work.

Franklyn Tackitt added 4 commits October 21, 2024 09:48
1. Fix all imports within klippy to be relative, or absolute klippy.mod

2. For compatibility with external `extras` that will probably still use
   the old import names (e.g. a bare `import stepper` instead of
   `from klippy import stepper`), klippy/compat.py hot patches
   `sys.modules` before starting the Printer reactor. Any module
   currently in `sys.modules` under the `klippy.` package namespace
   are inserted a second time with the leading namespace stripped.

   * To keep compatibility with `klippy.xxx` being used,
     `klippy/__init__.py` does `from klippy.printer import *`, ensuring
     all legacy values exist

3. For compatibility with running `python klippy/klippy.py` (every
   current printer's systemd service, as well as any KIAUH install),
   a shim `klippy/klippy.py` is in place that patches `sys.path` before
   importing and calling `klippy.printer.main()`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant