@@ -39,87 +39,103 @@ You need to grab the source code for ORE and ORESWIG, e.g:
3939
4040# Environment Variables
4141
42- For purposes of this tutorial, we are going to create a series of environment
43- variables, prefixed with ` DEMO_ ` , pointing to the locations of the
44- prerequisites. Once you have installed all of the prerequisites listed above,
45- set the following environment variables pointing to the relevant directories,
46- e.g:
47-
48- SET DEMO_BOOST=C:\repos\boost\boost_1_86_0
49- SET DEMO_BOOST_LIB64=C:\repos\boost\boost_1_86_0\lib64-msvc-14.2
50- SET DEMO_SWIG_DIR=C:\repos\swigwin\swigwin-4.3.0
51- SET DEMO_ORE_DIR=C:\repos\Engine
52- SET DEMO_ZLIB_ROOT=C:\repos\vcpkg\packages\zlib_x64-windows (optional)
42+ For purposes of this tutorial, create environment variables pointing to ORE and
43+ its prerequisites, e.g:
44+
45+ SET BOOST_INCLUDEDIR=C:\repos\boost\boost_1_72_0
46+ SET BOOST_LIBRARYDIR=C:\repos\boost\boost_1_72_0\lib64-msvc-14.2
47+ SET SWIG_ROOT=C:\repos\swigwin\swigwin-4.3.0
48+ SET ZLIB_ROOT=C:\repos\vcpkg\packages\zlib_x64-windows (optional)
49+ SET ORE_DIR=C:\repos\ore
5350
5451# Build ORE and ORE-SWIG
52+
5553There are two ways to build ORESWIG: using ** cmake** , or using ** setup.py** .
5654With cmake, you can generate the wrapper. With setup.py you can generate both
5755the wrapper and the wheel. Regardless, ORE libraries must be built first.
5856
5957## Build ORE/ORESWIG via CMake
6058
61- Below are the commands to configure the ORE and ORE-SWIG build using cmake. If you do not
62- require compression, then you can omit the ` ZLIB_ROOT ` environment variable,
63- and, when running cmake, you can omit flag ` -DORE_USE_ZLIB=ON ` .
59+ Below are the commands to configure and build ORE and ORE-SWIG using cmake. If
60+ you do not require compression, then you can omit the ` ZLIB_ROOT ` environment
61+ variable, and, when running cmake, you can omit flag ` -DORE_USE_ZLIB=ON ` .
6462
65- To build ORE and ORE-SWIG simulataneously With cmake, you can generate the wrapper by
66- simply including ` -DORE_BUILD-SWIG=ON ` when configuring your ORE.
67-
68- cd %DEMO_ORE_DIR%
63+ cd %ORE_DIR%
6964 mkdir build
70- cd %DEMO_ORE_DIR%\build
71- SET BOOST_INCLUDEDIR=%DEMO_BOOST_ROOT%
72- SET BOOST_LIB64=%DEMO_BOOST_LIB%
73- SET ZLIB_ROOT=%DEMO_ZLIB_ROOT%
74- SET SWIG_ROOT=%DEMO_SWIG_DIR%
75- cmake -G "Visual Studio 17 2022" -A x64 .. -DBOOST_INCLUDEDIR=%BOOST% -DBOOST_LIBRARYDIR=%BOOST_LIB64% -DMSVC_LINK_DYNAMIC_RUNTIME=OFF -DORE-BUILD-SWIG=ON -DORE_BUILD_DOC=OFF -DORE_BUILD_EXAMPLES=OFF -DORE_BUILD_TESTS=OFF -DORE_BUILD_APP=OFF -DQL_BUILD_BENCHMARK=OFF -DQL_BUILD_EXAMPLES=OFF -DQL_BUILD_TEST_SUITE=OFF -DCMAKE_BUILD_TYPE=Release -DORE_USE_ZLIB=ON -DQL_ENABLE_SESSIONS=ON -DBoost_NO_SYSTEM_PATHS=ON
65+ cd %ORE_DIR%\build
66+ cmake .. -DMSVC_LINK_DYNAMIC_RUNTIME=OFF -DORE_USE_ZLIB=ON -DQL_ENABLE_SESSIONS=ON -DORE_BUILD_DOC=OFF -DORE_BUILD_EXAMPLES=OFF -DORE_BUILD_TESTS=OFF -DORE_BUILD_APP=OFF -DQL_BUILD_BENCHMARK=OFF -DQL_BUILD_EXAMPLES=OFF -DQL_BUILD_TEST_SUITE=OFF
7667 cmake --build . --config Release
7768
78- Make sure to add the location of the ORE-SWIG package to your PYTHONPATH, e.g.
69+ Make sure to add the location of the ORE-SWIG package to your PYTHONPATH, e.g:
7970
80- SET PYTHONPATH=%DEMO_ORE_DIR %\build;%DEMO_ORE_DIR %\build\ORE-SWIG\Release
71+ SET PYTHONPATH=%ORE_DIR %\build\ORE-SWIG;%ORE_DIR %\build\ORE-SWIG\Release
8172
8273## Build ORE/ORESWIG via setup.py
8374
84- If using the setup.py method, you would have to build ORE with cmake as demonstrated
85- above, but, when configuring cmake, disable the flag ` -DORE_BUILD-SWIG=OFF ` . Once
86- ORE libraries have been built, below are the commands to build the ORESWIG Python
87- wrapper and wheel using setup.py. If you do not require compression, then you can
88- omit the ` ORE_USE_ZLIB ` environment variable.
75+ If using the setup.py method, you would have to build ORE with cmake as
76+ demonstrated above, but, when configuring cmake, disable the SWIG build with:
77+ ` -DORE_BUILD-SWIG=OFF ` . Once ORE libraries have been built, below are the
78+ commands to build the ORESWIG Python wrapper using setup.py. If you
79+ do not require compression, then you can omit the ` ORE_USE_ZLIB ` environment
80+ variable.
81+
82+ In the commands below, to avoid polluting your primary installation of python,
83+ we create a virtual environment into which we install the packages required by
84+ setup.py.
8985
90- cd Engine \ORE-SWIG\
86+ cd %ORE_DIR% \ORE-SWIG
9187 SET ORE_STATIC_RUNTIME=1
9288 SET ORE_USE_ZLIB=1
89+ SET PATH=%PATH%;C:\path\to\swig
90+ python -m venv env1
91+ .\env1\Scripts\activate.bat
92+ python -m pip install --upgrade pip
93+ python -m pip install build pynose pytest setuptools
9394 python setup.py wrap
9495 python setup.py build
9596 python setup.py test
9697 python setup.py install
9798 python -m build --wheel
99+ deactivate
98100
99101The ` python setup.py install ` should take care of installing ORE as a package
100102to be universally used in Python, without needing to set PYTHONPATH. Otherwise,
101103
102- SET PYTHONPATH=%DEMO_ORE_DIR %\ORE-SWIG\build\lib.win-amd64-cpython-310
104+ SET PYTHONPATH=%ORE_DIR %\ORE-SWIG\build\lib.win-amd64-cpython-312
103105
104106### Use the wrapper
105107
106- cd %DEMO_ORE_DIR %\Examples\ORE-Python\ExampleScripts
108+ cd %ORE_DIR %\Examples\ORE-Python\ExampleScripts
107109 python swap.py
108110
109111When you run example script ` ore.py ` , it writes to directory ` Output ` a number
110112of output files, including ` cube.dat ` . If you have compression enabled, as
111113described above, then ` cube.dat ` is generated in compressed format (zip). If
112114not then ` cube.dat ` is generated as a flat (plain text) file.
113115
116+ ## Build the wheel with setup.py
117+
118+ Whether you used cmake or setup.py above to build the wrapper, you can use
119+ setup.py to build the wheel. If you used setup.py then you already have the
120+ python virtual environment, and you can reuse it, otherwise you can create a
121+ new one as shown below.
122+
123+ cd %ORE_DIR%\ORE-SWIG
124+ SET BOOST=C:\repos\boost\boost_1_72_0
125+ SET BOOST_LIB64=C:\repos\boost\boost_1_72_0\lib64-msvc-14.2
126+ python -m venv env1
127+ .\env1\Scripts\activate.bat
128+ python -m pip install --upgrade pip
129+ python -m pip install build
130+ python -m build --wheel
131+ deactivate
114132
115133### Use the wheel
116134
117- cd %DEMO_ORE_DIR%\ORE-SWIG \ORE-Python\Examples
135+ cd %ORE_DIR%\Examples \ORE-Python\ExampleScripts
118136 python -m venv env1
119137 .\env1\Scripts\activate.bat
120- pip install %DEMO_ORE_DIR %\ORE-SWIG\dist\open_source_risk_engine_ -1.8.13-cp310-cp310 -win_amd64.whl
138+ pip install %ORE_DIR %\ORE-SWIG\dist\open_source_risk_engine -1.8.13.1-cp312-cp312 -win_amd64.whl
121139 python swap.py
122140 deactivate
123- rmdir /s /q env1
124-
125141
0 commit comments