[SciPy-dev] SciPy on MacOS X (almost)
J Nicholas Laneman
jnl at allegro.mit.edu
Mon Feb 18 19:39:16 EST 2002
Hi Everyone,
First, let me say THANKS for SciPy! A colleague and I have begun
using Python, Numeric, and SciPy exclusively for our research (instead
of MATLAB). While it's been a little rough here in the beginning,
already we can see a lot of advantages to making the switch.
My main reason for posting is to try to help push along support for
MacOS X. I noticed some recent postings on this subject, but was not
a member of the list so could not reply to them directly. To
summarize, I seem to have successfully built SciPy using the Fink
tools, but have some errors when trying to import it (which have also
shown up in other contexts on this list). Any help in getting this
stuff working would be greatly appreciated! If there is interest, I
can look into getting SciPy added as a Fink package.
Details of my attempt are below.
Cheers,
Nick
IMPORT ERRORS
-------------
[localhost:~] jnl% python
Python 2.2 (#1, Feb 17 2002, 21:17:18)
[GCC 2.95.2 19991024 (release)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import scipy
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/loc/fink/lib/python2.2/site-packages/scipy/__init__.py", line
41, in ?
from handy import *
File "/loc/fink/lib/python2.2/site-packages/scipy/handy.py", line 1,
in ?
import Numeric
File "/loc/fink/lib/python2.2/site-packages/Numeric/Numeric.py",
line 119, in ?
arrayrange = multiarray.arange
AttributeError: 'module' object has no attribute 'arange'
>>> from scipy.integrate import *
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File
"/loc/fink/lib/python2.2/site-packages/scipy/integrate/__init__.py",
line 23, in ?
scipy.somenames2all(__all__, _moddict, globals())
File "/loc/fink/lib/python2.2/site-packages/scipy/__init__.py", line
9, in somenames2all
exec("from %s import %s" % (key, string.join(namedict[key],',')),
gldict)
File "<string>", line 1, in ?
File
"/loc/fink/lib/python2.2/site-packages/scipy/integrate/quadrature.py",
line 1, in ?
from orthogonal import P_roots
File
"/loc/fink/lib/python2.2/site-packages/scipy/integrate/orthogonal.py",
line 53, in ?
from MLab import eig
File "/loc/fink/lib/python2.2/site-packages/Numeric/MLab.py", line
17, in ?
import RandomArray
File "/loc/fink/lib/python2.2/site-packages/Numeric/RandomArray.py",
line 3, in ?
import LinearAlgebra
File
"/loc/fink/lib/python2.2/site-packages/Numeric/LinearAlgebra.py", line
8, in ?
import lapack_lite
ImportError: Failure linking new module
>>>
BUILD
-----
Using the latest fink distribution (http://fink.sourceforge.net/),
with Python 2.2 and g77 2.95.2 packages, I was able to build SciPy
under MacOS X 10.1 with only a few differences to the SciPy
distribution. These include:
1) In setup.py, setting X11 = 1 because the line
find /usr -name "libX11*" -print
does not find the X11 libraries through a symbolic link. My X11
files are on another partition, with /usr/X11R6 a symbolic link
pointing to them.
2) In build_flib.py, using things like '"' + object '"' to encapsulate
object filenames with things like "Power Macintosh" in them. The
space in the object name seems to give the Apple linker fits.
SciPy makes a temporary directory called "build", with a directory
called
temp.darwin-5.2-Power Macintosh-2.2
into which most of the object files are placed. I don't know
exactly what function call genereates this file name, and in
particular the "Power Macintosh" part, so I tried to work around
it.
3) In build_flib.py, running "ranlib" on libraries seems necessary
after running "ar" to make them.
4) In a few of the C files, malloc.h doesn't seem to exist in OS X,
but including <stdlib.h> instead of <malloc.h> seems to work (as
someone pointed out on this list earlier).
Here is a diff file of the changes I made to get things working. I
apologize that they are probably very kludgy, but I don't know enough
about Python or SciPy to do it "the right way".
diff -r SciPy-0.1.new/build_flib.py SciPy-0.1/build_flib.py
200c200
< object_files = map(lambda x,td=temp_dir: '"' + os.path.join(td,x) + '"',object_list)
---
> object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)
216c216
< module_switch + ' -c "' + source + '" -o ' + object
---
> module_switch + ' -c ' + source + ' -o ' + object
242c242
< lib_file = '"' + os.path.join(output_dir,'lib'+library_name+'.a') + '"'
---
> lib_file = os.path.join(output_dir,'lib'+library_name+'.a')
250,252d249
< print cmd
< os.system(cmd)
< cmd = 'ranlib -s %s' % lib_file
diff -r SciPy-0.1.new/setup.py SciPy-0.1/setup.py
200d199
< X11 = 1
diff -r SciPy-0.1.new/special/cephes/polmisc.c SciPy-0.1/special/cephes/polmisc.c
7c7
< #include <stdlib.h>
---
> #include <malloc.h>
diff -r SciPy-0.1.new/special/cephes/polyn.c SciPy-0.1/special/cephes/polyn.c
68c68
< #include <stdlib.h>
---
> #include <malloc.h>
More information about the SciPy-Dev
mailing list