-
-
Notifications
You must be signed in to change notification settings - Fork 11.3k
wxpython: system python doesn't pick up .pth in /usr/local/lib #30844
Comments
Just noticed this in the site package docs:
So, for option 3, Homebrew could still recommend an echo into homebrew.pth instead of creating a usercustomize.py. |
@tdsmith Just ran into this when needing to have a formula I agree with the need to have better support for echo "import site; site.addsitedir('#{HOMEBREW_PREFIX}/lib/python2.7/site-packages')" >> ~/Library/Python/2.7/lib/python/site-packages/homebrew.pth Still, more needs done for supporting 'keg-only' packages. So, the above For building within a formula, it is better to adjust PYTHONPATH, as that will be picked up by the package's build process, e.g. via def install
...
wx_paths = formula_site_packages "wxpython"
ENV.prepend("PYTHONPATH", wx_paths, File::PATH_SEPARATOR) if wx_paths
...
end
def formula_site_packages f
`python -c "import os, sys, site; sp1 = list(sys.path); site.addsitedir('#{Formula[f].opt_lib}/python2.7/site-packages'); print(os.pathsep.join([x for x in sys.path if x not in sp1]))"`.strip
end That works regardless of whether using OS X or Homebrew's Python, though a bit of overkill for Homebrew's. Maybe a Lastly, the current python s += " echo '#{site_packages}' > #{file}" # should be >> So that needs fixed as well, but then IMO the
This was brought up in PR #28597 and looks like it may have been forgotten (even by myself). /cc @samueljohn Any ideas here? |
@dakcarto Please file a separate issue/PR for things that are broken. This whole situation is a mess, unfortunately, and I'd love us to find a final solution for this. |
Hi, (installing XCode and dev tools, agreeing to the license etc)... Everything seemed to work, although it did say something about I might have problems referencing it (which seems to be relevant), or linking other packages to it. I tried using the echo command above, but still nothing from Python. I can't import wx, or wxversion. What are my options? The Cocoa version of wx from the wxpython site has a broken .pkg in it's dmg, so I can't use that one, and I don't want to use Carbon, since it doesn't provide the accessibility I rely on. Cheers. |
@chrisnorman7: Ignore Homebrew's messages at your peril. :) Although they wouldn't have helped here, yet! You can see the caveats that were printed after installation with |
No worries, Now I can wx away. Cheers, On 17/09/2014 15:49, tim smith wrote:
|
import wx
doesn't work for system Python users after brew installing wxpython.import wx
doesn't work unless this .pth file is processed.import wx
doesn't work out-of-the box with system Python with the suggestions that Homebrew provides.Some options:
wxpython could install wx directly into site-packages without the wx-3.0-osx_cocoa path elementOther packages require this behavior, and overriding it would be at odds with the wxpython versioning system.wxpython could install a wx symlink into site-packages pointing to wx-3.0-osx_cocoa/wxThis is at odds with the spirit of the wxpython versioning system.echo "import site; site.addsitedir('#{HOMEBREW_PREFIX}/lib/python2.7/site-packages')" >> ~/Library/Python/2.7/lib/python/site-packages/usercustomize.py
4 would work and in some sense would be the most durable but I don't know if other packages try to install .pth files.
Previously mentioned: #27112 (comment)
[1] PYTHONPATH is different from .pth files in that PYTHONPATH is prepended to sys.path and paths discovered in .pth files are appended. This is, just incidentally, bad for homebrew-python, where we would like to avoid importing system numpy, and need to come first in sys.path. addsitedir also appends, so we would still need to either a) set PYTHONPATH, or b) forcibly insert homebrew site-packages early in sys.path inside (user|site)customize.py.
The text was updated successfully, but these errors were encountered: