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

Allow to specify Qt version via an environment variable (QT_VERSION) #476

Open
Bzero opened this issue Apr 2, 2024 · 4 comments · May be fixed by #478
Open

Allow to specify Qt version via an environment variable (QT_VERSION) #476

Bzero opened this issue Apr 2, 2024 · 4 comments · May be fixed by #478
Assignees
Milestone

Comments

@Bzero
Copy link

Bzero commented Apr 2, 2024

In some circumstances it may be useful to specify the Qt version qtpy should use without without specifying which implementation to use. Currently it is only possible leave it up to qtpy to decide or to exactly specify the API using the QT_API environment variable.

In my particular use case I would need this feature in an application using QtPdf (which is only available in Qt6) but am indifferent whether PyQt6 or PySide6 should be used. I am aware that it is possible to set QT_API=pyqt6 and pyqt will fall back to PySide6 when PyQt6 is not available but I would consider this a bit unsatisfactory since it will trigger a warning for an unproblematic case, the actual intention does not become clear when looking at the code and it does not work when only Qt5 should be used instead.

This feature could be realized by allowing to set QT_API to a Qt version , e.g. QT_API=Qt6 or by allowing to set QT_API to a list of values, e.g. QT_API=pyqt6,pyside6.

@ccordoba12
Copy link
Member

Hey @Bzero, thanks for reporting. I think it'd better to create a new env var for this case because QT_API is used by other packages (e.g. Matplotlib and Qtconsole, if I'm not mistaken). So, we could have QT_VERSION=qt6, which is similar to what you suggested.

@dalthviz, what do you think?

@Bzero
Copy link
Author

Bzero commented Apr 8, 2024

Thanks for your reply. I was not aware that QT_API is used by other packages too so I agree that adding a QT_VERSION environment variable makes sense.

The only drawback I see with this is that QT_API and QT_VERSION may be in conflict with each other, I suppose in that case qtpy should probably just ignore QT_VERSION and trigger a warning.

I can prepare a PR to implement this feature.

@ccordoba12
Copy link
Member

ccordoba12 commented Apr 8, 2024

The only drawback I see with this is that QT_API and QT_VERSION may be in conflict with each other, I suppose in that case qtpy should probably just ignore QT_VERSION and trigger a warning.

Agreed. QT_API should have precedence over QT_VERSION and we should report a warning about it. Also, another warning should be shown if the QT_VERSION value can't be set because there are no matching bindings.

I can prepare a PR to implement this feature.

That'd be great, thanks!

@dalthviz
Copy link
Member

dalthviz commented Apr 9, 2024

Just in case, creating a QT_VERSION env var makes sense 👍 Thank you @Bzero for bringing this up and your willingness to implement it!

@dalthviz dalthviz added this to the v2.5.0 milestone Apr 9, 2024
@dalthviz dalthviz changed the title Allow to specify Qt Version via Environemt Variable Allow to specify Qt version via an environment variable (QT_VERSION) Apr 9, 2024
@Bzero Bzero linked a pull request Apr 13, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants