|
| 1 | + |
| 2 | +1. Introduction |
| 3 | +================ |
| 4 | + |
| 5 | +This document provides a HOWTO for building and using a python wheel for OREAnalytics. |
| 6 | + |
| 7 | +1.1 Other documentation |
| 8 | + |
| 9 | +This document is fairly terse. Refer to the resources below for more extensive information on the build and on the SWIG wrappers. |
| 10 | + |
| 11 | +ore\userguide.pdf |
| 12 | +ore-swig\README |
| 13 | +ore-swig\README.md |
| 14 | +ore-swig\OREAnalytics-SWIG\README |
| 15 | + |
| 16 | +1.2 Prerequisites |
| 17 | + |
| 18 | +- python - This HOWTO will require you to have the following tools up to date: |
| 19 | + |
| 20 | +python -m ensurepip |
| 21 | +pip install build |
| 22 | + |
| 23 | +- boost and swig: You need to either install the binaries, |
| 24 | + or install the source code and build yourself |
| 25 | + |
| 26 | +- ore and oreswig: You need to install the source code. |
| 27 | + Instructions for building with cmake are provided below. |
| 28 | + |
| 29 | +1.3 Environment variables |
| 30 | + |
| 31 | +For purposes of this HOWTO, set the following environment variables to the paths where the above items live on your machine, e.g: |
| 32 | + |
| 33 | +SET DEMO_BOOST_ROOT=C:\ORE\repos\boost\boost_1_81_0 |
| 34 | +SET DEMO_BOOST_LIB=C:\ORE\repos\boost\boost_1_81_0\lib\x64\lib |
| 35 | +SET DEMO_SWIG_DIR=C:\ORE\repos\swigwin-4.1.1 |
| 36 | +SET DEMO_ORE_DIR=C:\ORE\repos\ore |
| 37 | +SET DEMO_ORE_SWIG_DIR=C:\ORE\repos\oreswig |
| 38 | + |
| 39 | +2. Build ORE |
| 40 | +============ |
| 41 | + |
| 42 | +2.1 Generate the project files |
| 43 | + |
| 44 | +cd %DEMO_ORE_DIR% |
| 45 | +mkdir build |
| 46 | +cd %DEMO_ORE_DIR%\build |
| 47 | +set BOOST_INCLUDEDIR=%DEMO_BOOST_ROOT% |
| 48 | +set BOOST_LIBRARYDIR=%DEMO_BOOST_LIB% |
| 49 | +"C:\Program Files\CMake\bin\cmake.exe" -DMSVC_LINK_DYNAMIC_RUNTIME=OFF -DBoost_NO_WARN_NEW_VERSIONS=1 -DORE_USE_ZLIB=OFF -Wno-dev -G "Visual Studio 17 2022" -A x64 .. |
| 50 | +-> %DEMO_ORE_DIR%\build\ORE.sln |
| 51 | + |
| 52 | +2.2 Build |
| 53 | + |
| 54 | +cd %DEMO_ORE_DIR%\build |
| 55 | +"C:\Program Files\CMake\bin\cmake.exe" --build . --config Release |
| 56 | +-> %DEMO_ORE_DIR%\build\OREAnalytics\orea\Release\OREAnalytics-x64-mt.lib |
| 57 | + |
| 58 | +3. Build ORE-SWIG |
| 59 | +================= |
| 60 | + |
| 61 | +3.1 Build ORE-SWIG (wrapper and wheel) |
| 62 | + |
| 63 | +cd %DEMO_ORE_SWIG_DIR%\OREAnalytics-SWIG\Python |
| 64 | +set BOOST_ROOT=%DEMO_BOOST_ROOT% |
| 65 | +set BOOST_LIB=%DEMO_BOOST_LIB% |
| 66 | +set ORE_DIR=%DEMO_ORE_DIR% |
| 67 | +set PATH=%PATH%;%DEMO_SWIG_DIR% |
| 68 | +set ORE_STATIC_RUNTIME=1 |
| 69 | +python setup.py wrap |
| 70 | +python setup.py build |
| 71 | +python -m build --wheel |
| 72 | + |
| 73 | +3.2 Use the wrapper |
| 74 | + |
| 75 | +cd %DEMO_ORE_SWIG_DIR%\OREAnalytics-SWIG\Python\Examples |
| 76 | +set PYTHONPATH=%DEMO_ORE_SWIG_DIR%\OREAnalytics-SWIG\Python\build\lib.win-amd64-cpython-310 |
| 77 | +python commodityforward.py |
| 78 | + |
| 79 | +3.3 Use the wheel |
| 80 | + |
| 81 | +cd %DEMO_ORE_SWIG_DIR%\OREAnalytics-SWIG\Python\Examples |
| 82 | +python -m venv env1 |
| 83 | +.\env1\Scripts\activate.bat |
| 84 | +pip install %DEMO_ORE_SWIG_DIR%\OREAnalytics-SWIG\Python\dist\osre-1.8.3.2-cp310-cp310-win_amd64.whl |
| 85 | +python commodityforward.py |
| 86 | +deactivate |
| 87 | +rmdir /s /q env1 |
| 88 | + |
0 commit comments