Wed, 13 Feb 2019 20:39:03 +0100
VirtualenvConfigurationDialog: added capability to create a conda environment from a requirements file.
VirtualEnv/VirtualenvConfigurationDialog.py | file | annotate | diff | comparison | revisions | |
VirtualEnv/VirtualenvConfigurationDialog.ui | file | annotate | diff | comparison | revisions |
--- a/VirtualEnv/VirtualenvConfigurationDialog.py Wed Feb 13 19:48:48 2019 +0100 +++ b/VirtualEnv/VirtualenvConfigurationDialog.py Wed Feb 13 20:39:03 2019 +0100 @@ -76,7 +76,14 @@ self.condaCloneDirectoryPicker.setDefaultDirectory( Utilities.getHomeDir()) - # TODO: add creation from requirements + self.condaRequirementsFilePicker.setMode( + E5PathPickerModes.OpenFileMode) + self.condaRequirementsFilePicker.setWindowTitle( + self.tr("Conda Requirements File")) + self.condaRequirementsFilePicker.setDefaultDirectory( + Utilities.getHomeDir()) + self.condaRequirementsFilePicker.setFilters( + self.tr("Text Files (*.txt);;All Files (*)")) self.__versionRe = re.compile(r""".*?(\d+\.\d+\.\d+).*""") @@ -121,9 +128,12 @@ elif self.condaButton.isChecked(): enable = bool(self.condaNameEdit.text()) or \ bool(self.condaTargetDirectoryPicker.text()) - if self.condaCloneGroup.isChecked(): - enable &= bool(self.condaCloneNameEdit.text()) or \ - bool(self.condaCloneDirectoryPicker.text()) + if self.condaSpecialsGroup.isChecked(): + if self.condaCloneButton.isChecked(): + enable &= bool(self.condaCloneNameEdit.text()) or \ + bool(self.condaCloneDirectoryPicker.text()) + elif self.condaRequirementsButton.isChecked(): + enable &= bool(self.condaRequirementsFilePicker.text()) self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enable) else: self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False) @@ -149,8 +159,7 @@ self.upgradeCheckBox.setEnabled(not enable) # conda page - # TODO: add creation from requirements - enable = not self.condaCloneGroup.isChecked() + enable = not self.condaSpecialsGroup.isChecked() self.condaPackagesEdit.setEnabled(enable) self.condaPythonEdit.setEnabled(enable) self.condaInsecureCheckBox.setEnabled( @@ -236,9 +245,9 @@ self.__updateOK() @pyqtSlot() - def on_condaCloneGroup_clicked(self): + def on_condaSpecialsGroup_clicked(self): """ - Private slot handling the selection of the clone group. + Private slot handling the selection of the specials group. """ self.__updateOK() self.__updateUi() @@ -263,6 +272,30 @@ """ self.__updateOK() + @pyqtSlot() + def on_condaCloneButton_clicked(self): + """ + Private slot handling the selection of the clone button. + """ + self.__updateOK() + + @pyqtSlot() + def on_condaRequirementsButton_clicked(self): + """ + Private slot handling the selection of the requirements button. + """ + self.__updateOK() + + @pyqtSlot(str) + def on_condaRequirementsFilePicker_textChanged(self, txt): + """ + Private slot handling a change of the requirements file entry. + + @param txt current text of the requirements file entry + @type str + """ + self.__updateOK() + def __setVirtualenvVersion(self): """ Private method to determine the virtualenv version and set the @@ -411,18 +444,24 @@ if bool(self.condaTargetDirectoryPicker.text()): args.extend(["--prefix", self.condaTargetDirectoryPicker.text()]) - if self.condaCloneGroup.isChecked(): - if bool(self.condaCloneNameEdit.text()): - args.extend(["--clone", self.condaCloneNameEdit.text()]) - elif bool(self.condaCloneDirectoryPicker.text()): - args.extend(["--clone", - self.condaCloneDirectoryPicker.text()]) + if self.condaSpecialsGroup.isChecked(): + if self.condaCloneButton.isChecked(): + if bool(self.condaCloneNameEdit.text()): + args.extend( + ["--clone", self.condaCloneNameEdit.text()] + ) + elif bool(self.condaCloneDirectoryPicker.text()): + args.extend(["--clone", + self.condaCloneDirectoryPicker.text()]) + elif self.condaRequirementsButton.isChecked(): + args.extend( + ["--file", self.condaRequirementsFilePicker.text()] + ) if self.condaInsecureCheckBox.isChecked(): args.append("--insecure") if self.condaDryrunCheckBox.isChecked(): args.append("--dry-run") - # TODO: add creation from requirements - if not self.condaCloneGroup.isChecked(): + if not self.condaSpecialsGroup.isChecked(): if bool(self.condaPythonEdit.text()): args.append("python={0}".format( self.condaPythonEdit.text()))
--- a/VirtualEnv/VirtualenvConfigurationDialog.ui Wed Feb 13 19:48:48 2019 +0100 +++ b/VirtualEnv/VirtualenvConfigurationDialog.ui Wed Feb 13 20:39:03 2019 +0100 @@ -7,7 +7,7 @@ <x>0</x> <y>0</y> <width>700</width> - <height>622</height> + <height>654</height> </rect> </property> <property name="windowTitle"> @@ -460,18 +460,6 @@ </widget> <widget class="QWidget" name="condaPage"> <layout class="QVBoxLayout" name="verticalLayout_3"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> <item> <widget class="QGroupBox" name="groupBox_4"> <property name="title"> @@ -526,12 +514,9 @@ </widget> </item> <item> - <widget class="QGroupBox" name="condaCloneGroup"> - <property name="toolTip"> - <string>Select to clone an existing environment</string> - </property> + <widget class="QGroupBox" name="condaSpecialsGroup"> <property name="title"> - <string>Clone Environment</string> + <string>Special Operations</string> </property> <property name="checkable"> <bool>true</bool> @@ -541,40 +526,116 @@ </property> <layout class="QGridLayout" name="gridLayout_5"> <item row="0" column="0"> - <widget class="QLabel" name="label_8"> + <widget class="QRadioButton" name="condaCloneButton"> + <property name="toolTip"> + <string>Select to clone an environment</string> + </property> <property name="text"> - <string>Name:</string> + <string>Clone Environment</string> + </property> + <property name="checked"> + <bool>true</bool> </property> </widget> </item> <item row="0" column="1"> - <widget class="E5ClearableLineEdit" name="condaCloneNameEdit"> - <property name="toolTip"> - <string>Enter the name of the environment to be cloned</string> + <widget class="QRadioButton" name="condaRequirementsButton"> + <property name="statusTip"> + <string>Select to create the environment from a requirements file</string> + </property> + <property name="text"> + <string>from Requirements</string> </property> </widget> </item> <item row="1" column="0"> - <widget class="QLabel" name="label_7"> - <property name="text"> - <string>Path:</string> + <widget class="QFrame" name="condaCloneFrame"> + <property name="frameShape"> + <enum>QFrame::StyledPanel</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Raised</enum> </property> + <layout class="QGridLayout" name="gridLayout_7"> + <item row="0" column="0"> + <widget class="QLabel" name="label_8"> + <property name="text"> + <string>Name:</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="E5ClearableLineEdit" name="condaCloneNameEdit"> + <property name="toolTip"> + <string>Enter the name of the environment to be cloned</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_7"> + <property name="text"> + <string>Path:</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="E5PathPicker" name="condaCloneDirectoryPicker" native="true"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="focusPolicy"> + <enum>Qt::WheelFocus</enum> + </property> + <property name="toolTip"> + <string>Enter the directory of the environment to be cloned</string> + </property> + </widget> + </item> + </layout> </widget> </item> <item row="1" column="1"> - <widget class="E5PathPicker" name="condaCloneDirectoryPicker" native="true"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> + <widget class="QFrame" name="condaRequirementsFrame"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="frameShape"> + <enum>QFrame::StyledPanel</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Raised</enum> </property> - <property name="focusPolicy"> - <enum>Qt::WheelFocus</enum> - </property> - <property name="toolTip"> - <string>Enter the directory of the environment to be cloned</string> - </property> + <layout class="QVBoxLayout" name="verticalLayout_4"> + <item> + <widget class="E5PathPicker" name="condaRequirementsFilePicker" native="true"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="focusPolicy"> + <enum>Qt::StrongFocus</enum> + </property> + </widget> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>37</height> + </size> + </property> + </spacer> + </item> + </layout> </widget> </item> </layout> @@ -651,19 +712,6 @@ </layout> </widget> </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>33</height> - </size> - </property> - </spacer> - </item> </layout> </widget> </widget> @@ -717,9 +765,12 @@ <tabstop>openCheckBox</tabstop> <tabstop>condaNameEdit</tabstop> <tabstop>condaTargetDirectoryPicker</tabstop> - <tabstop>condaCloneGroup</tabstop> + <tabstop>condaSpecialsGroup</tabstop> + <tabstop>condaCloneButton</tabstop> <tabstop>condaCloneNameEdit</tabstop> <tabstop>condaCloneDirectoryPicker</tabstop> + <tabstop>condaRequirementsButton</tabstop> + <tabstop>condaRequirementsFilePicker</tabstop> <tabstop>condaPackagesEdit</tabstop> <tabstop>condaPythonEdit</tabstop> <tabstop>condaInsecureCheckBox</tabstop> @@ -734,8 +785,8 @@ <slot>accept()</slot> <hints> <hint type="sourcelabel"> - <x>248</x> - <y>254</y> + <x>257</x> + <y>644</y> </hint> <hint type="destinationlabel"> <x>157</x> @@ -750,8 +801,8 @@ <slot>reject()</slot> <hints> <hint type="sourcelabel"> - <x>316</x> - <y>260</y> + <x>325</x> + <y>644</y> </hint> <hint type="destinationlabel"> <x>286</x> @@ -759,5 +810,37 @@ </hint> </hints> </connection> + <connection> + <sender>condaCloneButton</sender> + <signal>toggled(bool)</signal> + <receiver>condaCloneFrame</receiver> + <slot>setEnabled(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>108</x> + <y>361</y> + </hint> + <hint type="destinationlabel"> + <x>78</x> + <y>380</y> + </hint> + </hints> + </connection> + <connection> + <sender>condaRequirementsButton</sender> + <signal>toggled(bool)</signal> + <receiver>condaRequirementsFrame</receiver> + <slot>setEnabled(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>431</x> + <y>359</y> + </hint> + <hint type="destinationlabel"> + <x>427</x> + <y>381</y> + </hint> + </hints> + </connection> </connections> </ui>