Advice on how to update lxml on OS X
Hi folks,
I have a client who needs a later version of lxml to be picked up by Inkscape* on OS X. Unfortunately, I do not have access to OS X, so I'm not sure how to best acheive this - any advice would be most welcome. I'm not sure what version of OS X, but I'm guessing the procedure will be somewhat similar on all of them...
Thanks, Chris
* I thought the target system was win32, but we crossed wires somewhere. If I'd known about bug #448285 in the first place, I would have written the extension differently from the start - but as it stands I don't think that I have enough time. His deadline approaches...
On 20/10/09 03:14, Chris Mohler wrote:
I have a client who needs a later version of lxml to be picked up by Inkscape* on OS X. Unfortunately, I do not have access to OS X, so I'm not sure how to best acheive this - any advice would be most welcome. I'm not sure what version of OS X, but I'm guessing the procedure will be somewhat similar on all of them...
A) he can install the lxml and numpy as any other python module into the Python Framework that is part of the OS X installation. You'd have to test if it's necessary to remove/rename the 'Contents/Resources/python' directory inside the application bundle - I don't know since I never touched the osx installed python version. If he didn't upgrade to Snow Leopard the default python install is v2.5.1. Note that this is not recommended according to the installation notes on the lxml website http://codespeak.net/lxml/installation.html#macos-x.
Inkscape Wiki: Pre-compiling the Python modules http://wiki.inkscape.org/wiki/index.php/CompilingMacOsX#Pre-compiling_the_Python_modules
B) If he is comfortable using commandline tools - MacPorts is a port manager that lets you install python and related modules into a separate tree independent from the osx installation. Inkscape's launcher script has $PATH for a default MacPorts installation included and uses the MacPorts python binary if installed instead of the OS X Framework version. I am not sure if you need to comment out the $PYTHONPATH in the launcher script or if the (updated) MacPorts python modules are seen first by the MacPorts python binary anyway (Michael or JiHO certainly know more about the details).
1) install MacPorts (DMG available) http://www.macports.org/ 2) use Terminal.app (shell): $ sudo port self-update $ sudo port install py26-lxml $ sudo port install py26-numpy should retrieve, install and activate all dependencies needed, including python 2.6.x itself. Default prefix is '/opt/local'. 3) test Inkscape.app (0.47pre4) with the "debug" extension (bug #448285) to see which modules are loaded. If needed, add/change $PYTHONHOME/$PYTHONPATH in 'Contents/Resources/bin/inkscape' (shell script) inside the application bundle.
SVN macosx packaging - launcher script: http://inkscape.svn.sourceforge.net/viewvc/inkscape/inkscape/trunk/packaging/macosx/Resources/bin/inkscape?view=markup
C) ? bug Michael to update and rebuild the python modules bundled with Inkscape 0.47 ?
hth, ~suv
@ Michael, JiHO - please correct me if I am wrong or missed an easier way ;-)
On Tue, Oct 20, 2009 at 03:57, ~suv <suv-sf@...58...> wrote:
B) If he is comfortable using commandline tools - MacPorts is a port manager that lets you install python and related modules into a separate tree independent from the osx installation. Inkscape's launcher script has $PATH for a default MacPorts installation included and uses the MacPorts python binary if installed instead of the OS X Framework version. I am not sure if you need to comment out the $PYTHONPATH in the launcher script or if the (updated) MacPorts python modules are seen first by the MacPorts python binary anyway (Michael or JiHO certainly know more about the details).
In bin/inkscape we *prepend* the internal path to our python modules to the PYTHONPATH, so those will be found and used first and user-installed ones will be ignored. In consequence, you have to edit/comment this line if you want to use your modules.... I think ;)
JiHO --- http://maururu.net
On Thu, Oct 29, 2009 at 3:37 PM, JiHO <jo.lists@...400...> wrote:
In bin/inkscape we *prepend* the internal path to our python modules to the PYTHONPATH, so those will be found and used first and user-installed ones will be ignored. In consequence, you have to edit/comment this line if you want to use your modules.... I think ;)
Hmm - shouldn't this be the other way around? Try system-wide first, then fall back to bundled libs if need be? Particularly since the bundled version of lxml (and numpy?) is quite dated it seems to make sense to me - but then again I have no experience packaging for OSX.
In the end, my client opened the .app bundle and replaced lxml with a newer version- and this got things rolling again.
Chris
On Fri, Oct 30, 2009 at 01:47, Chris Mohler <cr33dog@...400...> wrote:
Hmm - shouldn't this be the other way around? Try system-wide first, then fall back to bundled libs if need be? Particularly since the bundled version of lxml (and numpy?) is quite dated it seems to make sense to me - but then again I have no experience packaging for OSX.
I don't recall the specifics but I think it PYTHONPATH was not working exactly as PATH. For example, we are doing:
export PYTHONPATH="$TOP/python/site-packages/$ARCH/$PYTHON_VERS"
and this only *prepends* stuff to PYTHONPATH (or at least it used to), it does not replace it. With PATH, you would have to do:
export PATH="foo:$PATH"
to prepend, and
export PATH="foo"
would reset PATH, not add to it.
But maybe we can try:
export PYTHONPATH="$PYTHONPATH:$TOP/python/site-packages/$ARCH/$PYTHON_VERS"
and see if that works. Basically we need to test with a recent lxml version in MacPorts + the old one in Inkscape.app and check which one gets loaded in Inkscape eventually. I'll have to do some digging to check how I can get access to the lxml version used from within Inkscape so if someone wants to test that before me, by all means, please do! ;)
JiHO --- http://maururu.net
On Sun, Nov 8, 2009 at 3:05 PM, JiHO <jo.lists@...400...> wrote:
Basically we need to test with a recent lxml version in MacPorts + the old one in Inkscape.app and check which one gets loaded in Inkscape eventually. I'll have to do some digging to check how I can get access to the lxml version used from within Inkscape so if someone wants to test that before me, by all means, please do! ;)
Maybe this is helpful: https://bugs.launchpad.net/inkscape/+bug/448285/comments/9 https://bugs.launchpad.net/inkscape/+bug/448285/comments/10
I'm on linux, so my ability to help set on OS X is nil :( (Inkscape uses the system-wide lxml here)
But this: export PYTHONPATH="$PYTHONPATH:$TOP/python/site-packages/$ARCH/$PYTHON_VERS" seems worth a shot to me.
If there's anything I can do or provide from a linux (or win32) box, just let me know.
Chris
On Sat, Nov 7, 2009 at 22:31, Chris Mohler <cr33dog@...400...> wrote:
Maybe this is helpful: https://bugs.launchpad.net/inkscape/+bug/448285/comments/9 https://bugs.launchpad.net/inkscape/+bug/448285/comments/10
That definitely helps! Thanks.
If there's anything I can do or provide from a linux (or win32) box, just let me know.
Well, the problem is really time to test everything. My MacPorts installation is in need of serious updating and I have very little time to spend on that+Inkscape. Yet, I would be happy to send some of my daytime work your way so that I can free so time in my schedule. You could definitely do this work on a linux box. Does that work for you ;)
... oh man, how much would I like this to be *actually* feasible!
Cheers,
JiHO --- http://maururu.net
On 7/11/09 22:31, Chris Mohler wrote:
On Sun, Nov 8, 2009 at 3:05 PM, JiHO <jo.lists@...400...> wrote:
Basically we need to test with a recent lxml version in MacPorts + the old one in Inkscape.app and check which one gets loaded in Inkscape eventually. I'll have to do some digging to check how I can get access to the lxml version used from within Inkscape so if someone wants to test that before me, by all means, please do! ;)
Maybe this is helpful: https://bugs.launchpad.net/inkscape/+bug/448285/comments/9 https://bugs.launchpad.net/inkscape/+bug/448285/comments/10
I'm on linux, so my ability to help set on OS X is nil :( (Inkscape uses the system-wide lxml here)
But this: export PYTHONPATH="$PYTHONPATH:$TOP/python/site-packages/$ARCH/$PYTHON_VERS" seems worth a shot to me.
The problem is: the current launch script doesn't see any user environment configuration, so $PYTHONPATH initially will always be empty... except we want to load only modules installed in assumed default locations (system python, macports), like this for example:
# Setup PYTHONPATH to use python modules shipped with Inkscape ARCH=`arch` PYTHON_VERS=`python -V 2>&1 | cut -c 8-10` # testing new PYTHONPATH proposed by JiHO in 'inkscape-devel' 07.11.09 22:05 # including predefined module paths (system python, macports) # # 3rd party modules for Python 2.5.1 on OS X 10.5.8 should be installed into # /Library/Python/2.5/site-packages # 3rd party modules for Python 2.6.1 on OS X 10.6.x should be installed into # /Library/Python/2.6/site-packages ??? # local modules compatible with system python 2.5.1 on OS X 10.5.8: # $MACPORTS_PREFIX/lib/python2.5/site-packages # $MACPORTS_PREFIX/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/ # local modules compatible with MacPorts python 2.6.x on OS X 10.5.8: # $MACPORTS_PREFIX/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/ # MACPORTS_PREFIX="/Volumes/blue/mp" #MACPORTS_PREFIX="/opt/local" MACPORTS_PYTHONPATH="$MACPORTS_PREFIX/Library/Frameworks/Python.framework/Versions/$PYTHON_VERS/lib/python$PYTHON_VERS/site-packages/" SYSTEM_PYTHONPATH="/Library/Python/$PYTHON_VERS/site-packages/" export PYTHONPATH="$SYSTEM_PYTHONPATH:$MACPORTS_PYTHONPATH:$TOP/python/site-packages/$ARCH/$PYTHON_VERS"
works for me with Inkscape 0.47pre4 from sf.net, system Python 2.5.1 and my updated MacPorts modules.
TODO: 1) verify paths: - default path to the Python frameworks in MacPorts installed in '/opt/local' - default path to site-packages for the system Python on OS X 10.6 Snow Leopard 2) test modules: - any module installed for the system Python on 10.5 and 10.6. 3) what about OS X 10.4 Tiger? 4) precedence of system Python over MacPorts modules or vice versa?
~suv
attached: diff for 'inkscape', 0.47pre4 (r22446)
--- inkscape-orig.sh 2009-10-18 18:29:05.000000000 +0200 +++ inkscape 2009-11-08 03:26:53.000000000 +0100 @@ -26,9 +26,27 @@ # Setup PYTHONPATH to use python modules shipped with Inkscape ARCH=`arch` PYTHON_VERS=`python -V 2>&1 | cut -c 8-10` -export PYTHONPATH="$TOP/python/site-packages/$ARCH/$PYTHON_VERS" +#export PYTHONPATH="$TOP/python/site-packages/$ARCH/$PYTHON_VERS" # NB: we are only preprending some stuff to the default python path so if the directory does not exist it should not harm the rest
+# testing new PYTHONPATH proposed by JiHO in 'inkscape-devel' 2009-11-07 +# including predefined module paths (system python, macports) +# +# 3rd party modules for Python 2.5.1 on OS X 10.5.8 should be installed into: +# /Library/Python/2.5/site-packages +# 3rd party modules for Python 2.6.1 on OS X 10.6.x should be installed into: +# /Library/Python/2.6/site-packages ??? +# local modules compatible with system python 2.5.1 on OS X 10.5.8: +# $MACPORTS_PREFIX/lib/python2.5/site-packages +# $MACPORTS_PREFIX/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/ +# local modules compatible with MacPorts python 2.6.x on OS X 10.5.8: +# $MACPORTS_PREFIX/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/ +# +MACPORTS_PREFIX="/opt/local" +MACPORTS_PYTHONPATH="$MACPORTS_PREFIX/Library/Frameworks/Python.framework/Versions/$PYTHON_VERS/lib/python$PYTHON_VERS/site-packages/" +SYSTEM_PYTHONPATH="/Library/Python/$PYTHON_VERS/site-packages/" +export PYTHONPATH="$SYSTEM_PYTHONPATH:$MACPORTS_PYTHONPATH:$TOP/python/site-packages/$ARCH/$PYTHON_VERS" + # No longer required if path rewriting has been conducted. # export DYLD_LIBRARY_PATH="$TOP/lib"
participants (3)
-
Chris Mohler
-
JiHO
-
~suv