Setting up ANUGA with Python 2.5 on Win32 using MinGW ===================================================== NOTE: Shell examples all use the MSYS bash shell. You'll need MSYS anyway to build NetCDF, so I don't see this as a huge problem. 1. Get Python2.5 I used the Enthought python distribution from (http://enthought.com/products/epd.php), as building VTK on Win32 with MinGW appears to be very difficult, if not impossible. 2. Get MinGW/MSYS from http://mingw.org ANUGA requires MinGW anyway, but MSYS is needed for the source build of NetCDF. 3. Uninstall ScientificPython Enthought's version of ScientificPython doesn't have the NetCDF interface. It needs to be removed before the new one can be built. Remove C:\Python25\Lib\site-packages\Scientific....egg directory. 4. Install NetCDF from source Get the NetCDF sources from (http://www.unidata.ucar.edu/downloads/netcdf/index.jsp). Unpack them somewhere (I used c:\code\build). Fire up an MSYS shell and cd to the top of the NetCDF directory. Building the NetCDF DLL requires some specific compiler flags, or else you get strange errors where the compiler is unable to determine sizeof(struct stat). $ 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 $ make $ make check $ make install This will install the stuff into c:\netcdf. The ScientificPython build scripts get confused and try to copy a `netcdf.dll', when this produces a `libnetcdf-4.dll', so make a copy so it doesn't choke: $ cp /c/netcdf/bin/{libnetcdf-4.dll,netcdf.dll} 5. Install Numeric from source The age of the Numeric package means that it's not in the Enthought distribution, but we need it for ANUGA. Grab the last Numeric sources (24.2) from (http://sourceforge.net/project/showfiles.php?group_id=1369&package_id=1351), extract somewhere and build using distutils: $ python setup.py build -c mingw32 install 6. Install ScientificPython from source Grab ScientificPython from (http://sourcesup.cru.fr/frs/?group_id=180&release_id=966) and extract somewhere. The setup.py needs to be fixed, as it makes some bad assumptions about the NetCDF prefix layout. I present a unified diff of the changes. diff -u ScientificPython-2.7.8.a/setup.py ScientificPython-2.7.8/setup.py --- ScientificPython-2.7.8.a/setup.py Fri Nov 30 05:07:37 2007 +++ ScientificPython-2.7.8/setup.py Fri Mar 28 12:30:50 2008 @@ -82,8 +82,8 @@ if netcdf_dll is None: print "Option --netcdf_dll is missing" raise SystemExit - netcdf_include = netcdf_prefix - netcdf_h_file = os.path.join(netcdf_prefix, 'netcdf.h') + netcdf_include = os.path.join(netcdf_prefix, 'include') + netcdf_h_file = os.path.join(netcdf_include, 'netcdf.h') netcdf_lib = netcdf_dll data_files.append(('DLLs', [os.path.join(netcdf_dll, 'netcdf.dll')])) scripts.append('scientific_win32_postinstall.py') @@ -97,7 +97,7 @@ ['Src/Scientific_netcdf.c'], include_dirs=['Include', netcdf_include] + arrayobject_h_include, - library_dirs=[netcdf_lib], + library_dirs=[netcdf_lib, os.path.join(netcdf_prefix, 'lib')], libraries = ['netcdf'], extra_compile_args=extra_compile_args)] Compile and install ScientificPython: $ NETCDF_PREFIX=/c/netcdf python setup.py --netcdf_dll=c:\\netcdf\\bin build -c mingw32 install The install process for ScientificPython copies netcdf.dll into C:\Python25\DLLs (or whatever the Python root is). This will cause breakage as it's linked against libnetcdf-4.dll. Fix this: $ mv /c/Python25/DLLs/{netcdf.dll,libnetcdf-4.dll} Run the ANUGA unit tests to make sure that it works. If everything's good, the source directories and the installed path for NetCDF can be removed.