154 # Windows: %VIRTUAL_ENV%\pip.ini |
154 # Windows: %VIRTUAL_ENV%\pip.ini |
155 |
155 |
156 pip = "pip.ini" if Globals.isWindowsPlatform() else "pip.conf" |
156 pip = "pip.ini" if Globals.isWindowsPlatform() else "pip.conf" |
157 |
157 |
158 venvManager = e5App().getObject("VirtualEnvManager") |
158 venvManager = e5App().getObject("VirtualEnvManager") |
159 if venvManager.isGlobalEnvironment(venvName): |
159 venvDirectory = ( |
160 venvDirectory = os.path.dirname(self.getUserConfig()) |
160 os.path.dirname(self.getUserConfig()) |
161 else: |
161 if venvManager.isGlobalEnvironment(venvName) else |
162 venvDirectory = venvManager.getVirtualenvDirectory(venvName) |
162 venvManager.getVirtualenvDirectory(venvName) |
|
163 ) |
163 |
164 |
164 config = os.path.join(venvDirectory, pip) if venvDirectory else "" |
165 config = os.path.join(venvDirectory, pip) if venvDirectory else "" |
165 |
166 |
166 return config |
167 return config |
167 |
168 |
237 interpreter = self.getVirtualenvInterpreter(venvName) |
238 interpreter = self.getVirtualenvInterpreter(venvName) |
238 if not interpreter: |
239 if not interpreter: |
239 return |
240 return |
240 |
241 |
241 dia = PipDialog(self.tr('Install PIP')) |
242 dia = PipDialog(self.tr('Install PIP')) |
242 if userSite: |
243 commands = ( |
243 commands = [(interpreter, ["-m", "ensurepip", "--user"])] |
244 [(interpreter, ["-m", "ensurepip", "--user"])] |
244 else: |
245 if userSite else |
245 commands = [(interpreter, ["-m", "ensurepip"])] |
246 [(interpreter, ["-m", "ensurepip"])] |
|
247 ) |
246 if Preferences.getPip("PipSearchIndex"): |
248 if Preferences.getPip("PipSearchIndex"): |
247 indexUrl = Preferences.getPip("PipSearchIndex") + "/simple" |
249 indexUrl = Preferences.getPip("PipSearchIndex") + "/simple" |
248 args = ["-m", "pip", "install", "--index-url", indexUrl, |
250 args = ["-m", "pip", "install", "--index-url", indexUrl, |
249 "--upgrade"] |
251 "--upgrade"] |
250 else: |
252 else: |
295 """ |
297 """ |
296 pyqtPackages = [p for p in packages |
298 pyqtPackages = [p for p in packages |
297 if p.lower() in ["pyqt5", "pyqt5-sip", "pyqtwebengine", |
299 if p.lower() in ["pyqt5", "pyqt5-sip", "pyqtwebengine", |
298 "qscintilla", "sip"]] |
300 "qscintilla", "sip"]] |
299 |
301 |
300 if bool(pyqtPackages): |
302 abort = ( |
301 abort = not E5MessageBox.yesNo( |
303 not E5MessageBox.yesNo( |
302 None, |
304 None, |
303 self.tr("Upgrade Packages"), |
305 self.tr("Upgrade Packages"), |
304 self.tr( |
306 self.tr( |
305 """You are trying to upgrade PyQt packages. This might""" |
307 """You are trying to upgrade PyQt packages. This might""" |
306 """ not work for the current instance of Python ({0}).""" |
308 """ not work for the current instance of Python ({0}).""" |
307 """ Do you want to continue?""").format(sys.executable), |
309 """ Do you want to continue?""").format(sys.executable), |
308 icon=E5MessageBox.Critical) |
310 icon=E5MessageBox.Critical) |
309 else: |
311 if bool(pyqtPackages) else |
310 abort = False |
312 False |
|
313 ) |
311 |
314 |
312 return abort |
315 return abort |
313 |
316 |
314 def upgradePackages(self, packages, venvName, userSite=False): |
317 def upgradePackages(self, packages, venvName, userSite=False): |
315 """ |
318 """ |
498 Public method to get the index URL for PyPI. |
501 Public method to get the index URL for PyPI. |
499 |
502 |
500 @return index URL for PyPI |
503 @return index URL for PyPI |
501 @rtype str |
504 @rtype str |
502 """ |
505 """ |
503 if Preferences.getPip("PipSearchIndex"): |
506 indexUrl = ( |
504 indexUrl = Preferences.getPip("PipSearchIndex") + "/simple" |
507 Preferences.getPip("PipSearchIndex") + "/simple" |
505 else: |
508 if Preferences.getPip("PipSearchIndex") else |
506 indexUrl = Pip.DefaultIndexUrlSimple |
509 Pip.DefaultIndexUrlSimple |
|
510 ) |
507 |
511 |
508 return indexUrl |
512 return indexUrl |
509 |
513 |
510 def getIndexUrlPypi(self): |
514 def getIndexUrlPypi(self): |
511 """ |
515 """ |
512 Public method to get the index URL for PyPI API calls. |
516 Public method to get the index URL for PyPI API calls. |
513 |
517 |
514 @return index URL for XML RPC calls |
518 @return index URL for XML RPC calls |
515 @rtype str |
519 @rtype str |
516 """ |
520 """ |
517 if Preferences.getPip("PipSearchIndex"): |
521 indexUrl = ( |
518 indexUrl = Preferences.getPip("PipSearchIndex") + "/pypi" |
522 Preferences.getPip("PipSearchIndex") + "/pypi" |
519 else: |
523 if Preferences.getPip("PipSearchIndex") else |
520 indexUrl = Pip.DefaultIndexUrlPypi |
524 Pip.DefaultIndexUrlPypi |
|
525 ) |
521 |
526 |
522 return indexUrl |
527 return indexUrl |
523 |
528 |
524 def getIndexUrlSearch(self): |
529 def getIndexUrlSearch(self): |
525 """ |
530 """ |
526 Public method to get the index URL for PyPI API calls. |
531 Public method to get the index URL for PyPI API calls. |
527 |
532 |
528 @return index URL for XML RPC calls |
533 @return index URL for XML RPC calls |
529 @rtype str |
534 @rtype str |
530 """ |
535 """ |
531 if Preferences.getPip("PipSearchIndex"): |
536 indexUrl = ( |
532 indexUrl = Preferences.getPip("PipSearchIndex") + "/search/" |
537 Preferences.getPip("PipSearchIndex") + "/search/" |
533 else: |
538 if Preferences.getPip("PipSearchIndex") else |
534 indexUrl = Pip.DefaultIndexUrlSearch |
539 Pip.DefaultIndexUrlSearch |
|
540 ) |
535 |
541 |
536 return indexUrl |
542 return indexUrl |
537 |
543 |
538 def getInstalledPackages(self, envName, localPackages=True, |
544 def getInstalledPackages(self, envName, localPackages=True, |
539 notRequired=False, usersite=False): |
545 notRequired=False, usersite=False): |