Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Make ipython cProfile-able #193

Closed
wants to merge 1 commit into from

3 participants

@tomspur

To get a cProfile of ipython inside of the git repo you could run:
"python -m cProfile ipython.py"

Currently file is wrongly detected and it crashes, after this commit, you get a proper cProfile.

@ellisonbg
Owner

I know this script is designed to just start ipython from the top-level source dir, but won't this mean that the script will no longer work if curdir is not the top-level source dir? That may be OK though. Can we make it work both ways?

@tomspur

Ha, I found another way (althought, it looks like a hack^^).

This works now both ways (but doesn't look nice anymore at least for me).

@tomspur tomspur Make ipython.py cProfile-able
When using __file__ on startup and cProfile in the same time, __file__
is defined as the __file__ of cProfile and not the local ipython.py.
With using sys.argv[0] instead, it's possible to get a cProfile.
a5680be
@minrk
Owner

This fix does work for me in and out of the directory with ipython.py, but the following has always worked for me:

python -m cProfile `which ipython`

Brian, should I go ahead and merge this?

@ellisonbg
Owner

I haven't testing this, but it looks fine.

@tomspur

Merge branch 'ready_cProfile' of https://github.com/tomspur/ipython

closed by 604c8e1

@markvoorhies markvoorhies referenced this pull request from a commit in markvoorhies/ipython
@tomspur tomspur Merge branch 'ready_cProfile' of https://github.com/tomspur/ipython
closes gh-193
604c8e1
@ellisonbg ellisonbg referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@mattvonrocketstein mattvonrocketstein referenced this pull request from a commit in mattvonrocketstein/ipython
@tomspur tomspur Merge branch 'ready_cProfile' of https://github.com/tomspur/ipython
closes gh-193
4ee8792
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 15, 2011
  1. @tomspur

    Make ipython.py cProfile-able

    tomspur authored
    When using __file__ on startup and cProfile in the same time, __file__
    is defined as the __file__ of cProfile and not the local ipython.py.
    With using sys.argv[0] instead, it's possible to get a cProfile.
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  ipython.py
View
2  ipython.py
@@ -9,7 +9,7 @@
# Ensure that the imported IPython is the local one, not a system-wide one
import os, sys
-this_dir = os.path.dirname(os.path.abspath(__file__))
+this_dir = os.path.dirname(sys.argv[0])
sys.path.insert(0, this_dir)
# Now proceed with execution
Something went wrong with that request. Please try again.