Beispiel #1
0
    def show_tour_message(self, force=False):
        """
        Show message about starting the tour the first time Spyder starts.

        Parameters
        ----------
        force: bool
            Force the display of the tour message.
        """
        should_show_tour = self.get_conf('show_tour_message')
        if force or (should_show_tour and not running_under_pytest()
                     and not get_safe_mode()):
            self.set_conf('show_tour_message', False)
            self.get_container().show_tour_message()
Beispiel #2
0
    def env(self):
        """Env vars for kernels"""
        default_interpreter = self.get_conf('default',
                                            section='main_interpreter')
        env_vars = os.environ.copy()

        # Avoid IPython adding the virtualenv on which Spyder is running
        # to the kernel sys.path
        env_vars.pop('VIRTUAL_ENV', None)

        # Add spyder-kernels subrepo path to PYTHONPATH
        if (DEV or running_under_pytest()) and not running_in_ci():
            repo_path = osp.normpath(osp.join(HERE, '..', '..', '..', '..'))
            subrepo_path = osp.join(repo_path, 'external-deps',
                                    'spyder-kernels')

            env_vars.update({'PYTHONPATH': subrepo_path})

        # List of paths declared by the user, plus project's path, to
        # add to PYTHONPATH
        pathlist = self.get_conf('spyder_pythonpath',
                                 default=[],
                                 section='main')
        pypath = os.pathsep.join(pathlist)

        # List of modules to exclude from our UMR
        umr_namelist = self.get_conf('umr/namelist',
                                     section='main_interpreter')

        # Environment variables that we need to pass to the kernel
        env_vars.update({
            'SPY_EXTERNAL_INTERPRETER':
            not default_interpreter,
            'SPY_UMR_ENABLED':
            self.get_conf('umr/enabled', section='main_interpreter'),
            'SPY_UMR_VERBOSE':
            self.get_conf('umr/verbose', section='main_interpreter'),
            'SPY_UMR_NAMELIST':
            ','.join(umr_namelist),
            'SPY_RUN_LINES_O':
            self.get_conf('startup/run_lines'),
            'SPY_PYLAB_O':
            self.get_conf('pylab'),
            'SPY_BACKEND_O':
            self.get_conf('pylab/backend'),
            'SPY_AUTOLOAD_PYLAB_O':
            self.get_conf('pylab/autoload'),
            'SPY_FORMAT_O':
            self.get_conf('pylab/inline/figure_format'),
            'SPY_BBOX_INCHES_O':
            self.get_conf('pylab/inline/bbox_inches'),
            'SPY_RESOLUTION_O':
            self.get_conf('pylab/inline/resolution'),
            'SPY_WIDTH_O':
            self.get_conf('pylab/inline/width'),
            'SPY_HEIGHT_O':
            self.get_conf('pylab/inline/height'),
            'SPY_USE_FILE_O':
            self.get_conf('startup/use_run_file'),
            'SPY_RUN_FILE_O':
            self.get_conf('startup/run_file'),
            'SPY_AUTOCALL_O':
            self.get_conf('autocall'),
            'SPY_GREEDY_O':
            self.get_conf('greedy_completer'),
            'SPY_JEDI_O':
            self.get_conf('jedi_completer'),
            'SPY_SYMPY_O':
            self.get_conf('symbolic_math'),
            'SPY_TESTING':
            running_under_pytest() or get_safe_mode(),
            'SPY_HIDE_CMD':
            self.get_conf('hide_cmd_windows'),
            'SPY_PYTHONPATH':
            pypath
        })

        if self.is_pylab is True:
            env_vars['SPY_AUTOLOAD_PYLAB_O'] = True
            env_vars['SPY_SYMPY_O'] = False
            env_vars['SPY_RUN_CYTHON'] = False
        if self.is_sympy is True:
            env_vars['SPY_AUTOLOAD_PYLAB_O'] = False
            env_vars['SPY_SYMPY_O'] = True
            env_vars['SPY_RUN_CYTHON'] = False
        if self.is_cython is True:
            env_vars['SPY_AUTOLOAD_PYLAB_O'] = False
            env_vars['SPY_SYMPY_O'] = False
            env_vars['SPY_RUN_CYTHON'] = True

        # App considerations
        if (running_in_mac_app() or is_pynsist()) and not default_interpreter:
            env_vars.pop('PYTHONHOME', None)
            env_vars.pop('PYTHONPATH', None)

        # Remove this variable because it prevents starting kernels for
        # external interpreters when present.
        # Fixes spyder-ide/spyder#13252
        env_vars.pop('PYTHONEXECUTABLE', None)

        # Making all env_vars strings
        clean_env_vars = clean_env(env_vars)

        return clean_env_vars