Wiki

Clone wiki

PyCA / Installing on Windows

Cygwin

Cygwin is no longer the recommended way to install PyCA on Windows. While this method will work, ITK no longer supports compiling in cygwin and CUDA has not and will probably never support compiling kernels in cygwin. This means you can use PyCA in cygwin, but without ITK or CUDA support.

Instead, please follow the directions in the next section to install using Visual Studio (note that these instructions work with the free Visual Studio Express version).

Visual Studio Express 2012

These instructions use the Express version of Visual Studio, because it's free. The full version works just as good. I haven't tested with 2013 and doubt it is supported by CMake yet.

At this stage, PyCA builds on Windows natively using ITK, but CUDA support is not yet working. Note that building on Windows is still a very fragile process, so be sure to read this entire document first and follow these instructions as closely as possible.

There are four stages to installation of PyCA in Windows: Preparation by downloading and installing the prerequisites, configuring and generating the buildsystem using CMake, building PyCA using Visual Studio, and installation using Visual Studio and a few manual steps.

Preparation

  • Note that lapack and blas are no longer used by pyca.
  • Install ActiveState Python. Be sure to only install the 2.7 version, as PyCA as well as many other libraries do not yet (and may never) support 3.*.
  • Install the scipy stack. Be sure to grab the 2.7 version for your platform.
  • Install Visual Studio Express 2012 for your platform
  • Install cmake, using the installer from cmake.org
  • Install msysgit and a git client (I recommend Atlassian SourceTree) and clone pyca into C:\src\pyca. Alternatively, if you are behind a firewall and cannot use git directly, you may download a .zip file of the repository from this bitbucket page.
  • Download swig. You can find a zip-file for swigwin here. Just download and extract into C:\src. The swig executable is in the top level of the extracted directory. You will need to point cmake to that executable when configure PyCA.
  • Download/Link FFTW. You can download precompiled DLLs for your architecture from fftw.org/install/windows.html. Extract these somewhere, like where you extracted the swigwin zip file. Then using the Developer Command Prompt in Start Menu->Microsoft Visual Studio 2012->Developer Command Prompt, enter that directory and run lib /def:libfftw3-3.dll. Do the same for the f and l versions of the library as well.
  • Download the boost source library, available here. Again, extract the downloaded archive into C:\src. Note that we do not link against against any boost libraries, so there is no need to install a compiled version of boost.
  • Optional: This is also a good time to install other python packages that you will likely need to use with PyCA. You can install mpi4py from here as well as pycuda. The AppUtils package (needed by some of jhinkle's projects) also makes use of the PyYaml library, which is a pure python package that can be downloaded installed using their included setup.py.
  • Optional: install ITK by cloning from itk.org into C:\src\ITK then building with CMake in C:\build\ITK. To do this, fire up cmake-gui, point it at the source directory and choose a build directory. Then hit configure. Note that you will need to enable building shared libraries, and that building testing and examples are not needed for pyca. After you've hit configure enough times that there are no red entries, hit generate. Then navigate to the build directory and double-click the ALL_BUILD.soln file. That will open visual studio express, where you can run Build->Build Solution. This can build in the background while you perform the next steps. Just be sure to let it finish before the final step of building PyCA.
  • Optional: install Cuda using the installer at their website. Note that any version >3.2 should work, and the pyca developers are mostly using CUDA 5.5 now.

CMake Configuration

Configure pyca in Cmake. Open cmake-gui and point it to the source dir C:\src\pyca and build dir C:\build\pyca. When you hit configure you will be asked to specify the generator for this project; choose 'Visual Studio 11' if you have VSE 2012. Then you will be greeted with some error messages and new options will appear in red. The following steps describe how to proceed

  • The first time you hit configure, CMake will complain about many things. You should now set SWIG_EXECUTABLE, which should point to swig.exe in the swig directory that you extracted into C:\src. Hit configure again.
  • There will be many new options in red now. At the top of the list is Boost_DIR and Boost_INCLUDE_DIR. You only need to set Boost_INCLUDE_DIR to C:\src\boost_1_54_0. There will also be many CUDA options. For now, find USE_CUDA and unmark the checkbox. Then hit configure again.
  • CMake will still complain that it cannot find FFTW. Set FFTWF_LIB to C:/src/fftw-3.3.3-dll32/libfftw3f-3.lib, FFTWD_LIB to C:/src/fftw-3.3.3-dll32/libfftw3-3.lib, and FFTW_INCLUDE_PATH to C:/src/fftw-3.3.3-dll32. Hit configure again
  • Find the BUILD_SHARED_LIBS option and uncheck the box. You may need to click Configure once or twice before this option will appear.
  • Set the PYTHON_INSTALL_DIR to C:/Python27/lib/site-packages.
  • There will still be red warnings in the output. You can safely ignore these as long as it says 'Configuring done'. At this point hit Generate to set up the buildsystem.

Building

Now it's time to compile the project using the following steps:

  • Open the ALL_BUILD.soln file in C:\build\pyca in Visual Studio.
  • Before building, go to BUILD->Configuration Manager.
  • In Configuration Manager, set Active solution configuration to Release.
  • Uncheck the build checkmarks next to clean_py_package, delint_cxx, and delint_python if they are checked.
  • Close Configuration Manager
  • BUILD->Build Solution. This will attempt to compile the project.

Installation

  • Now in the Configuration Manager, enable the INSTALL target and build. This will copy files into C:\Python27\Lib\site-packages\PyCA.
  • Unfortunately, not all the required libraries are copied over during installation. In particular, you should copy the _Core.pyd file from the PyCA build directory, as well as libfftwf3-3.dll and libITKCommon-4.4.dll into that installation directory manually.

Known Issues

32-bit vs 64-bit

If everything compiles in visual studio, but you get link errors, chances are you have installed an incompatible library. I have tested with all 32-bit libraries. The main ones to consider are FFTW and the optional ITK and CUDA. Each of those have 32-bit options and you should use those when entering the library paths in cmake. I will test building with win64 generator in cmake soon so that we can use 64bit everything.

CMake

CMake will not generally find all necessary dependencies. The following notes should be followed when running cmake after downloading and installing the necessary dependencies.

  • FFTW: Be sure to use 32-bit FFTW libraries downloaded and installed from this link. Unzip that wherever you like and then provide that as the FFTW_INCLUDE_PATH in cmake. You will also need to provide FFTWF_LIB (libfftw3f-3.lib) and FFTWD_LIB (libfftw3-3.lib) manually. You don't need the threads lib.

-

Misc tips

  • I (Jacob) prefer to keep a C:\src directory for cloning the source repos, and create build directories in C:\build. This is just personal preference and nothing within PyCA depends on using these directory names. Just don't forget where you put stuff.
  • For setting the $PYTHONPATH, it's useful to have the Rapid Environment Editor.

Updated