Skip to content

Commit

Permalink
Merge from 3.x: PR #7715
Browse files Browse the repository at this point in the history
Fixes #7674
  • Loading branch information
ccordoba12 committed Aug 18, 2018
2 parents 52418a1 + 58a0684 commit 7a8c2cb
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 37 deletions.
6 changes: 3 additions & 3 deletions spyder/config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@
'umr/enabled': True,
'umr/verbose': True,
'umr/namelist': [],
'custom_list': [],
'custom_executable': '',
'custom_interpreters_list': [],
'custom_interpreter': '',
}),
('ipython_console',
{
Expand Down Expand Up @@ -656,7 +656,7 @@
# or if you want to *rename* options, then you need to do a MAJOR update in
# version, e.g. from 3.0.0 to 4.0.0
# 3. You don't need to touch this value if you're just adding a new option
CONF_VERSION = '44.1.0'
CONF_VERSION = '45.0.0'

# Main configuration instance
try:
Expand Down
11 changes: 1 addition & 10 deletions spyder/plugins/configdialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -698,16 +698,7 @@ def create_file_combobox(self, text, choices, option, default=NoDefault,

if tip is not None:
combobox.setToolTip(tip)
for name, key in choices:
if not (name is None and key is None):
combobox.addItem(name, to_qvariant(key))
# Insert separators
count = 0
for index, item in enumerate(choices):
name, key = item
if name is None and key is None:
combobox.insertSeparator(index + count)
count += 1
combobox.addItems(choices)
self.comboboxes[combobox] = (option, default)

msg = _('Invalid file path')
Expand Down
45 changes: 23 additions & 22 deletions spyder/plugins/maininterpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ def __init__(self, parent, main):
# the Python executable has already been set with pythonw.exe:
self.set_option('executable',
executable.replace("pythonw.exe", "python.exe"))

if not self.get_option('default'):
if not self.get_option('custom_executable'):
self.set_option('custom_executable', ' ')
self.set_custom_interpreters_list(executable, executable)
if not self.get_option('custom_interpreter'):
self.set_option('custom_interpreter', ' ')
self.set_custom_interpreters_list(executable)
self.validate_custom_interpreters_list()

def initialize(self):
Expand Down Expand Up @@ -88,13 +89,13 @@ def setup_page(self):
pyexec_layout.addWidget(self.cus_exec_radio)
self.validate_custom_interpreters_list()
self.cus_exec_combo = self.create_file_combobox(
_('Recent custom interpreters'),
self.get_option('custom_list'),
'custom_executable',
filters=filters,
default_line_edit=True,
adjust_to_contents=True
)
_('Recent custom interpreters'),
self.get_option('custom_interpreters_list'),
'custom_interpreter',
filters=filters,
default_line_edit=True,
adjust_to_contents=True
)
self.def_exec_radio.toggled.connect(self.cus_exec_combo.setDisabled)
self.cus_exec_radio.toggled.connect(self.cus_exec_combo.setEnabled)
pyexec_layout.addWidget(self.cus_exec_combo)
Expand Down Expand Up @@ -230,23 +231,22 @@ def set_umr_namelist(self):
fixed_namelist = []
self.set_option('umr/namelist', fixed_namelist)

def set_custom_interpreters_list(self, display_value, value):
def set_custom_interpreters_list(self, value):
"""Update the list of interpreters used and the current one."""
custom_list = self.get_option('custom_list')
if ((display_value, value) not in custom_list
and value != get_python_executable()):
custom_list.append((display_value, value))
self.set_option('custom_list', custom_list)
custom_list = self.get_option('custom_interpreters_list')
if value not in custom_list and value != get_python_executable():
custom_list.append(value)
self.set_option('custom_interpreters_list', custom_list)

def validate_custom_interpreters_list(self):
"""Check that the used custom interpreters are still valid."""
custom_list = self.get_option('custom_list')
custom_list = self.get_option('custom_interpreters_list')
valid_custom_list = []
for name, value in custom_list:
for value in custom_list:
if (osp.isfile(value) and programs.is_python_interpreter(value)
and value != get_python_executable()):
valid_custom_list.append((name, value))
self.set_option('custom_list', valid_custom_list)
valid_custom_list.append(value)
self.set_option('custom_interpreters_list', valid_custom_list)

def apply_settings(self, options):
if not self.def_exec_radio.isChecked():
Expand All @@ -256,8 +256,9 @@ def apply_settings(self, options):
executable = executable.replace("pythonw.exe", "python.exe")
change = self.python_executable_changed(executable)
if change:
self.set_custom_interpreters_list(executable, executable)
self.set_custom_interpreters_list(executable)
self.set_option('executable', executable)
self.set_option('custom_interpreter', executable)
if not self.pyexec_edit.text():
self.set_option('custom_executable', '')
self.set_option('custom_interpreter', '')
self.main.apply_settings()
2 changes: 0 additions & 2 deletions spyder/plugins/workingdirectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ def __init__(self, parent, workdir=None, **kwds):
self.toolbar.addAction(self.previous_action)

# Next dir action
self.history = []
self.histindex = None
self.next_action = create_action(self, "next", None,
ima.icon('next'), _('Next'),
triggered=self.next_directory)
Expand Down

0 comments on commit 7a8c2cb

Please sign in to comment.