-
Notifications
You must be signed in to change notification settings - Fork 7
Build windows
On this page, I document how I build feff85exafs on a Windows 7 machine using gfortran.
I had to do a lot of prep work to get my machine ready to do the build. Hopefully, this will be simpler in the future. For now, this was my path through the problem.
At this time (2015-02-11), the build scripts are such that running scons from the top level folder on Windows will correctly build all of Feff (presuming you have followed all the instructions below). scons install
will install all the stuff into Larch's space (usually C:\Program Files\larch
). Once installed, the fortran and C example programs in wrappers\
can be successfully built and run.
The Python and Perl wrappers are not yet working on Windows and the unit testing system has not yet been tested.
Table of Contents
Since the build system and the unit testing system use Python, you must have a Python interpreter on your computer. Go to https://www.python.org/downloads/ and download the installer for Python 2.7. Do not install Python 3.4. Everything on this page presumes you are using 2.7.
Download, double click to install.
Note that the python executable is C:\Python27\python.exe
. Make sure that C\Python27
is in your execution path.
The build and unit testing framework, as well as many future uses of feff85exafs, require Matt's Larch. Larch has some dependencies:
- numpy
- scipy
- h5py
- matplotlib
- sqlalchemy
It is quite a lot of work to compile and install all these binary components and the various libraries they require. Much simpler is to use one of the many repositories of pre-built packages. There are multiple ways to solve this problem (several of which are discussed on this page). I chose to use the packages maintained by Christoph Gohlke.
First you must upgrade to a more recent version of the pip
python package installer. I did this by following these instructions. Following that page, download this file, preserving its name as get-pip.py
, then do
python get-pip.py
This will install the latest version of pip6 as C:\Python27\Scripts\pip.exe
.
From Christoph Gohlke's page, download the "wheel" files for each of the packages listed above. Be sure to grab the cp27
versions build for your architecture. On the computer I was using, I grabbed the *cp27‑none‑win32.whl
, like so:
- numpy:
numpy‑1.8.2+mkl‑cp27‑none‑win32.whl
- scipy:
scipy‑0.15.1‑cp27‑none‑win32.whl
- h5py:
h5py‑2.4.0‑cp27‑none‑win32.whl
- matplotlib:
matplotlib‑1.4.3rc1‑cp27‑none‑win32.whl
- sqlalchemy:
SQLAlchemy‑0.9.8‑cp27‑none‑win32.whl
Version numbers may have changed by the time you read this.
Once downloaded, do
pip install numpy‑1.8.2+mkl‑cp27‑none‑win32.whl
and so on for all 5 packages. Note that pip will follow and install additional dependencies.
While wxPython is not strictly required for building feff85exafs, Larch is significantly crippled without it.
Grab the py27
installer file for your computer architecture from the wxPython download site. I used the 32-bit Python 2.7 file: wxPython3.0-win32-py27
.
Download, double click to install.
At a command line, do each of the following
pip install nose
pip install termcolor
pip install sphinx
pip install wxutils
pip install wxmplot
pip install pyepics
While only nose is strictly required for feff85exafs, installing all of these will leave you with a fully functioning Larch.
Use git to clone a copy of larch:
git clone https://github.com/xraypy/xraylarch.git
or use the neat-o GitHub client for Window to clone a copy. (You do have git installed already, right? If not, here's the download site.)
Once cloned, cd into its folder and, at the command line, do
python setup.py build
If everything above was done correctly, the build should go smoothly.
You now need to install Larch. Try this:
python setup.py install
That may or may not work, depending on the configuration of your Windows machine. The problem is that the installation wants to write files to C:\Program Files\Larch
. As a normal user, you may not be able to write to that location. If that is the case, you will need to start a command prompt as the administrator. Once the command window oipens, cd to the location of the larch repository and do
python setup.py install
With admin privilege, this command will now run to completion.
As discussed elsewhere on this wiki, we are using a Fortran 2008 implementation of a JSON parser/writer to handle passing configuration information between the free-standing Feff executables. This will only compile correctly with gfortran 4.9 or later. (Apparently Intel Fortran and Visual Studio can also be made to work, but I have no experience with either of those.)
Unfortunately, gcc 4.9 is a bit bleeding edge at the time of this writing. At this time, MinGW is shipping with gcc 4.8. To get 4.9, I used the nifty MinGW-builds effort. Download and double click. You now have gcc 4.9.
You, like me, may already have MinGW on your computer. If you have a copy of Demeter, Demeter comes with enough of MinGW to compile up most Perl modules with binary components. Currently the Demeter installer puts gcc 4.7 on your computer and puts its location in the execution path.
On my computer, the gcc 4.9 executables were installed into C:\Program Files\mingw-w64\x86_64-4.9.2-win32-seh-rt_v3-rev1\mingw64\bin
. I am doing all this work in the MinGW terminal, which runs bash. I source a file containing the following to get the execution PATH munged correctly to use gcc 4.9. I also define some useful aliases and put several other things that we'll need in the PATH.
alias ls='ls -F --color=always'
alias rm='rm -i'
alias scons='python /c/Python27/Scripts/scons.py'
alias pip='/c/Python27/Scripts/pip.exe'
## need to put the location of gcc 4.9 at the front of the path
## (Demeter, for instance, comes with 4.7, which won't work for json-fortran)
export PATH=/C/Program\ Files/mingw-w64/x86_64-4.9.2-win32-seh-rt_v3-rev1/mingw64/bin:$PATH
## want the installation location of swig at the end of the path
export PATH=$PATH:/c/Program\ Files/swigwin-3.0.5
export PATH=$PATH:/c/Program\ Files/larch/bin
export PATH=$PATH:/c/Program\ Files/larch/dlls/win32
NOTE: Unix-style separators (/
) are needed when working in Bash and spaces must be escaped. Locations may be different on your computer.
NOTE: I was not able to make the build work using the normal Windows command prompt and I have not tried at all with PowerShell. YMMV with those shells.
At this time, SWIG is used to generate perl and python wrappers around the feffpath
library. Matt is working on a wrapper that uses ctypes. Bruce has an Inline::C wrapper on his todo list. SWIG was a quick and easy way to get enough functionality written to get the unit test suite working correctly.
Grab the SWIG package here. This is a zip file. You will have to unzip it someplace. I unpacked mine in C:\Program Files
. The SWIG executable is, therefore, C:\Program Files\swigwin-3.0.5\swig.exe
.
http://www.microsoft.com/en-us/download/details.aspx?id=44266
http://stackoverflow.com/questions/3047542/building-lxml-for-python-2-7-on-windows
Whew! That was a lot of stuff. Now, you are ready to build feff85exafs.
From here, the build works exactly the same as on any other platform.
-
Use git to clone a copy of feff85exafs:
git clone https://github.com/xraypy/feff85exafs.git
-
cd to the feff85exafs folder
-
do
python C:\Python27\Scripts\scons.py
or (using the allias I defined above)scons
. Wait as it chugs away. -
To test everything, ...
-
To install everything, do
scons install
. This will put all the Feff stuff in the Larch location, usuallyC:\Program Files\larch
. -
To build the fortran and C sample programs, cd to
wwrappers\fortran\
orwrappers\C\
. Doscons
to build the example programs. In each folder, there is a program calledmakepath.exe
which generates a couple offeffNNNN.dat
file for copper metal. In the C folder, there is also a program callederrors.exe
which exercises the library's error reporting capabilities.