58 self.pythonExecPicker.setWindowTitle( |
60 self.pythonExecPicker.setWindowTitle( |
59 self.tr("Python Interpreter")) |
61 self.tr("Python Interpreter")) |
60 self.pythonExecPicker.setDefaultDirectory( |
62 self.pythonExecPicker.setDefaultDirectory( |
61 sys.executable.replace("w.exe", ".exe")) |
63 sys.executable.replace("w.exe", ".exe")) |
62 |
64 |
|
65 self.condaTargetDirectoryPicker.setMode( |
|
66 E5PathPickerModes.DirectoryMode) |
|
67 self.condaTargetDirectoryPicker.setWindowTitle( |
|
68 self.tr("Conda Environment Location")) |
|
69 self.condaTargetDirectoryPicker.setDefaultDirectory( |
|
70 Utilities.getHomeDir()) |
|
71 |
|
72 self.condaCloneDirectoryPicker.setMode( |
|
73 E5PathPickerModes.DirectoryMode) |
|
74 self.condaCloneDirectoryPicker.setWindowTitle( |
|
75 self.tr("Conda Environment Location")) |
|
76 self.condaCloneDirectoryPicker.setDefaultDirectory( |
|
77 Utilities.getHomeDir()) |
|
78 |
|
79 self.condaRequirementsFilePicker.setMode( |
|
80 E5PathPickerModes.OpenFileMode) |
|
81 self.condaRequirementsFilePicker.setWindowTitle( |
|
82 self.tr("Conda Requirements File")) |
|
83 self.condaRequirementsFilePicker.setDefaultDirectory( |
|
84 Utilities.getHomeDir()) |
|
85 self.condaRequirementsFilePicker.setFilters( |
|
86 self.tr("Text Files (*.txt);;All Files (*)")) |
|
87 |
63 self.__versionRe = re.compile(r""".*?(\d+\.\d+\.\d+).*""") |
88 self.__versionRe = re.compile(r""".*?(\d+\.\d+\.\d+).*""") |
64 |
89 |
65 self.__virtualenvFound = False |
90 self.__virtualenvFound = False |
66 self.__pyvenvFound = False |
91 self.__pyvenvFound = False |
|
92 self.__condaFound = False |
67 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False) |
93 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False) |
68 |
94 |
69 self.__mandatoryStyleSheet = "QLineEdit {border: 2px solid;}" |
95 self.__mandatoryStyleSheet = "QLineEdit {border: 2px solid;}" |
70 self.targetDirectoryPicker.setStyleSheet(self.__mandatoryStyleSheet) |
96 self.targetDirectoryPicker.setStyleSheet(self.__mandatoryStyleSheet) |
71 self.nameEdit.setStyleSheet(self.__mandatoryStyleSheet) |
97 self.nameEdit.setStyleSheet(self.__mandatoryStyleSheet) |
|
98 self.condaTargetDirectoryPicker.setStyleSheet( |
|
99 self.__mandatoryStyleSheet) |
|
100 self.condaNameEdit.setStyleSheet(self.__mandatoryStyleSheet) |
72 |
101 |
73 self.__setVirtualenvVersion() |
102 self.__setVirtualenvVersion() |
74 self.__setPyvenvVersion() |
103 self.__setPyvenvVersion() |
75 if self.__virtualenvFound: |
104 self.__setCondaVersion() |
|
105 if self.__pyvenvFound: |
|
106 self.pyvenvButton.setChecked(True) |
|
107 elif self.__virtualenvFound: |
76 self.virtualenvButton.setChecked(True) |
108 self.virtualenvButton.setChecked(True) |
77 elif self.__pyvenvFound: |
109 elif self.__condaFound: |
78 self.pyvenvButton.setChecked(True) |
110 self.condaButton.setChecked(True) |
|
111 |
|
112 self.condaInsecureCheckBox.setEnabled( |
|
113 CondaInterface.condaVersion() >= (4, 3, 18)) |
79 |
114 |
80 msh = self.minimumSizeHint() |
115 msh = self.minimumSizeHint() |
81 self.resize(max(self.width(), msh.width()), msh.height()) |
116 self.resize(max(self.width(), msh.width()), msh.height()) |
82 |
117 |
83 def __updateOK(self): |
118 def __updateOK(self): |
84 """ |
119 """ |
85 Private method to update the enabled status of the OK button. |
120 Private method to update the enabled status of the OK button. |
86 """ |
121 """ |
87 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled( |
122 if self.virtualenvButton.isChecked() or self.pyvenvButton.isChecked(): |
88 (self.__virtualenvFound or self.__pyvenvFound) and |
123 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled( |
89 bool(self.targetDirectoryPicker.text()) and |
124 (self.__virtualenvFound or self.__pyvenvFound) and |
90 bool(self.nameEdit.text()) |
125 bool(self.targetDirectoryPicker.text()) and |
91 ) |
126 bool(self.nameEdit.text()) |
|
127 ) |
|
128 elif self.condaButton.isChecked(): |
|
129 enable = bool(self.condaNameEdit.text()) or \ |
|
130 bool(self.condaTargetDirectoryPicker.text()) |
|
131 if self.condaSpecialsGroup.isChecked(): |
|
132 if self.condaCloneButton.isChecked(): |
|
133 enable &= bool(self.condaCloneNameEdit.text()) or \ |
|
134 bool(self.condaCloneDirectoryPicker.text()) |
|
135 elif self.condaRequirementsButton.isChecked(): |
|
136 enable &= bool(self.condaRequirementsFilePicker.text()) |
|
137 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enable) |
|
138 else: |
|
139 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False) |
92 |
140 |
93 def __updateUi(self): |
141 def __updateUi(self): |
94 """ |
142 """ |
95 Private method to update the UI depending on the selected |
143 Private method to update the UI depending on the selected |
96 virtual environment creator (virtualenv or pyvenv). |
144 virtual environment creator (virtualenv or pyvenv). |
97 """ |
145 """ |
|
146 # venv page |
98 enable = self.virtualenvButton.isChecked() |
147 enable = self.virtualenvButton.isChecked() |
99 self.extraSearchPathLabel.setEnabled(enable) |
148 self.extraSearchPathLabel.setEnabled(enable) |
100 self.extraSearchPathPicker.setEnabled(enable) |
149 self.extraSearchPathPicker.setEnabled(enable) |
101 self.promptPrefixLabel.setEnabled(enable) |
150 self.promptPrefixLabel.setEnabled(enable) |
102 self.promptPrefixEdit.setEnabled(enable) |
151 self.promptPrefixEdit.setEnabled(enable) |
279 |
436 |
280 @return process arguments |
437 @return process arguments |
281 @rtype list of str |
438 @rtype list of str |
282 """ |
439 """ |
283 args = [] |
440 args = [] |
284 if self.virtualenvButton.isChecked(): |
441 if self.condaButton.isChecked(): |
285 if self.extraSearchPathPicker.text(): |
442 if bool(self.condaNameEdit.text()): |
286 args.append("--extra-search-dir={0}".format( |
443 args.extend(["--name", self.condaNameEdit.text()]) |
287 Utilities.toNativeSeparators( |
444 if bool(self.condaTargetDirectoryPicker.text()): |
288 self.extraSearchPathPicker.text()))) |
445 args.extend(["--prefix", |
289 if self.promptPrefixEdit.text(): |
446 self.condaTargetDirectoryPicker.text()]) |
290 args.append("--prompt={0}".format( |
447 if self.condaSpecialsGroup.isChecked(): |
291 self.promptPrefixEdit.text().replace(" ", "_"))) |
448 if self.condaCloneButton.isChecked(): |
292 if self.pythonExecPicker.text(): |
449 if bool(self.condaCloneNameEdit.text()): |
293 args.append("--python={0}".format( |
450 args.extend( |
294 Utilities.toNativeSeparators( |
451 ["--clone", self.condaCloneNameEdit.text()] |
295 self.pythonExecPicker.text()))) |
452 ) |
296 elif self.versionComboBox.currentText(): |
453 elif bool(self.condaCloneDirectoryPicker.text()): |
297 args.append("--python=python{0}".format( |
454 args.extend(["--clone", |
298 self.versionComboBox.currentText())) |
455 self.condaCloneDirectoryPicker.text()]) |
299 if self.verbositySpinBox.value() == 1: |
456 elif self.condaRequirementsButton.isChecked(): |
300 args.append("--verbose") |
457 args.extend( |
301 elif self.verbositySpinBox.value() == -1: |
458 ["--file", self.condaRequirementsFilePicker.text()] |
302 args.append("--quiet") |
459 ) |
303 if self.clearCheckBox.isChecked(): |
460 if self.condaInsecureCheckBox.isChecked(): |
304 args.append("--clear") |
461 args.append("--insecure") |
305 if self.systemCheckBox.isChecked(): |
462 if self.condaDryrunCheckBox.isChecked(): |
306 args.append("--system-site-packages") |
463 args.append("--dry-run") |
307 if self.unzipCheckBox.isChecked(): |
464 if not self.condaSpecialsGroup.isChecked(): |
308 args.append("--unzip-setuptools") |
465 if bool(self.condaPythonEdit.text()): |
309 if self.noSetuptoolsCheckBox.isChecked(): |
466 args.append("python={0}".format( |
310 args.append("--no-setuptools") |
467 self.condaPythonEdit.text())) |
311 if self.noPipCcheckBox.isChecked(): |
468 if bool(self.condaPackagesEdit.text()): |
312 args.append("--no-pip") |
469 args.extend(self.condaPackagesEdit.text().split()) |
313 if self.copyCheckBox.isChecked(): |
470 else: |
314 args.append("--always-copy") |
471 if self.virtualenvButton.isChecked(): |
315 elif self.pyvenvButton.isChecked(): |
472 if self.extraSearchPathPicker.text(): |
316 if self.clearCheckBox.isChecked(): |
473 args.append("--extra-search-dir={0}".format( |
317 args.append("--clear") |
474 Utilities.toNativeSeparators( |
318 if self.systemCheckBox.isChecked(): |
475 self.extraSearchPathPicker.text()))) |
319 args.append("--system-site-packages") |
476 if self.promptPrefixEdit.text(): |
320 if self.noPipCcheckBox.isChecked(): |
477 args.append("--prompt={0}".format( |
321 args.append("--without-pip") |
478 self.promptPrefixEdit.text().replace(" ", "_"))) |
322 if self.copyCheckBox.isChecked(): |
479 if self.pythonExecPicker.text(): |
323 args.append("--copies") |
480 args.append("--python={0}".format( |
324 if self.symlinkCheckBox.isChecked(): |
481 Utilities.toNativeSeparators( |
325 args.append("--symlinks") |
482 self.pythonExecPicker.text()))) |
326 if self.upgradeCheckBox.isChecked(): |
483 elif self.versionComboBox.currentText(): |
327 args.append("--upgrade") |
484 args.append("--python=python{0}".format( |
328 targetDirectory = self.__generateTargetDir() |
485 self.versionComboBox.currentText())) |
329 args.append(targetDirectory) |
486 if self.verbositySpinBox.value() == 1: |
|
487 args.append("--verbose") |
|
488 elif self.verbositySpinBox.value() == -1: |
|
489 args.append("--quiet") |
|
490 if self.clearCheckBox.isChecked(): |
|
491 args.append("--clear") |
|
492 if self.systemCheckBox.isChecked(): |
|
493 args.append("--system-site-packages") |
|
494 if self.unzipCheckBox.isChecked(): |
|
495 args.append("--unzip-setuptools") |
|
496 if self.noSetuptoolsCheckBox.isChecked(): |
|
497 args.append("--no-setuptools") |
|
498 if self.noPipCcheckBox.isChecked(): |
|
499 args.append("--no-pip") |
|
500 if self.copyCheckBox.isChecked(): |
|
501 args.append("--always-copy") |
|
502 elif self.pyvenvButton.isChecked(): |
|
503 if self.clearCheckBox.isChecked(): |
|
504 args.append("--clear") |
|
505 if self.systemCheckBox.isChecked(): |
|
506 args.append("--system-site-packages") |
|
507 if self.noPipCcheckBox.isChecked(): |
|
508 args.append("--without-pip") |
|
509 if self.copyCheckBox.isChecked(): |
|
510 args.append("--copies") |
|
511 if self.symlinkCheckBox.isChecked(): |
|
512 args.append("--symlinks") |
|
513 if self.upgradeCheckBox.isChecked(): |
|
514 args.append("--upgrade") |
|
515 targetDirectory = self.__generateTargetDir() |
|
516 args.append(targetDirectory) |
|
517 |
330 return args |
518 return args |
331 |
519 |
332 def getData(self): |
520 def getData(self): |
333 """ |
521 """ |
334 Public method to retrieve the dialog data. |
522 Public method to retrieve the dialog data. |
335 |
523 |
336 @return tuple containing a flag indicating the pyvenv selection, the |
524 @return dictionary containing the data for the two environment |
337 process arguments, a name for the virtual environment, a flag |
525 variants. The keys for both variants are 'arguments' containing the |
338 indicating to open the target directory after creation, a flag |
526 command line arguments, 'logicalName' containing the environment |
339 indicating to write a log file, a flag indicating to write a |
527 name to be used with the virtual env manager and 'envType' |
340 script, the name of the target directory and the name of the |
528 containing the environment type (virtualenv, pyvenv or conda). The |
341 Python interpreter to use |
529 virtualenv/pyvenv specific keys are 'openTarget' containg a flag to |
342 @rtype tuple of (bool, list of str, str, bool, bool, bool, str, str) |
530 open the target directory after creation, 'createLog' containing a |
|
531 flag to write a log file, 'createScript' containing a flag to write |
|
532 a script, 'targetDirectory' containing the target directory and |
|
533 'pythonExe' containing the Python interpreter to be used. The |
|
534 conda specific key is 'command' giving the conda command to be |
|
535 executed (always 'create'). |
|
536 @rtype dict |
343 """ |
537 """ |
344 args = self.__generateArguments() |
538 args = self.__generateArguments() |
345 targetDirectory = self.__generateTargetDir() |
539 resultDict = { |
346 return ( |
540 "arguments": args, |
347 self.pyvenvButton.isChecked(), |
541 "logicalName": self.nameEdit.text(), |
348 args, |
542 } |
349 self.nameEdit.text(), |
543 if self.condaButton.isChecked(): |
350 self.openCheckBox.isChecked(), |
544 resultDict.update({ |
351 self.logCheckBox.isChecked(), |
545 "envType": "conda", |
352 self.scriptCheckBox.isChecked(), |
546 "command": "create", |
353 targetDirectory, |
547 }) |
354 Utilities.toNativeSeparators(self.pythonExecPicker.text()), |
548 else: |
355 ) |
549 resultDict.update({ |
|
550 "envType": ("pyvenv" if self.pyvenvButton.isChecked() else |
|
551 "virtualenv"), |
|
552 "openTarget": self.openCheckBox.isChecked(), |
|
553 "createLog": self.logCheckBox.isChecked(), |
|
554 "createScript": self.scriptCheckBox.isChecked(), |
|
555 "targetDirectory": self.__generateTargetDir(), |
|
556 "pythonExe": Utilities.toNativeSeparators( |
|
557 self.pythonExecPicker.text()), |
|
558 }) |
|
559 |
|
560 return resultDict |