1 | Setting up ANUGA with Python 2.5 on Win32 using MinGW |
---|
2 | ===================================================== |
---|
3 | |
---|
4 | NOTE: Shell examples all use the MSYS bash shell. You'll need MSYS |
---|
5 | anyway to build NetCDF, so I don't see this as a huge problem. |
---|
6 | |
---|
7 | 1. Get Python2.5 |
---|
8 | |
---|
9 | I used the Enthought python distribution from |
---|
10 | (http://enthought.com/products/epd.php), as building VTK on Win32 with |
---|
11 | MinGW appears to be very difficult, if not impossible. |
---|
12 | |
---|
13 | 2. Get MinGW/MSYS from http://mingw.org |
---|
14 | |
---|
15 | ANUGA requires MinGW anyway, but MSYS is needed for the source build |
---|
16 | of NetCDF. |
---|
17 | |
---|
18 | 3. Uninstall ScientificPython |
---|
19 | |
---|
20 | Enthought's version of ScientificPython doesn't have the NetCDF |
---|
21 | interface. It needs to be removed before the new one can be built. |
---|
22 | |
---|
23 | Remove C:\Python25\Lib\site-packages\Scientific....egg directory. |
---|
24 | |
---|
25 | 4. Install NetCDF from source |
---|
26 | |
---|
27 | Get the NetCDF sources from |
---|
28 | (http://www.unidata.ucar.edu/downloads/netcdf/index.jsp). Unpack them |
---|
29 | somewhere (I used c:\code\build). Fire up an MSYS shell and cd to the |
---|
30 | top of the NetCDF directory. Building the NetCDF DLL requires some |
---|
31 | specific compiler flags, or else you get strange errors where the |
---|
32 | compiler is unable to determine sizeof(struct stat). |
---|
33 | |
---|
34 | $ CFLAGS='-march=i686 -O2 -pipe -fomit-frame-pointer -D__MSVCRT_VERSION__=0x0601' ./configure --enable-dll --disable-f77 --disable-cxx --disable-examples --disable-utilities --enable-shared --disable-static --prefix=/c/netcdf |
---|
35 | $ make |
---|
36 | $ make check |
---|
37 | $ make install |
---|
38 | |
---|
39 | This will install the stuff into c:\netcdf. The ScientificPython build |
---|
40 | scripts get confused and try to copy a `netcdf.dll', when this produces |
---|
41 | a `libnetcdf-4.dll', so make a copy so it doesn't choke: |
---|
42 | |
---|
43 | $ cp /c/netcdf/bin/{libnetcdf-4.dll,netcdf.dll} |
---|
44 | |
---|
45 | 5. Install Numeric from source |
---|
46 | |
---|
47 | The age of the Numeric package means that it's not in the Enthought |
---|
48 | distribution, but we need it for ANUGA. |
---|
49 | |
---|
50 | Grab the last Numeric sources (24.2) from |
---|
51 | (http://sourceforge.net/project/showfiles.php?group_id=1369&package_id=1351), |
---|
52 | extract somewhere and build using distutils: |
---|
53 | |
---|
54 | $ python setup.py build -c mingw32 install |
---|
55 | |
---|
56 | 6. Install ScientificPython from source |
---|
57 | |
---|
58 | Grab ScientificPython from |
---|
59 | (http://sourcesup.cru.fr/frs/?group_id=180&release_id=966) and extract |
---|
60 | somewhere. |
---|
61 | |
---|
62 | The setup.py needs to be fixed, as it makes some bad assumptions about |
---|
63 | the NetCDF prefix layout. I present a unified diff of the changes. |
---|
64 | |
---|
65 | diff -u ScientificPython-2.7.8.a/setup.py ScientificPython-2.7.8/setup.py |
---|
66 | --- ScientificPython-2.7.8.a/setup.py Fri Nov 30 05:07:37 2007 |
---|
67 | +++ ScientificPython-2.7.8/setup.py Fri Mar 28 12:30:50 2008 |
---|
68 | @@ -82,8 +82,8 @@ |
---|
69 | if netcdf_dll is None: |
---|
70 | print "Option --netcdf_dll is missing" |
---|
71 | raise SystemExit |
---|
72 | - netcdf_include = netcdf_prefix |
---|
73 | - netcdf_h_file = os.path.join(netcdf_prefix, 'netcdf.h') |
---|
74 | + netcdf_include = os.path.join(netcdf_prefix, 'include') |
---|
75 | + netcdf_h_file = os.path.join(netcdf_include, 'netcdf.h') |
---|
76 | netcdf_lib = netcdf_dll |
---|
77 | data_files.append(('DLLs', [os.path.join(netcdf_dll, 'netcdf.dll')])) |
---|
78 | scripts.append('scientific_win32_postinstall.py') |
---|
79 | @@ -97,7 +97,7 @@ |
---|
80 | ['Src/Scientific_netcdf.c'], |
---|
81 | include_dirs=['Include', netcdf_include] |
---|
82 | + arrayobject_h_include, |
---|
83 | - library_dirs=[netcdf_lib], |
---|
84 | + library_dirs=[netcdf_lib, os.path.join(netcdf_prefix, 'lib')], |
---|
85 | libraries = ['netcdf'], |
---|
86 | extra_compile_args=extra_compile_args)] |
---|
87 | |
---|
88 | Compile and install ScientificPython: |
---|
89 | |
---|
90 | $ NETCDF_PREFIX=/c/netcdf python setup.py --netcdf_dll=c:\\netcdf\\bin |
---|
91 | build -c mingw32 install |
---|
92 | |
---|
93 | The install process for ScientificPython copies netcdf.dll into |
---|
94 | C:\Python25\DLLs (or whatever the Python root is). This will cause |
---|
95 | breakage as it's linked against libnetcdf-4.dll. Fix this: |
---|
96 | |
---|
97 | $ mv /c/Python25/DLLs/{netcdf.dll,libnetcdf-4.dll} |
---|
98 | |
---|
99 | Run the ANUGA unit tests to make sure that it works. If everything's |
---|
100 | good, the source directories and the installed path for NetCDF can be |
---|
101 | removed. |
---|