py-load-pymacs sets load path incorrectly
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
python-mode.el |
Fix Released
|
Medium
|
Andreas Roehler |
Bug Description
So far as I can tell py-load-pymacs adds .../pymacs/
(add-to-list 'load-path "~/el/python-
(setq py-install-
in .emacs
Here's a slightly modified function to do these:
(defun py-load-pymacs ()
"Load Pymacs as delivered with python-mode.el.
Pymacs has been written by François Pinard and many others.
See original source: http://
(interactive)
(if (or (not (boundp 'py-install-
(error "`py-install-
(load (expand-file-name (concat py-install-
(add-to-list 'load-path (expand-file-name (concat py-install-
(setenv "PYMACS_PYTHON" "python2.7")
(autoload 'pymacs-apply "pymacs")
(autoload 'pymacs-call "pymacs")
(autoload 'pymacs-eval "pymacs")
(autoload 'pymacs-exec "pymacs")
(autoload 'pymacs-load "pymacs")
(require 'pymacs)))
Changed in python-mode: | |
assignee: | nobody → Andreas Roehler (a-roehler) |
milestone: | none → 6.0.5 |
importance: | Undecided → Medium |
Changed in python-mode: | |
status: | New → Fix Committed |
Changed in python-mode: | |
status: | Fix Committed → Fix Released |
Hi Andreas,
A bit more on this. I think that some extra expand-file-name calls are needed -- see diff below.
Also, if the user (like me) chooses IPython as the default interpreter by customizing py-shell, then pymacs tries to start IPython rather than python or jython is its inferior process. This is done by setting the PYMACS_PYTHON environment variable with py-choose-shell. For the time being, I've just specified "python" instead of calling py-choose-shell; I never use jython and I pymacs never wants Ipython.
Unfortunately for me, pymacs doesn't start cleanly even when I make sure that python is the inferior shell. In the *Pymacs* buffer I get:
------- ------- ------- ------- ------- ------- ------- ------- --
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named Pymacs.pymacs
Process pymacs exited abnormally with code 1 ------- ------- ------- ------- ------- ------- ------- ---
-------
This seems to be because the "standard" pymacs is a package, probably located in .../lib/ pythonX. Y/site- packages, but with the automatic loading from python-mode.el it's not in a package and the py-install- directory is not in sys.path. I'm not sure of the best way to tell the inferior Python where to find pymacs -- one possibility would be to mess with PYTHONPATH, but that might be messy if the user has also set it; another might be to add py-install- directory directly to sys.path in pymacs.el. Hardcoding my .../python- mode/pymacs directory (it has to be the full path) and changing Pymacs to pymacs in a couple of places (see patch) helps, but it looks as if pymacs.py still differs from Pymacs enough to break it. Here's what happens in *Pymacs* with the patched code:
------- ------- ------- ------- ------- ------- ------- ------- ----- Cellar/ python/ 2.7.2/Framework s/Python. framework/ Versions/ 2.7/lib/ python2. 7/site- packages/ pip-1.0. 2-py2.7. egg', '/usr/local/ Cellar/ python/ 2.7.2/Framework s/Python. framework/ Versions/ 2.7/lib/ python2. 7/site- packages/ distribute- 0.6.21- py2.7.egg' , '/System/ Library/ Frameworks/ Python. framework/ Versions/ src/scipy' , '/System/ Library/ Frameworks/ Python. framework/ Versions/ src/matplotlib/ lib', '/usr/local/ Cellar/ python/ 2.7.2/Framework s/Python. framework/ Versions/ 2.7/lib/ python27. zip', '/usr/local/ Cellar/ python/ 2.7.2/Framework s/Python. framework/ Versions/ 2.7/lib/ python2. 7', '/usr/local/ Cellar/ python/ 2.7.2/Framework s/Python. framework/ Versions/ 2.7/lib/ python2. 7/plat- darwin' , '/usr/local/ Cellar/ python/ 2.7.2/Framework s/Python. framework/ Versions/ 2.7/lib/ python2. 7/plat- mac', '/usr/local/ Cellar/ python/ 2.7.2/Framework s/Python. framework/ Versions/ 2.7/lib/ python2. 7/plat- mac/lib- scriptpackages' , '/usr/local/ Cellar/ python/ 2.7.2/Framework s/Python. framework/ Versions/ 2.7/lib/ python2. 7/lib-tk' , '/usr/local/ Cellar/ python/ 2.7.2/Framework s/Python. framework/ Versions/ 2.7/lib/ python2. 7/lib-old' , '/usr/local/ Cellar/ python/ 2.7.2/Framework s/Python. framework/ Versions/ 2.7/lib/ python2. 7/lib-dynload' , '/usr/local/ Cellar/ python/ 2.7.2/Framework s/Python. framework/ Versions/ 2.7/lib/ python2. 7/site- packages' , '/Library/ Python/ 2.7/site- packages' , '/Users/ reverson/ Emacs/el/ python- mode/pymacs' ]
['', '/usr/local/
Traceback (most recent call las...