I had a mini-vacation and I spent a while trying to get sage working
with VTK on a Macbook. The machine is somewhat slow and experimenting
takes a long while. I've managed to get VTK built with Sage but
required a framework build. Here are the details.
I've been using sage-3.4 (since thats what I had with me). I have a
fresh sage (3.4) install where I installed cmake from Jaap's package here:
http://sage.math.washington.edu/home/jsp/SPKGS/MayaviOSMesa/
I then got
http://sage.math.washington.edu/home/jsp/SPKGS/MayaviOSMesa/vtk-cvs-20090316osmesa.spkg
and changed the spkg-install so it builds on the Mac.
I first tried building VTK with the existing sage python build but kept
running into build errors with VTK unable to find several Python
symbols. I configured VTK to build with the libpython2.5.a but that
failed to build with link errors that I forgot to note down (I must have
tried 10 different things trying to get this going). After various
failed attempts I finally decided to change the way sage builds its
Python and added:
--enable-framework="$SAGE_LOCAL/Frameworks"
to the configure command in the spkg-install of python-2.5.2.p9 that
ships with sage-3.4. This built successfully. I basically untarred the
standard spkg, changed the spkg-install suitably and ran it within a
sage -sh session. I then built VTK with the following configuration for
cmake:
-DPYTHON_EXECUTABLE:FILEPATH=$SAGE_LOCAL/Frameworks/Python.framework/Versions/2.5/bin/python\
-DPYTHON_INCLUDE_PATH:PATH=$SAGE_LOCAL/Frameworks/Python.framework/Headers\
-DPYTHON_LIBRARY:FILEPATH=$SAGE_LOCAL/Frameworks/Python.framework/Versions/2.5/Python\
-DVTK_USE_CARBON:BOOL=ON
This built VTK perfectly.
I initially ran into problems like so:
sage: import vtk
Fatal Python error: Interpreter not initialized (version mismatch?)
$SAGE_LOCAL/bin/sage-sage: line 205: 1407 Abort trap
sage-ipython "$@" -i
But figured that my existing builds were confusing matters and once I
moved that old build out of the way, everything worked great. I was
able to do this:
sage: import vtk
sage: c = vtk.vtkConeSource()
[...]
I have the following questions:
1. Why isn't --enable-framework turned on by default for the sage
python build on the Mac? If this isn't a hassle can you please consider
making this the default?
2. What else would it take to get the VTK package to optional quality?
Thanks!
cheers,
prabhu
I really don't know if this is needed or not. It could well be a VTK
issue. I need to build VTK with Carbon support and I'm not sure that
requires a framework build of Python. Anyway, VTK tries to detect the
Python library to link to when it builds the Python wrappers. I think
it finds the system Python by default which obviously will not work.
When I point it to the libpython25.a file in
SAGE_LOCAL/lib/python2.5/config, I get link errors since my guess is
that file is not a proper universal library? Upon some digging,
fortunately, I seem to have an install.log lying around. Here is the
exact error message I got when linking to libpython25.a:
Linking CXX shared library ../bin/libvtkCommonPythonD.dylib
ld: common symbols not allowed with MH_DYLIB output format with the
-multi_module option
/Users/prabhu/src/build/sage-3.4/local/lib/python2.5/config/libpython2.5.a(object.o)
definition of common _Py_DivisionWarningFlag (size 16)
/Users/prabhu/src/build/sage-3.4/local/lib/python2.5/config/libpython2.5.a(pythonrun.o)
definition of common _Py_VerboseFlag (size 16)
/Users/prabhu/src/build/sage-3.4/local/lib/python2.5/config/libpython2.5.a(pythonrun.o)
definition of common _Py_DebugFlag (size 16)
/Users/prabhu/src/build/sage-3.4/local/lib/python2.5/config/libpython2.5.a(pythonrun.o)
definition of common _Py_FrozenFlag (size 16)
/Users/prabhu/src/build/sage-3.4/local/lib/python2.5/config/libpython2.5.a(pythonrun.o)
definition of common _Py_IgnoreEnvironmentFlag (size 16)
/Users/prabhu/src/build/sage-3.4/local/lib/python2.5/config/libpython2.5.a(pythonrun.o)
definition of common _Py_InteractiveFlag (size 16)
/Users/prabhu/src/build/sage-3.4/local/lib/python2.5/config/libpython2.5.a(pythonrun.o)
definition of common _Py_NoSiteFlag (size 16)
/Users/prabhu/src/build/sage-3.4/local/lib/python2.5/config/libpython2.5.a(parsetok.o)
definition of common _Py_TabcheckFlag (size 16)
/Users/prabhu/src/build/sage-3.4/local/lib/python2.5/config/libpython2.5.a(myreadline.o)
definition of common _PyOS_ReadlineFunctionPointer (size 16)
/Users/prabhu/src/build/sage-3.4/local/lib/python2.5/config/libpython2.5.a(myreadline.o)
definition of common __PyOS_ReadlineTState (size 16)
/usr/libexec/gcc/i686-apple-darwin8/4.0.1/libtool: internal link edit
command failed
If I leave the Python library unspecified it runs into linker errors
with symbols being undefined at link time. None of this happens with a
framework build.
I guess I could retry with a non-framework build but it really takes a
while to build on my machine and all previous attempts failed.
> Another problem is that if we changed the default for OSX we would
> need to force a rebuild of every other python component in Sage, so
> since we don't have any problems as it is seems plainly not worth it.
But isn't everything anyways built from source? So how would this
affect anything? In my case nothing else seems affected -- I rebuilt
Python and installed that over the existing build. I didn't test too
much apart from VTK related scripts though.
cheers,
prabhu
Well, I have seen this when I got the error first time (google is our
friend) but didn't believe the answer would work for the simple reason
that VTK is really well tested. I didn't want to mess with compilation
arguments before testing other options. Regardless, I did try a manual
link with -Wl,-single_module and it didn't work -- I got different
errors. I could try -fno-common but that would have to be done for the
Python build and not the VTK build. It appears that the problem is not
with VTK but the Python build since the linking fails for the Python
library. The VTK libraries are linked to each other quite nicely.
>> I guess I could retry with a non-framework build but it really takes a
>> while to build on my machine and all previous attempts failed.
>
> Sure. Let me know if the above works.
I've tried the above and a few other things too. I'm still all ears
though, so keep the suggestions coming.
>>> Another problem is that if we changed the default for OSX we would
>>> need to force a rebuild of every other python component in Sage, so
>>> since we don't have any problems as it is seems plainly not worth it.
>> But isn't everything anyways built from source? So how would this
>> affect anything? In my case nothing else seems affected -- I rebuilt
>> Python and installed that over the existing build. I didn't test too
>> much apart from VTK related scripts though.
>
> Well, it doesn't matter for builds from source too much, the real
> problem is when a user runs -upgrade for Sage.
Sorry for being dense. You mean when the user runs -upgrade with a
non-framework install? Suppose a user has a fresh install, would the
framework build cause problems when this user does a -upgrade?
IOW, is this only a problem for those with older non-framework builds?
Thanks.
cheers,
prabhu
What are the current issues with the framework build? A while back I
had a framework python build in sage that worked fine. But maybe
there was something I was missing or that I didn't take into account.
Also, what libpng and IOkit issues are you referring to?
Cheers,
Brian
This explains why my build of wxPython worked at all! I had done this
after making the modifications to create a framework build. I haven't
tried without the framework build.
> know that in SPD, we would like to be able to have an spkgs for
> matplotlib that includes real GUI support. Plus I know that some
> folks are obviously linterested in VTK, Mayavi stuff as well.
Yes, indeed, my humble vote in addition for a framework build.
cheers,
prabhu
OK, I will try this sometime and see if I run into difficulties.
cheers,
prabhu
Could you please share it? I have created sip (sip is something like
swig, needed to built pyqt) and pyqt packages here:
http://femhub.googlecode.com/files/sip.spkg
http://femhub.googlecode.com/files/pyqt.p1.spkg
the sip is 0.5MB, pyqt is 1MB, sip builds instantly, pyqt in about 10
min on my laptop and 7 min on my workstation (not in parallel).
So it nicely works on linux, however on mac, the sip package refuses
to build, because python is not built with framework support.
I will use pyqt using traits-qt backend for my gui applications.
VTK also doesn't build without the framework support, but we'll look
at it at scipy09 with Prabhu, so maybe we'll fix it. however, from
what I understood above, there is no way to fix pyqt to work with Sage
on Mac, unless we use framework.
Am I missing something? If that is the case, then it's an absolute
showstopper for me, if I can't use Sage as a framework for our gui
apps. I don't have time thought to invest it into porting things to
mac, so for the time being I chose the strategy to disable packages
that just don't build on Mac in our distribution (femhub.org) and
that's it.
Also, what is the state of the windows port of Sage --- will it be
possible to just maintain one spkg and it would build on windows, or
will it be necessary to maintain one spkg for linux/mac and another
one for windows?
Ondrej
At present the Windows port spkg's are completely different than on Linux/mac.
Obviously that's not what we want in the long run. However, things
are *very* different in Windows land than UNIX land, and something
that works under UNIX isn't going to "just work" under native Windows.
-- William
>> Also, what is the state of the windows port of Sage --- will it be
>> possible to just maintain one spkg and it would build on windows, or
>> will it be necessary to maintain one spkg for linux/mac and another
>> one for windows?
>
> At present the Windows port spkg's are completely different than on Linux/mac.
> Obviously that's not what we want in the long run. However, things
> are *very* different in Windows land than UNIX land, and something
> that works under UNIX isn't going to "just work" under native Windows.
Thanks for the clarification. Unfortunately I can't help with the
windows port in the next couple weeks.
My biggest problem is that if I want to try something on windows, I
need to bootup my virtualbox with windows 7, then the net connection
usually doesn't work, so I need to restart windows and it just takes
too much time. On mac, I just log to bsd.math and quickly
port/try/test something, it only takes a minute. Another problem is
that I am very slow doing any changes in the windows terminal, I can't
easily copy things in and out of the virtualbox etc.
Is there some way to install openssh into windows, so that I can leave
it running on my workstation somewhere and just use my terminal + ssh
to log into there and port to windows using this approach? That would
make me way more effective and I could help more with the porting and
testing my code in windows.
Ondrej
Ondrej, I put up a simple spkg and William kindly put it up as a nice
ticket along with all the resulting problems:
http://trac.sagemath.org/sage_trac/ticket/3924
Unfortunately, I have not had the time to look into this at all for the
last several weeks.
cheers,
prabhu
Thanks. That sounds like lots of stuff to fix. I think windows is a
higher priority for me now. Ironically, people who only use C++ in my
group already make nice windows packages, because they just ship one
binary and one or two libs. Me, as python user, need to ship lots of
stuff and libraries.
Ondrej
Thanks for sharing it. I will investigate both options. I am positive
that there must be some solution so that I can connect to in in 5
seconds and start hacking in 10 seconds and do everything from my
(ubuntu) desktop.
I will report later.
Ondrej
Yeah, that's what I thought. But maybe I can at least use it to test
the spkg packages. Maybe not, I don't know.
>
> I'm surprised by how bad you say VirtualBox support for Windows is.
> Using Windows via Parallels or VMware (which I've done) is pretty nice
> -- cut and paste, networking, etc., all typically works perfectly.
> Incidentally, I was literally about to install Windows Vista on
> Virtual Box, since I've been using Linux on Virtual Box (on my mac)
> lately and really like it. I hope my experience isn't as bad as for
> you.
Try it, it's not that bad. The network works for me in about 50% of
cases, etc. It could be a bug in Windows 7, that I use, I don't know.
But it's not as fast as just sshing into some box. So I want to figure
it out somehow.
Ondrej