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

[Bug]: exception in list-qt for android target #817

Open
1 task done
BenCrafterRED opened this issue Aug 28, 2024 · 1 comment · May be fixed by #839
Open
1 task done

[Bug]: exception in list-qt for android target #817

BenCrafterRED opened this issue Aug 28, 2024 · 1 comment · May be fixed by #839
Labels
bug Something isn't working triage

Comments

@BenCrafterRED
Copy link

BenCrafterRED commented Aug 28, 2024

Bug description

Run aqt list-qt <TARGET> android. Where <TARGET> is one of linux, mac, windows.

The command crashes without any useful information provided to the user. Other list-* commands seem to work.

Tested in virtual environment and system-wide pip install which both result in the same behavior.

Expected behavior

A list of Qt versions.

aqt and python version

aqtinstall(aqt) v3.1.18 on Python 3.12.3 [CPython GCC 13.2.0]

Operating System

Linux/Unix

Relevant log output

ERROR   : Invalid version string '7'
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/dist-packages/aqt/installer.py", line 182, in run
    args.func(args)
  File "/usr/local/lib/python3.12/dist-packages/aqt/installer.py", line 663, in run_list_qt
    show_list(meta)
  File "/usr/local/lib/python3.12/dist-packages/aqt/metadata.py", line 1005, in show_list
    output = meta.getList()
             ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/aqt/metadata.py", line 620, in getList
    return self._action()
           ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/aqt/metadata.py", line 657, in fetch_versions
    versions = sorted([ver for ver, ext in versions_extensions if ver is not None and filter_by(ver, ext)])
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/aqt/metadata.py", line 784, in folder_to_version_extension
    get_semantic_version(qt_ver=ver, is_preview="preview" in ext),
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/aqt/metadata.py", line 197, in get_semantic_version
    raise ValueError("Invalid version string '{}'".format(qt_ver))
ValueError: Invalid version string '7'
ERROR   : aqtinstall(aqt) v3.1.18 on Python 3.12.3 [CPython GCC 13.2.0]
Working dir: `/home/user`
Arguments: `['/usr/local/bin/aqt', 'list-qt', 'linux', 'android']` Host: `uname_result(system='Linux', node='ubuntumatepc', release='6.8.0-41-generic', version='#41-Ubuntu SMP PREEMPT_DYNAMIC Fri Aug  2 20:41:06 UTC 2024', machine='x86_64')`
===========================PLEASE FILE A BUG REPORT===========================
You have discovered a bug in aqt.
Please file a bug report at https://github.com/miurahr/aqtinstall/issues
Please remember to include a copy of this program's output in your report.

Code of Conduct

  • I agree to follow this project's Code of Conduct
@ddalcino
Copy link
Contributor

ddalcino commented Sep 1, 2024

Looks like the Qt maintainers changed the directory structure, again.

Incomplete listing of directories at https://download.qt.io/online/qtsdkrepository/linux_x64/android/:

  • qt6_600_x86_64/
  • qt6_600_x86/
  • qt6_600_armv7/
  • qt6_600_arm64_v8a
  • qt6_600/
  • qt6_7_3/
  • qt6_7_2/
  • qt6_7_1/
  • qt6_7_0/
  • qt5_51212/
  • qt5_51211/
  • qt5_51210/

Currently, the following code splits up the folder name on _, and the string of digits following qt5 or qt6 is interpreted as the version of Qt. So, 51212 gets split up into 5.12.12 and 600 gets split up into 6.0.0. However, qt6_7_3 gets mangled, because aqt thinks that 7 is the whole version string, when it actually refers to version 6.7.3.

aqtinstall/aqt/metadata.py

Lines 779 to 786 in 73fc45e

def folder_to_version_extension(folder: str) -> Tuple[Optional[Version], str]:
components = folder.split("_", maxsplit=2)
ext = "" if len(components) < 3 else components[2]
ver = "" if len(components) < 2 else components[1]
return (
get_semantic_version(qt_ver=ver, is_preview="preview" in ext),
ext,
)

Also see get_semantic_version_string here:

aqtinstall/aqt/metadata.py

Lines 172 to 197 in 73fc45e

def get_semantic_version(qt_ver: str, is_preview: bool) -> Optional[Version]:
"""Converts a Qt version string (596, 512, 5132, etc) into a semantic version.
This makes a lot of assumptions based on established patterns:
If is_preview is True, the number is interpreted as ver[0].ver[1:], with no patch.
If the version is 3 digits, then major, minor, and patch each get 1 digit.
If the version is 4 or more digits, then major gets 1 digit, minor gets 2 digits
and patch gets all the rest.
As of May 2021, the version strings at https://download.qt.io/online/qtsdkrepository
conform to this pattern; they are not guaranteed to do so in the future.
"""
if not qt_ver or any(not ch.isdigit() for ch in qt_ver):
return None
if is_preview:
return Version(
major=int(qt_ver[:1]),
minor=int(qt_ver[1:]),
patch=0,
prerelease=("preview",),
)
elif len(qt_ver) >= 4:
return Version(major=int(qt_ver[:1]), minor=int(qt_ver[1:3]), patch=int(qt_ver[3:]))
elif len(qt_ver) == 3:
return Version(major=int(qt_ver[:1]), minor=int(qt_ver[1:2]), patch=int(qt_ver[2:]))
elif len(qt_ver) == 2:
return Version(major=int(qt_ver[:1]), minor=int(qt_ver[1:2]), patch=0)
raise ValueError("Invalid version string '{}'".format(qt_ver))

Please also note that this means it is currently impossible to install Qt 6.7.* for Android without using the all_os directory, because the installer won't be able to find these folders either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants