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

PR: Choose Qt binding to install from SPYDER_QT_BINDING environment variable #23055

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 40 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,37 @@ def get_packages():
packages = get_subpackages(LIBNAME)
return packages

def get_qt_requirements(qt_requirements, default='pyqt5'):
"""
Return a list of requirements for the Qt binding according to the
environment variable SPYDER_QT_BINDING. If this variable is not set
or has an unsupported value it defaults to 'pyqt5'.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a nitpick: In my opinion it’s better to throw an error when an invalid/unsupported value is passed.


Parameters
----------
qt_requirements : dict
A dictionary whose keys are supported Qt bindings and whose values are
lists of required packages to install for each binding.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

No need of a blank line here.

default : str
Default Qt binding to use if the environment variable is not
in qt_requirements. Default is 'pyqt5'.

Returns
-------
install_requires : list
A list of required packages to install for the given Qt binding.
"""

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

I think this is unnecessary.

install_requires = []

# Check if a Qt binding is set in the environment and normalizes
env_qt_binding = os.environ.get('SPYDER_QT_BINDING', default)
env_qt_binding = env_qt_binding.lower()
install_requires = qt_requirements.get(env_qt_binding, qt_requirements[default])

return install_requires


# =============================================================================
# Make Linux detect Spyder desktop file (will not work with wheels)
Expand Down Expand Up @@ -201,8 +232,16 @@ def run(self):
cmdclass=CMDCLASS,
)

# Qt bindings requirements
qt_requirements = {
'pyqt5' : ['pyqt5>=5.15,<5.16', 'pyqtwebengine>=5.15,<5.16'],
'pyqt6' : ['pyqt6>=6,<7', 'pyqt6-webengine>=6,<7'],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'pyqt6' : ['pyqt6>=6,<7', 'pyqt6-webengine>=6,<7'],
'pyqt6' : ['pyqt6>=6.5,<7', 'pyqt6-webengine>=6.5,<7'],

This is our minimal supported version of pyqt6.

}

# Get the proper requirements for the selected Qt binding
install_requires = get_qt_requirements(qt_requirements, default='pyqt5')

install_requires = [
install_requires += [
'aiohttp>=3.9.3',
'applaunchservices>=0.3.0;platform_system=="Darwin"',
'asyncssh>=2.14.0,<3.0.0',
Expand Down Expand Up @@ -232,8 +271,6 @@ def run(self):
'pylint>=3.1,<4',
'pylint-venv>=3.0.2',
'pyls-spyder>=0.4.0',
'pyqt5>=5.15,<5.16',
'pyqtwebengine>=5.15,<5.16',
'python-lsp-black>=2.0.0,<3.0.0',
'python-lsp-server[all]>=1.12.0,<1.13.0',
'pyuca>=1.2',
Expand Down
Loading