[SciPy-user] How I compiled scipy on Windows

Gary Pajer pajer at iname.com
Mon Jan 5 20:06:52 CST 2004


I had intended to figure out how to compile scipy on Windows, and then write
a complete guide.

That's not what happened.  I have a guide, but it's not complete, and it
doesn't produce a fully functional scipy (it's close, though).  The road was
not straight, and I've forgotten some of the steps. Some of steps may be out
of order (not sure).  But I publish it here because it might be helpful as
is, and so that someone else can distill it and fix it up.

If anyone has comments, questions, corrections, or solutions, please post
them.

-gary

-----------------------------------------------------------

This is how I got scipy compiled.  It is no doubt overly complicated, but
it's what I did.  In particular, I used two different compilers ... cygwin
gcc for ATLAS and LAPACK, and MinGW for scipy.  Could this be the source of
lingering problems??

I started with the Enthough Edition of python 2.3.

MinGW:  I installed the latest version in case fixed the bug referred to
below.  It didn't, so it was probably unneccesary.  I installed it in
c:\mingw.  (I installed everything into paths without spaces to avoid that
problem)

CYGWIN:
Make sure you have the latest version of cygwin. An easy installation.  Go
to http://www.cywin.org  and follow the installation instructions.  Do
yourself a favor and do a "complete" installation.  Make sure you have
gcc-devel.  Make sure you have g77 (a package separate from gcc)

FFTW:
I installed this a while ago, and I don't remember how I did it.  Since I
don't remember, it must have gone smoothly.  I installed it into c:\fftw.


ATLAS:
Get the *latest* sources from http://math-atlas.sourceforge.net
Move everything to c:\atlas
execute "make"
answer all questions, choosing the default most of the time
take note of the name of the architecture that atlas has come up with.  in
my case, it was WinNT_PIIISSE1
execute "make install arch=XXXXX"
where XXXXX is the name of the archtecture that atlas built for.
WinNT_PIIISSE1 in my case.
Go get lunch.
(I moved the libraries to c:\atlib for my own convenience. See the
environment variables below under COMPILING SCIPY)

Note: many people have had trouble compiling atlas under cygwin.  If you
have the *newest* cygwin (and compilers) and the *newest* atlas, you
shouldn't have these problems.
Note: you may see warnings about performance degredation when compiling with
gcc 3.1 along with advice to use gcc 2.95.   Forget that advice; it's
outdated if you have the *latest* versions of everything.

You are probably left with an *incomplete* lapack library.  Check the size
of the library (in my case it is c:\atlas\lib\WinNT_PIIISSE1\liblapack.a)
If it's around 6 MB, you are somehow lucky.  It's probably around 250 kB.
You have to fix it.  First, install LAPACK.

LAPACK:
Get lapack.tgz from
I unpacked to c:\lapack
Rename c:\lapack\make.inc to c:\lapack\make.inc.original (or something)
In c:\lapack\INSTALL directory, there is a file make.inc.linux.
Move and rename to c:\lapack\make.inc
Execute "make lib"
(the linux make.inc works for cygwin.)

This creates c:\lapack\lapack_LINUX.a,  which is a complete lapack library.
Now we have to dig into this library and put in the atlas files that we
compliled earlier.  The instructions for how to do this are in the FAQ on
the atlas website:
http://math-atlas.sourceforge.net/errata.html#completelp
It amounts to cd'ing to your lapack path, and

  mkdir tmp
  cd tmp
  ar x ../liblapack.a
  cp <your LAPACK path & lib> ../liblapack.a
  ar r ../liblapack.a *.o
  cd ..
  rm -rf tmp


BUGS WORK-AROUND:

Something is screwy in the setup script, and at one point the build tries to
compile a file using the command "g".  Got around this one by copying
g++.exe to g.exe (thanks to Brett Oliver)


Because of a compiler bug, two functions in specfun.f won't compile, and the
install crashes.
There are two possible fixes.  I don't know which one is better.

First fix:
Brett Oliver had success by changing an optimization flag. Go to the
directory containing specfun.f  (.../scipy/Lib/special/specfun)  and compile
specfun.f by hand (without the -O3 flag):

g77 -Wall -fno-second-underscore -funroll-loops -march=pentium3
-malign-double -fomit-frame-pointer -c specfun.f -o specfun.o

this built a specfun.o which I copied to: build\temp.win32-2.3

goto COMPILING SCIPY



Second possible fix:
Short-circuit the two offending functions.  I short-circuit them by having
them return meaningless data.  I don't just comment the functions out (that
doesn't work).
***NB*** I am not at all sure that this doesn't break something else.  It
certainly breaks these functions, so it's obviously not ideal.

1. the function RMN2L, which starts at line 1439 in specfun.f
I replace this function with the following:
----------------------------
        SUBROUTINE RMN2L(M,N,C,X,DF,KD,R2F,R2D,ID)
  IMPLICIT DOUBLE PRECISION (A-H,O-Z)
        ID=1
        R2D=1.
 R2F=1.
        RETURN
        END
----------------------------

2. the function ASWFB, which starts at line 7837 in specfun.f
I replace this function with the following:
-----------------------------
        SUBROUTINE ASWFB(M,N,C,X,KD,CV,S1F,S1D)
 IMPLICIT DOUBLE PRECISION (A-H,O-Z)
        S1F=0.0D0
        S1D=0.0D0
 RETURN
 END
-----------------------------


COMPILING SCIPY:
set environment variables
set FFTW=c:\fftw
set ATLAS=c:\atlib  (I moved the ATLAS libraries to this directory)
set SWIG=c:\swig  (I don't know if this is necessary. I tried it at some
point and left it in)
use command
python setup.py --compiler=mingw32
cross your fingers.

Note: the first time I did this, python couldn't find something...
unfortunately, I neglected to take notes.  I think it was libpython23.a  I'm
sorry that I can't be more specific about this.  In any event, I now have a
file called c:\python23\libs\libpython23.a  Check to see if you have one.

INSTALLING:
python setup.py install --skip-build

In my case, scipy mostly works.  scipy.test() returns a few errors (one at
the 100% level). plt and xplt don't work.  gplt does work.

I'm still working on it.



More information about the SciPy-user mailing list