Skip to content

Move commandline interface to typer #2751

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Move commandline interface to typer #2751

wants to merge 1 commit into from

Conversation

schaefi
Copy link
Collaborator

@schaefi schaefi commented Mar 19, 2025

This commit moves the kiwi commandline and plugin interface to typer and drops the use of docopt. Typer is based on python type hints and allows for a more modern way to define Cli interfaces and auto completion, even for plugins. Also docopt is split into an old and a next generation variant and allows us to get rid of spec file hacks as well as documentation rendering hacks.

@schaefi schaefi self-assigned this Mar 19, 2025
@schaefi
Copy link
Collaborator Author

schaefi commented Mar 19, 2025

There are still open tasks before we can consider this change to go in

  • stackbuild plugin needs cli.py: TBD by @schaefi
  • box plugin needs cli.py: TBD by @schaefi
  • is python-typer package available in all distros ?

@schaefi schaefi force-pushed the move_to_typer branch 5 times, most recently from ace7dab to fb35cbd Compare March 19, 2025 15:23
@schaefi
Copy link
Collaborator Author

schaefi commented Mar 19, 2025

@Conan-Kudo I'm mostly interested in getting the open questions from the checklist answered, so no need to do an in-depth review of the code changes as it's time consuming. Thanks much

@schaefi schaefi requested a review from Conan-Kudo March 19, 2025 15:29
schaefi added a commit to OSInside/kiwi-boxed-plugin that referenced this pull request Mar 19, 2025
In addition to docopt also support the typer
commandline interface. This is relevant for
kiwi versions that has moved to typer.
OSInside/kiwi#2751
schaefi added a commit to OSInside/kiwi-boxed-plugin that referenced this pull request Mar 19, 2025
In addition to docopt also support the typer
commandline interface. This is relevant for
kiwi versions that has moved to typer.
OSInside/kiwi#2751
schaefi added a commit to OSInside/kiwi-boxed-plugin that referenced this pull request Mar 19, 2025
In addition to docopt also support the typer
commandline interface. This is relevant for
kiwi versions that has moved to typer.
OSInside/kiwi#2751
schaefi added a commit to OSInside/kiwi-boxed-plugin that referenced this pull request Mar 19, 2025
In addition to docopt also support the typer
commandline interface. This is relevant for
kiwi versions that has moved to typer.
OSInside/kiwi#2751
schaefi added a commit to OSInside/kiwi-boxed-plugin that referenced this pull request Mar 20, 2025
In addition to docopt also support the typer
commandline interface. This is relevant for
kiwi versions that has moved to typer.
OSInside/kiwi#2751
schaefi added a commit to OSInside/kiwi-boxed-plugin that referenced this pull request Mar 20, 2025
In addition to docopt also support the typer
commandline interface. This is relevant for
kiwi versions that has moved to typer.
OSInside/kiwi#2751
@Conan-Kudo
Copy link
Member

We can't drop Python 3.9 support since that's required for CentOS/RHEL 9.

@schaefi
Copy link
Collaborator Author

schaefi commented Mar 20, 2025

We can't drop Python 3.9 support since that's required for CentOS/RHEL 9.

I found a fix to make it work on 3.9 too

schaefi added a commit to OSInside/kiwi-boxed-plugin that referenced this pull request Mar 20, 2025
In addition to docopt also support the typer
commandline interface. This is relevant for
kiwi versions that has moved to typer.
OSInside/kiwi#2751
schaefi added a commit to OSInside/kiwi-boxed-plugin that referenced this pull request Mar 20, 2025
In addition to docopt also support the typer
commandline interface. This is relevant for
kiwi versions that has moved to typer.
OSInside/kiwi#2751
schaefi added a commit to OSInside/kiwi-stackbuild-plugin that referenced this pull request Mar 20, 2025
In addition to docopt also support the typer
commandline interface. This is relevant for
kiwi versions that has moved to typer.
OSInside/kiwi#2751
schaefi added a commit to OSInside/kiwi-stackbuild-plugin that referenced this pull request Mar 20, 2025
In addition to docopt also support the typer
commandline interface. This is relevant for
kiwi versions that has moved to typer.
OSInside/kiwi#2751
schaefi added a commit to OSInside/kiwi-stackbuild-plugin that referenced this pull request Mar 20, 2025
In addition to docopt also support the typer
commandline interface. This is relevant for
kiwi versions that has moved to typer.
OSInside/kiwi#2751
schaefi added a commit to OSInside/kiwi-stackbuild-plugin that referenced this pull request Mar 20, 2025
In addition to docopt also support the typer
commandline interface. This is relevant for
kiwi versions that has moved to typer.
OSInside/kiwi#2751
@schaefi
Copy link
Collaborator Author

schaefi commented Mar 20, 2025

@Conan-Kudo I finished the Cli change and also updated the plugins. The plugins continues to support both docopt and typer such that they can continue to work also with older versions of kiwi. The upstream kiwi should change to typer and the interface is a drop-in-replacement such that there should be no difference in the former caller semantic.

The only open question is if the typer python module is available in all distros we support. I did a short test on Virtualization:Appliances:Staging/python-kiwi and it would build the package for all targets that exists there except for ALP which is an issue that I need to resolve prior merge

Also I appreciate your feedback with regards to the other OS'es

Thanks

@schaefi
Copy link
Collaborator Author

schaefi commented Mar 20, 2025

And there is also the question on the min version of typer in the pyproject.toml to be ok or not

@schaefi
Copy link
Collaborator Author

schaefi commented Mar 21, 2025

I'll give it a test on Staging

schaefi added a commit to OSInside/kiwi-boxed-plugin that referenced this pull request Mar 21, 2025
In addition to docopt also support the typer
commandline interface. This is relevant for
kiwi versions that has moved to typer.
OSInside/kiwi#2751
schaefi added a commit to OSInside/kiwi-stackbuild-plugin that referenced this pull request Mar 21, 2025
In addition to docopt also support the typer
commandline interface. This is relevant for
kiwi versions that has moved to typer.
OSInside/kiwi#2751
@schaefi
Copy link
Collaborator Author

schaefi commented Mar 21, 2025

I'll give it a test on Staging

ok some results here.

  1. ALP needs typer, it doesn't exist there. I built the package from TW for ALP, no problems just works
  2. The typer version 0.7.0 which is used on Debian 12 and others is too old and too bugy. I added patches to make it run but it produces wrong output and has a lot of issues which are also reported on the typer git. The minimum version of typer that works and is available is 0.9.0. I added that version as a minimum requirement for now. This leads to the following targets on Staging not building
xUbuntu_23.04_x86_64  x86_64     python-kiwi      unresolvable*
xUbuntu_23.04_aarch64 aarch64    python-kiwi      unresolvable*
Fedora_38             aarch64    python-kiwi      unresolvable*
Fedora_38             x86_64     python-kiwi      unresolvable*
Debian_12_x86_64      x86_64     python-kiwi      unresolvable*
Debian_12_aarch64     aarch64    python-kiwi      unresolvable*

How can we go from there ? Or does that mean we leave this PR open until our OS Matrix allows the move smoothly ?

@schaefi
Copy link
Collaborator Author

schaefi commented Mar 21, 2025

I also figured typer 0.9.0 only works for python version < 3.8 because it imports typing_extensions which no longer exists starting with py3.8. This is especially a problem for Leap who added the python 3.11 stack and we only provide kiwi for Leap for 3.11 (the other python version there is 3.6 which is too old for kiwi v10.x.x) So typer 0.9.0 doesn't play with python 3.11 but fortunately the backports project offers the latest typer, so I don't see an issue here

@schaefi
Copy link
Collaborator Author

schaefi commented Mar 21, 2025

Overall such a change is a pita but I had hoped with the kiwi v10.x.x constraints it could be done... maybe a mistake ?

schaefi added a commit to OSInside/kiwi-stackbuild-plugin that referenced this pull request Mar 21, 2025
In addition to docopt also support the typer
commandline interface. This is relevant for
kiwi versions that has moved to typer.
OSInside/kiwi#2751
schaefi added a commit to OSInside/kiwi-boxed-plugin that referenced this pull request Mar 21, 2025
In addition to docopt also support the typer
commandline interface. This is relevant for
kiwi versions that has moved to typer.
OSInside/kiwi#2751
@Conan-Kudo
Copy link
Member

We could consider this for kiwi 11 and decide we do a kiwi 11 next year?

schaefi added a commit to OSInside/kiwi-boxed-plugin that referenced this pull request Mar 22, 2025
In addition to docopt also support the typer
commandline interface. This is relevant for
kiwi versions that has moved to typer.
OSInside/kiwi#2751
schaefi added a commit to OSInside/kiwi-stackbuild-plugin that referenced this pull request Mar 22, 2025
In addition to docopt also support the typer
commandline interface. This is relevant for
kiwi versions that has moved to typer.
OSInside/kiwi#2751
@schaefi
Copy link
Collaborator Author

schaefi commented Mar 22, 2025

We could consider this for kiwi 11 and decide we do a kiwi 11 next year?

ok, I did that on this PR and the plugin PRs. btw are Fedora 38 and xUbuntu_23.04 still supported targets ?

@Conan-Kudo
Copy link
Member

No. Our minimum for Fedora is currently Fedora 40. And Ubuntu is at 24.04.

schaefi added a commit that referenced this pull request Mar 24, 2025
Even though we will add support for the typer Cli with kiwi-11
I want our integration test images to be able to build with the
open PR #2751. Debian 12 is the only target in the support matrix
which uses a too old veryion of typer. Therefore to be able to
test this target I built a newer version of typer in an update
repo for Debian 12 and added it to the integration test
description
@schaefi
Copy link
Collaborator Author

schaefi commented Mar 24, 2025

No. Our minimum for Fedora is currently Fedora 40. And Ubuntu is at 24.04.

ok I dropped those. For the Debian 12 part I added an updated typer to the Staging project which allows me to finally run all integration tests with a changed kiwi that contains this new cli interface. All tests built which is good.

So I will keep this and the plugin PRs open with a kiwi-11 label set to be merged in 2026

@schaefi schaefi requested a review from Conan-Kudo March 24, 2025 08:58
@schaefi schaefi removed the blocked label Mar 24, 2025
@Conan-Kudo Conan-Kudo marked this pull request as draft March 25, 2025 10:54
@schaefi schaefi force-pushed the move_to_typer branch 2 times, most recently from 6ca82a6 to ea0e919 Compare March 25, 2025 11:24
This commit moves the kiwi commandline and plugin interface
to typer and drops the use of docopt. Typer is based on python
type hints and allows for a more modern way to define Cli
interfaces and auto completion, even for plugins. Also docopt
is split into an old and a next generation variant and allows
us to get rid of spec file hacks as well as documentation
rendering hacks.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants