diff --git a/IPython/core/application.py b/IPython/core/application.py index b91aefa..c99966f 100644 --- a/IPython/core/application.py +++ b/IPython/core/application.py @@ -27,6 +27,7 @@ Authors: # Imports #----------------------------------------------------------------------------- +import glob import logging import os import shutil @@ -254,8 +255,8 @@ class BaseIPythonApplication(Application): def init_config_files(self): """[optionally] copy default config files into profile dir.""" # copy config files + path = self.builtin_profile_dir if self.copy_config_files: - path = self.builtin_profile_dir src = self.profile cfg = self.config_file_name @@ -266,6 +267,19 @@ class BaseIPythonApplication(Application): self.profile_dir.copy_config_file(cfg, path=path, overwrite=self.overwrite) else: self.stage_default_config_file() + else: + # Still stage *bundled* config files, but not generated ones + # This is necessary for `ipython profile=sympy` to load the profile + # on the first go + files = glob.glob(os.path.join(path, '*.py')) + for fullpath in files: + cfg = os.path.basename(fullpath) + if self.profile_dir.copy_config_file(cfg, path=path, overwrite=False): + # file was copied + self.log.warn("Staging bundled %s from %s into %r"%( + cfg, self.profile, self.profile_dir.location) + ) + def stage_default_config_file(self): """auto generate default config file, and stage it into the profile.""" diff --git a/IPython/core/profiledir.py b/IPython/core/profiledir.py index 2668325..5f7615f 100644 --- a/IPython/core/profiledir.py +++ b/IPython/core/profiledir.py @@ -123,11 +123,12 @@ class ProfileDir(Configurable): """ dst = os.path.join(self.location, config_file) if os.path.isfile(dst) and not overwrite: - return + return False if path is None: path = os.path.join(get_ipython_package_dir(), u'config', u'profile', u'default') src = os.path.join(path, config_file) shutil.copy(src, dst) + return True @classmethod def create_profile_dir(cls, profile_dir, config=None):