def argv(self): """Command to start kernels""" # Python interpreter used to start kernels if CONF.get('main_interpreter', 'default'): pyexec = get_python_executable() else: # Avoid IPython adding the virtualenv on which Spyder is running # to the kernel sys.path os.environ.pop('VIRTUAL_ENV', None) pyexec = CONF.get('main_interpreter', 'executable') if not is_python_interpreter(pyexec): pyexec = get_python_executable() CONF.set('main_interpreter', 'executable', '') CONF.set('main_interpreter', 'default', True) CONF.set('main_interpreter', 'custom', False) # Part of spyder-ide/spyder#11819 is_different = is_different_interpreter(pyexec) # Fixes spyder-ide/spyder#3427. if os.name == 'nt': dir_pyexec = osp.dirname(pyexec) pyexec_w = osp.join(dir_pyexec, 'pythonw.exe') if osp.isfile(pyexec_w): pyexec = pyexec_w # Command used to start kernels if is_different and is_conda_env(pyexec=pyexec): # If this is a conda environment we need to call an intermediate # activation script to correctly activate the spyder-kernel # If changes are needed on this section make sure you also update # the activation scripts at spyder/plugins/ipythonconsole/scripts/ kernel_cmd = [ get_activation_script(), # This is bundled with Spyder get_conda_activation_script(), get_conda_env_path(pyexec), # Might be external pyexec, '{connection_file}', ] else: kernel_cmd = [ pyexec, '-m', 'spyder_kernels.console', '-f', '{connection_file}' ] logger.info('Kernel command: {}'.format(kernel_cmd)) return kernel_cmd
def argv(self): """Command to start kernels""" # Python interpreter used to start kernels if CONF.get('main_interpreter', 'default'): pyexec = get_python_executable() else: pyexec = CONF.get('main_interpreter', 'executable') if not is_python_interpreter(pyexec): pyexec = get_python_executable() CONF.set('main_interpreter', 'executable', '') CONF.set('main_interpreter', 'default', True) CONF.set('main_interpreter', 'custom', False) # Part of spyder-ide/spyder#11819 is_different = is_different_interpreter(pyexec) # Command used to start kernels if is_different and is_conda_env(pyexec=pyexec): # If this is a conda environment we need to call an intermediate # activation script to correctly activate the spyder-kernel # If changes are needed on this section make sure you also update # the activation scripts at spyder/plugins/ipythonconsole/scripts/ kernel_cmd = [ get_activation_script(), # This is bundled with Spyder get_conda_activation_script(pyexec), get_conda_env_path(pyexec), # Might be external pyexec, '{connection_file}', ] else: kernel_cmd = [ pyexec, '-m', 'spyder_kernels.console', '-f', '{connection_file}' ] logger.info('Kernel command: {}'.format(kernel_cmd)) return kernel_cmd
def test_get_conda_env_path(): output = get_conda_env_path(TEST_PYEXEC) if os.name == 'nt': assert output == 'c:/miniconda/envs/foobar' else: assert output == '/miniconda/envs/foobar'
def render_issue(cls, description='', traceback='', include_env=False): """ Render issue content. Parameters ---------- description: str Description to include in issue message. traceback: str Traceback text. include_env: bool (False) Whether to include the IPython console environment. """ # Get dependencies if they haven't beed computed yet. if not dependencies.DEPENDENCIES: try: dependencies.declare_dependencies() except ValueError: pass # Make a description header in case no description is supplied if not description: description = "### What steps reproduce the problem?" # Make error section from traceback and add appropriate reminder header if traceback: error_section = ("### Traceback\n" "```python-traceback\n" "{}\n" "```".format(traceback)) else: error_section = '' versions_text = get_versions_text() issue_template = f"""\ ## Description {description} {error_section} ## Versions {versions_text} ### Dependencies ``` {dependencies.status()} ``` """ # Report environment if selected if include_env: pyexe = cls.get_conf(cls, 'executable', section='main_interpreter') if is_conda_env(pyexec=pyexe): path = get_conda_env_path(pyexe) exe = find_conda() args = ['list', '--prefix', path] else: exe = pyexe args = ['-m', 'pip', 'list'] proc = run_program(exe, args=args) ext_env, stderr = proc.communicate() issue_template += f""" ### Environment <details><summary>Environment</summary> ``` {ext_env.decode()} ``` </details> """ return issue_template