| 1 | How to build nixpy on Windows |
| 2 | ============================= |
| 3 | |
| 4 | The following guide shows build options for both, 32- and 64-bit. They are marked with :three::two: and :six::four: in the text. |
| 5 | |
| 6 | Dependencies |
| 7 | ------------ |
| 8 | |
| 9 | 1. **Required prior to python build** |
| 10 | - Navigate to the instructions for building nix on windows and follow the steps there to set up all necessary win build tools. |
| 11 | |
| 12 | 2. **Nix for windows** |
| 13 | - Install nix for windows in `C:\opt\nix` using the installer provided on github (https://github.com/G-Node/nix/releases), get the correct version (:three::two: or :six::four:) |
| 14 | - Make sure `C:\opt\nix\bin` is added to the windows PATH |
| 15 | |
| 16 | 3. **Python2.7** |
| 17 | - Obtain python2.7.8 64-bit for windows, get the correct version (:three::two: or :six::four:) |
| 18 | - Make sure python is added to the windows PATH, e.g. `C:\Python27` |
| 19 | |
| 20 | 4. **NumPy**: |
| 21 | - :three::two: Get the 32-bit version of numpy from: http://sourceforge.net/projects/numpy/files/NumPy/ |
| 22 | - :six::four: Get the 64-bit version of numpy from: http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy |
| 23 | |
| 24 | 5. **Pip**: |
| 25 | - Obtain "pip" for python2.7 (https://pip.pypa.io/en/latest/installing.html), get the correct version (:three::two: or :six::four:) |
| 26 | - Make sure pip is added to the windows PATH, e.g. `C:\Python27\Scripts` |
| 27 | |
| 28 | 6. **Boost**:<br> |
| 29 | Again, if you have not yet done so, head over to the instructions for building nix on windows to see how to build boost. Additionally we have to do the following: |
| 30 | - We need to rebuild boost with extended options compared to the nix build. Rebuild boost with:<br> |
| 31 | :three::two: |
| 32 | ``` |
| 33 | > .\b2 install -j4 -a --prefix=C:\opt\boost toolset=msvc architecture=x86 address-model=32 threading=multi variant=release link=static runtime-link=shared --with-python |
| 34 | ```<br> |
| 35 | :six::four: |
| 36 | ``` |
| 37 | > .\b2 install -j4 -a --prefix=C:\opt\boost toolset=msvc architecture=x86 address-model=64 threading=multi variant=release link=static runtime-link=shared --with-python |
| 38 | ```<br> |
| 39 | 7. **Environment variables**:<br> |
| 40 | Set the following environment variables using `set VAR=value` or `setx VAR "value" /m` to make them permanent. For the latter you will need to start a cmd window with admin rights. (right click the cmd icon and run as admin) Check if an environmental variable is set using `echo %VAR%`. If a variable should not seem to work try adding its' value to PATH too! |
| 41 | - `BOOST_INCDIR = C:\opt\boost\include\boost-1_56` NOTE: insert your boost version for `1_56` |
| 42 | - `BOOST_LIBDIR = C:\opt\boost\lib` |
| 43 | - `NIX_LIBDIR = C:\opt\nix\lib` |
| 44 | - `NIX_INCDIR = C:\opt\nix\include` |
| 45 | - `VS90COMNTOOLS = <VSPATH>\Common7\Tools` where `<VSPATH>` is the path where you installed visual studio. (e.g. "C:\Program Files (x86)\Microsoft Visual Studio 12.0") |
| 46 | - `VS120COMNTOOLS = <VSPATH>\Common7\Tools` where `<VSPATH>` is the path where you installed visual studio. (e.g. "C:\Program Files (x86)\Microsoft Visual Studio 12.0") |
| 47 | - Make sure `<VSPATH>` is added to PATH too! |
| 48 | |
| 49 | 8. **vcvarsall.bat**:<br> |
| 50 | :three::two:Execute once manually `vcvarsall.bat x86` from the cmd line.<br> |
| 51 | :six::four:Execute once manually `vcvarsall.bat x86_amd64` from the cmd line. |
| 52 | |
| 53 | 9. **Build**:<br> |
| 54 | NOTE: instead of steps 7. & 8. you can grab the code from 10. to set all vars. Make sure you are connected to the internet to allow missing packages to download. Now build via: |
| 55 | ``` |
| 56 | python setup.py build |
| 57 | python setup.py bdist --format=msi |
| 58 | ``` |
| 59 | afterwards you should have an installer in "dist\" and a "nix\core.pyd" file. NOTE: to make python build again delete the "core.pyd" file in "nix". |
| 60 | |
| 61 | 10. **Troubleshooting**:<br> |
| 62 | - If the PATH seems to be wrong (e.g. `python>>> import nix` fails with missing DLL) be sure to restart the Command Prompt _and_ restart Visual Studio before launching any Command Prompt from there |
| 63 | - If you get a python error from "msvc9compiler.py", "query_vcvarsall" saying "ValueError: [u'path']" this means that "vcvarsall.bat" is not being found. Check the environmental vars and execute `vcvarsall.bat x86_amd64` manually. |
| 64 | - If you get linker errors either the "boost_python" lib or the "nix" lib are not being found. Check the environmental vars and check whether "nix.lib" is in `<NIXPATH>\lib` and whether "boost_python-vc120-mt-1_55.lib" (with your version numbers) is in `<BOOSTPATH>\lib` |
| 65 | - If you find steps 7. & 8. complicated grab this code, put it in a batch file and run it whenever you are about to build nixpy: |
| 66 | |
| 67 | :three::two: |
| 68 | ``` |
| 69 | set NIX_LIBDIR=C:\opt\nix\lib |
| 70 | set NIX_INCDIR=C:\opt\nix\include |
| 71 | set BOOST_LIBDIR=C:\opt\boost\lib |
| 72 | set BOOST_INCDIR=C:\opt\boost\include\boost-1_56 |
| 73 | set VS90COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools |
| 74 | set VS120COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools |
| 75 | vcvarsall.bat x86 |
| 76 | ``` |
| 77 | :six::four: |
| 78 | ``` |
| 79 | set NIX_LIBDIR=C:\opt\nix\lib |
| 80 | set NIX_INCDIR=C:\opt\nix\include |
| 81 | set BOOST_LIBDIR=C:\opt\boost\lib |
| 82 | set BOOST_INCDIR=C:\opt\boost\include\boost-1_56 |
| 83 | set VS90COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools |
| 84 | set VS120COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools |
| 85 | vcvarsall.bat x86_amd64 |
| 86 | ``` |
| 87 |