Skip to content
This repository

Default profile #964

Merged
merged 3 commits into from over 2 years ago

2 participants

Thomas Kluyver Min RK
Thomas Kluyver
Collaborator

As discussed, this makes the default profile the same for Python 2 and 3.

Also includes a fix for a new test that was failing on Python 3.

Thomas Kluyver
Collaborator

Now also includes Min's fix so starting the qtconsole and specifying a different profile works properly (#939).

Min RK
Owner

Looks good to me, thanks!

Min RK minrk commented on the diff November 02, 2011
IPython/core/tests/test_profile.py
@@ -80,7 +80,7 @@ def test_startup_py():
80 80
     # write simple test file, to check that the startup file was run
81 81
     fname = os.path.join(TMP_TEST_DIR, 'test.py')
82 82
     with open(fname, 'w') as f:
83  
-        f.write('print zzz\n')
  83
+        f.write(py3compat.doctest_refactor_print('print zzz\n'))
4
Min RK Owner
minrk added a note November 02, 2011

@takluyver, when you get a chance, do you want to toss together a writeup of the py3compat stuff? The unicode_to_str, etc. is clear enough, but some of these would warrant a good doc, so we don't make you keep fixing our tests, etc. for py3 quite so often.

Thomas Kluyver Collaborator
Min RK Owner
minrk added a note November 02, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Min RK minrk merged commit c3d885f into from November 02, 2011
Min RK minrk closed this November 02, 2011
Brian E. Granger ellisonbg referenced this pull request from a commit January 10, 2012
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
6  IPython/core/application.py
@@ -104,11 +104,9 @@ def _config_file_name_changed(self, name, old, new):
104 104
     def _config_file_paths_default(self):
105 105
         return [os.getcwdu()]
106 106
 
107  
-    profile = Unicode(u'', config=True,
  107
+    profile = Unicode(u'default', config=True,
108 108
         help="""The IPython profile to use."""
109 109
     )
110  
-    def _profile_default(self):
111  
-        return "python3" if py3compat.PY3 else "default"
112 110
 
113 111
     def _profile_changed(self, name, old, new):
114 112
         self.builtin_profile_dir = os.path.join(
@@ -230,7 +228,7 @@ def init_profile_dir(self):
230 228
                 p = ProfileDir.find_profile_dir_by_name(self.ipython_dir, self.profile, self.config)
231 229
             except ProfileDirError:
232 230
                 # not found, maybe create it (always create default profile)
233  
-                if self.auto_create or self.profile==self._profile_default():
  231
+                if self.auto_create or self.profile=='default':
234 232
                     try:
235 233
                         p = ProfileDir.create_profile_dir_by_name(self.ipython_dir, self.profile, self.config)
236 234
                     except ProfileDirError:
6  IPython/core/magic.py
@@ -527,7 +527,11 @@ def magic_page(self, parameter_s=''):
527 527
 
528 528
     def magic_profile(self, parameter_s=''):
529 529
         """Print your currently active IPython profile."""
530  
-        print self.shell.profile
  530
+        from IPython.core.application import BaseIPythonApplication
  531
+        if BaseIPythonApplication.initialized():
  532
+            print BaseIPythonApplication.instance().profile
  533
+        else:
  534
+            error("profile is an application-level value, but you don't appear to be in an IPython application")
531 535
 
532 536
     def magic_pinfo(self, parameter_s='', namespaces=None):
533 537
         """Provide detailed information about an object.
4  IPython/core/tests/test_profile.py
@@ -80,7 +80,7 @@ def test_startup_py():
80 80
     # write simple test file, to check that the startup file was run
81 81
     fname = os.path.join(TMP_TEST_DIR, 'test.py')
82 82
     with open(fname, 'w') as f:
83  
-        f.write('print zzz\n')
  83
+        f.write(py3compat.doctest_refactor_print('print zzz\n'))
84 84
     # validate output
85 85
     tt.ipexec_validate(fname, '123', '', 
86 86
         options=['--ipython-dir', IP_TEST_DIR, '--profile', 'test'])
@@ -100,4 +100,4 @@ def test_startup_ipy():
100 100
     tt.ipexec_validate(fname, 'test', '', 
101 101
         options=['--ipython-dir', IP_TEST_DIR, '--profile', 'test'])
102 102
     
103  
-    
  103
+    
9  IPython/zmq/ipkernel.py
@@ -64,6 +64,7 @@ class Kernel(Configurable):
64 64
 
65 65
     shell = Instance('IPython.core.interactiveshell.InteractiveShellABC')
66 66
     session = Instance(Session)
  67
+    profile_dir = Instance('IPython.core.profiledir.ProfileDir')
67 68
     shell_socket = Instance('zmq.Socket')
68 69
     iopub_socket = Instance('zmq.Socket')
69 70
     stdin_socket = Instance('zmq.Socket')
@@ -106,7 +107,9 @@ def __init__(self, **kwargs):
106 107
         atexit.register(self._at_shutdown)
107 108
 
108 109
         # Initialize the InteractiveShell subclass
109  
-        self.shell = ZMQInteractiveShell.instance(config=self.config)
  110
+        self.shell = ZMQInteractiveShell.instance(config=self.config,
  111
+            profile_dir = self.profile_dir,
  112
+        )
110 113
         self.shell.displayhook.session = self.session
111 114
         self.shell.displayhook.pub_socket = self.iopub_socket
112 115
         self.shell.display_pub.session = self.session
@@ -739,16 +742,16 @@ def initialize(self, argv=None):
739 742
         self.init_code()
740 743
 
741 744
     def init_kernel(self):
742  
-        kernel_factory = Kernel
743 745
 
744 746
         if self.pylab:
745 747
             gui, backend = pylabtools.find_gui_and_backend(self.pylab)
746 748
 
747  
-        kernel = kernel_factory(config=self.config, session=self.session,
  749
+        kernel = Kernel(config=self.config, session=self.session,
748 750
                                 shell_socket=self.shell_socket,
749 751
                                 iopub_socket=self.iopub_socket,
750 752
                                 stdin_socket=self.stdin_socket,
751 753
                                 log=self.log,
  754
+                                profile_dir=self.profile_dir,
752 755
         )
753 756
         self.kernel = kernel
754 757
         kernel.record_ports(self.ports)
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.