Skip to content

Loading…

Default profile #964

Merged
merged 3 commits into from

2 participants

@takluyver
IPython member

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.

@takluyver
IPython member

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

@minrk
IPython member

Looks good to me, thanks!

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

@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.

@takluyver IPython member
@minrk IPython member
minrk added a note
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@minrk minrk merged commit c3d885f into ipython:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 1, 2011
  1. @takluyver
  2. @takluyver
  3. @minrk

    %profile points to application value, not shell value

    minrk committed
    also add missing shell.profile_dir in ipkernel
    
    closes gh-939
Showing with 15 additions and 10 deletions.
  1. +2 −4 IPython/core/application.py
  2. +5 −1 IPython/core/magic.py
  3. +2 −2 IPython/core/tests/test_profile.py
  4. +6 −3 IPython/zmq/ipkernel.py
View
6 IPython/core/application.py
@@ -104,11 +104,9 @@ def _config_file_name_changed(self, name, old, new):
def _config_file_paths_default(self):
return [os.getcwdu()]
- profile = Unicode(u'', config=True,
+ profile = Unicode(u'default', config=True,
help="""The IPython profile to use."""
)
- def _profile_default(self):
- return "python3" if py3compat.PY3 else "default"
def _profile_changed(self, name, old, new):
self.builtin_profile_dir = os.path.join(
@@ -230,7 +228,7 @@ def init_profile_dir(self):
p = ProfileDir.find_profile_dir_by_name(self.ipython_dir, self.profile, self.config)
except ProfileDirError:
# not found, maybe create it (always create default profile)
- if self.auto_create or self.profile==self._profile_default():
+ if self.auto_create or self.profile=='default':
try:
p = ProfileDir.create_profile_dir_by_name(self.ipython_dir, self.profile, self.config)
except ProfileDirError:
View
6 IPython/core/magic.py
@@ -527,7 +527,11 @@ def magic_page(self, parameter_s=''):
def magic_profile(self, parameter_s=''):
"""Print your currently active IPython profile."""
- print self.shell.profile
+ from IPython.core.application import BaseIPythonApplication
+ if BaseIPythonApplication.initialized():
+ print BaseIPythonApplication.instance().profile
+ else:
+ error("profile is an application-level value, but you don't appear to be in an IPython application")
def magic_pinfo(self, parameter_s='', namespaces=None):
"""Provide detailed information about an object.
View
4 IPython/core/tests/test_profile.py
@@ -80,7 +80,7 @@ def test_startup_py():
# write simple test file, to check that the startup file was run
fname = os.path.join(TMP_TEST_DIR, 'test.py')
with open(fname, 'w') as f:
- f.write('print zzz\n')
+ f.write(py3compat.doctest_refactor_print('print zzz\n'))
@minrk IPython member
minrk added a note

@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.

@takluyver IPython member
@minrk IPython member
minrk added a note
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
# validate output
tt.ipexec_validate(fname, '123', '',
options=['--ipython-dir', IP_TEST_DIR, '--profile', 'test'])
@@ -100,4 +100,4 @@ def test_startup_ipy():
tt.ipexec_validate(fname, 'test', '',
options=['--ipython-dir', IP_TEST_DIR, '--profile', 'test'])
-
+
View
9 IPython/zmq/ipkernel.py
@@ -64,6 +64,7 @@ class Kernel(Configurable):
shell = Instance('IPython.core.interactiveshell.InteractiveShellABC')
session = Instance(Session)
+ profile_dir = Instance('IPython.core.profiledir.ProfileDir')
shell_socket = Instance('zmq.Socket')
iopub_socket = Instance('zmq.Socket')
stdin_socket = Instance('zmq.Socket')
@@ -106,7 +107,9 @@ def __init__(self, **kwargs):
atexit.register(self._at_shutdown)
# Initialize the InteractiveShell subclass
- self.shell = ZMQInteractiveShell.instance(config=self.config)
+ self.shell = ZMQInteractiveShell.instance(config=self.config,
+ profile_dir = self.profile_dir,
+ )
self.shell.displayhook.session = self.session
self.shell.displayhook.pub_socket = self.iopub_socket
self.shell.display_pub.session = self.session
@@ -739,16 +742,16 @@ def initialize(self, argv=None):
self.init_code()
def init_kernel(self):
- kernel_factory = Kernel
if self.pylab:
gui, backend = pylabtools.find_gui_and_backend(self.pylab)
- kernel = kernel_factory(config=self.config, session=self.session,
+ kernel = Kernel(config=self.config, session=self.session,
shell_socket=self.shell_socket,
iopub_socket=self.iopub_socket,
stdin_socket=self.stdin_socket,
log=self.log,
+ profile_dir=self.profile_dir,
)
self.kernel = kernel
kernel.record_ports(self.ports)
Something went wrong with that request. Please try again.