10 import contextlib |
10 import contextlib |
11 import html.parser |
11 import html.parser |
12 import os |
12 import os |
13 import textwrap |
13 import textwrap |
14 |
14 |
15 from packaging.specifiers import SpecifierSet |
15 from packaging.specifiers import InvalidSpecifier, SpecifierSet |
16 from PyQt6.QtCore import Qt, QUrl, QUrlQuery, pyqtSlot |
16 from PyQt6.QtCore import Qt, QUrl, QUrlQuery, pyqtSlot |
17 from PyQt6.QtGui import QIcon |
17 from PyQt6.QtGui import QIcon |
18 from PyQt6.QtNetwork import QNetworkReply, QNetworkRequest |
18 from PyQt6.QtNetwork import QNetworkReply, QNetworkRequest |
19 from PyQt6.QtWidgets import ( |
19 from PyQt6.QtWidgets import ( |
20 QAbstractItemView, |
20 QAbstractItemView, |
175 """ |
175 """ |
176 Constructor |
176 Constructor |
177 |
177 |
178 @param pip reference to the global pip interface |
178 @param pip reference to the global pip interface |
179 @type Pip |
179 @type Pip |
180 @param parent reference to the parent widget |
180 @param parent reference to the parent widget (defaults to None) |
181 @type QWidget |
181 @type QWidget (optional) |
182 """ |
182 """ |
183 super().__init__(parent) |
183 super().__init__(parent) |
184 self.setupUi(self) |
184 self.setupUi(self) |
185 |
185 |
186 self.layout().setContentsMargins(0, 3, 0, 0) |
186 self.layout().setContentsMargins(0, 3, 0, 0) |
244 venvManager = ericApp().getObject("VirtualEnvManager") |
244 venvManager = ericApp().getObject("VirtualEnvManager") |
245 venvManager.virtualEnvironmentAdded.connect(self.on_refreshButton_clicked) |
245 venvManager.virtualEnvironmentAdded.connect(self.on_refreshButton_clicked) |
246 venvManager.virtualEnvironmentRemoved.connect(self.on_refreshButton_clicked) |
246 venvManager.virtualEnvironmentRemoved.connect(self.on_refreshButton_clicked) |
247 self.__selectedEnvironment = None |
247 self.__selectedEnvironment = None |
248 |
248 |
249 project = ericApp().getObject("Project") |
249 with contextlib.suppress(KeyError): |
250 project.projectOpened.connect(self.__projectOpened) |
250 project = ericApp().getObject("Project") |
251 project.projectClosed.connect(self.__projectClosed) |
251 project.projectOpened.connect(self.__projectOpened) |
|
252 project.projectClosed.connect(self.__projectClosed) |
252 |
253 |
253 self.__initPipMenu() |
254 self.__initPipMenu() |
254 self.__populateEnvironments() |
255 self.__populateEnvironments() |
255 self.__updateActionButtons() |
256 self.__updateActionButtons() |
256 self.__updateDepActionButtons() |
257 self.__updateDepActionButtons() |
1552 |
1553 |
1553 def __pipConfigure(self): |
1554 def __pipConfigure(self): |
1554 """ |
1555 """ |
1555 Private slot to open the configuration page. |
1556 Private slot to open the configuration page. |
1556 """ |
1557 """ |
1557 ericApp().getObject("UserInterface").showPreferences("pipPage") |
1558 try: |
|
1559 ericApp().getObject("UserInterface").showPreferences("pipPage") |
|
1560 except KeyError: |
|
1561 # we were called from outside the eric IDE |
|
1562 from eric7.Preferences.ConfigurationDialog import ( # noqa: I101 |
|
1563 ConfigurationDialog, |
|
1564 ConfigurationMode, |
|
1565 ) |
|
1566 |
|
1567 dlg = ConfigurationDialog( |
|
1568 None, |
|
1569 "Configuration", |
|
1570 True, |
|
1571 fromEric=False, |
|
1572 displayMode=ConfigurationMode.PIPMANAGERMODE, |
|
1573 ) |
|
1574 dlg.show() |
|
1575 dlg.showConfigurationPageByName("pipPage") |
|
1576 dlg.exec() |
|
1577 if dlg.result() == QDialog.DialogCode.Accepted: |
|
1578 dlg.setPreferences() |
|
1579 Preferences.syncPreferences() |
1558 |
1580 |
1559 @pyqtSlot() |
1581 @pyqtSlot() |
1560 def __showCacheInfo(self): |
1582 def __showCacheInfo(self): |
1561 """ |
1583 """ |
1562 Private slot to show information about the cache. |
1584 Private slot to show information about the cache. |
1846 spec = ( |
1868 spec = ( |
1847 "=={0}".format(dependency["required_version"]) |
1869 "=={0}".format(dependency["required_version"]) |
1848 if dependency["required_version"][0] in "0123456789" |
1870 if dependency["required_version"][0] in "0123456789" |
1849 else dependency["required_version"] |
1871 else dependency["required_version"] |
1850 ) |
1872 ) |
1851 specifierSet = SpecifierSet(specifiers=spec) |
1873 try: |
1852 if not specifierSet.contains(dependency["installed_version"]): |
1874 specifierSet = SpecifierSet(specifiers=spec) |
1853 itm.setIcon( |
1875 if not specifierSet.contains(dependency["installed_version"]): |
|
1876 itm.setIcon( |
|
1877 PipPackagesWidget.DepRequiredVersionColumn, |
|
1878 EricPixmapCache.getIcon("warning"), |
|
1879 ) |
|
1880 except InvalidSpecifier: |
|
1881 itm.setText( |
1854 PipPackagesWidget.DepRequiredVersionColumn, |
1882 PipPackagesWidget.DepRequiredVersionColumn, |
1855 EricPixmapCache.getIcon("warning"), |
1883 dependency["required_version"], |
1856 ) |
1884 ) |
1857 |
1885 |
1858 elif dependency["required_version"].lower() == "any": |
1886 elif dependency["required_version"].lower() == "any": |
1859 itm.setText(PipPackagesWidget.DepRequiredVersionColumn, self.tr("any")) |
1887 itm.setText(PipPackagesWidget.DepRequiredVersionColumn, self.tr("any")) |
1860 |
1888 |