Skip to content

Commit

Permalink
setup.py: do not overwrite conda's PyQt5
Browse files Browse the repository at this point in the history
The PyQt5 dependency conflicts with conda, where the same package is called
pyqt. Installing pyqt5 inside a conda environment that already contains pyqt
may be catastrophic. Removing the dependency makes pip installation into conda
environments safer; such installations frequently occur when users install an
add-on not available in the conda repos that requires a newer version of
Orange. The same issue appears when Anaconda users try to update Orange with
the Add-on dialog box. Or when someone who installed Orange with conda
downloads the master branch and does "pip install -e .".

Orange added the PyQt5 dependency about a year ago to make pip installations
friendlier. Unfortunately, that caused more problems than it fixed. This commit
modifies setup.py to only installs PyQt5 in a conda environment if PyQt5 could
not be imported. I presume this is safe.
  • Loading branch information
markotoplak committed Sep 10, 2021
1 parent 53e2640 commit 959786b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 0 additions & 2 deletions requirements-gui.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
orange-canvas-core>=0.1.21,<0.2a
orange-widget-base>=4.13.0

PyQt5>=5.12,!=5.15.1 # 5.15.1 skipped because of QTBUG-87057 - affects select columns
PyQtWebEngine>=5.12
AnyQt>=0.0.11

pyqtgraph>=0.11.1
Expand Down
2 changes: 2 additions & 0 deletions requirements-pyqt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PyQt5>=5.12,!=5.15.1 # 5.15.1 skipped because of QTBUG-87057 - affects select columns
PyQtWebEngine>=5.12
13 changes: 13 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@
except ImportError:
have_cython = False

try:
import PyQt5.QtCore
have_pyqt5 = True
except ImportError:
have_pyqt5 = False

is_conda = os.path.exists(os.path.join(sys.prefix, 'conda-meta'))

NAME = 'Orange3'

Expand Down Expand Up @@ -78,6 +85,12 @@

requirements = ['requirements-core.txt', 'requirements-gui.txt']

# pyqt5 is named pyqt5 on pypi and pyqt on conda
# due to possible conflicts, skip the pyqt5 requirement in conda environments
# that already have pyqt
if not (is_conda and have_pyqt5):
requirements.append('requirements-pyqt.txt')

INSTALL_REQUIRES = sorted(set(
line.partition('#')[0].strip()
for file in (os.path.join(os.path.dirname(__file__), file)
Expand Down

0 comments on commit 959786b

Please sign in to comment.