Skip to content

Commit ac62cfe

Browse files
committed
Merge branch 'feature/wheels' into 'master'
Update the python wheels build See merge request qs/oreplus!3007
1 parent 381a347 commit ac62cfe

3 files changed

Lines changed: 67 additions & 52 deletions

File tree

ORE-SWIG/tutorials.03.build_windows.md

Lines changed: 54 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
5553
There are two ways to build ORESWIG: using **cmake**, or using **setup.py**.
5654
With cmake, you can generate the wrapper. With setup.py you can generate both
5755
the 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

99101
The `python setup.py install` should take care of installing ORE as a package
100102
to 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

109111
When you run example script `ore.py`, it writes to directory `Output` a number
110112
of output files, including `cube.dat`. If you have compression enabled, as
111113
described above, then `cube.dat` is generated in compressed format (zip). If
112114
not 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

tutorials/tutorials.010.build_windows.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,29 @@ You need to grab the source code for ORE, e.g:
2121

2222
# Environment Variables
2323

24-
For purposes of this tutorial, create environment variables pointing to the ORE
25-
and boost directories, e.g:
24+
For purposes of this tutorial, create environment variables pointing to the
25+
boost and ORE directories, e.g:
2626

27-
SET ORE_ROOT_DIR=C:\repos\ore
2827
SET BOOST_INCLUDEDIR=C:\repos\boost\boost_1_72_0
2928
SET BOOST_LIBRARYDIR=C:\repos\boost\boost_1_72_0\lib64-msvc-14.2
29+
SET ORE_DIR=C:\repos\ore
3030

3131
# Build ORE
3232

3333
## Configure ORE
3434

3535
Below are the commands to configure the ORE build using cmake:
3636

37-
mkdir %ORE_ROOT_DIR%\build
38-
cd %ORE_ROOT_DIR%\build
39-
cmake ..
37+
cd %ORE_DIR%
38+
mkdir %ORE_DIR%\build
39+
cd %ORE_DIR%\build
40+
cmake .. -DORE_BUILD_SWIG=0
4041

4142
## Build ORE
4243

4344
Below are the commands to build ORE:
4445

45-
cd %ORE_ROOT_DIR%\build
46+
cd %ORE_DIR%\build
4647
cmake --build . --config Release
4748

4849
# Run tests
@@ -51,28 +52,28 @@ Below are the commands to build ORE:
5152

5253
cd to the test directory:
5354

54-
cd %ORE_ROOT_DIR%\build\QuantLib\test-suite\Release
55+
cd %ORE_DIR%\build\QuantLib\test-suite\Release
5556

5657
Run all unit tests:
5758

5859
quantlib-test-suite.exe
5960

6061
Or run a selected test, e.g:
6162

62-
quantlib-test-suite.exe --log_level=all --run_test="QuantLib test suite/Swap tests"
63+
quantlib-test-suite.exe --log_level=all --run_test=QuantLibTests/SwapTests
6364

6465
## QuantExt
6566

66-
cd %ORE_ROOT_DIR%/build/QuantExt/test/Release
67+
cd %ORE_DIR%\build\QuantExt\test\Release
6768
quantext-test-suite.exe
6869

6970
## OREData
7071

71-
cd %ORE_ROOT_DIR%/build/OREData/test/Release
72+
cd %ORE_DIR%\build\OREData\test\Release
7273
ored-test-suite.exe
7374

7475
## OREAnalytics
7576

76-
cd %ORE_ROOT_DIR%/build/OREAnalytics/test/Release/
77+
cd %ORE_DIR%\build\OREAnalytics\test\Release\
7778
orea-test-suite.exe
7879

tutorials_index.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,5 @@ This page serves as the index for selected tutorials on building ORE.
2929

3030
[Building ORE Python Wrappers on Posix Systems (e.g. MacOS and Linux)](ORE-SWIG/tutorials.04.build_posix.md)
3131

32-
[Managing Wheels](ORE-SWIG/tutorials.05.wheels.md)
33-
3432
[Run Jupyter Notebook Examples using the published ORE Python module](ORE-SWIG/tutorials.06.notebooks.md)
3533

0 commit comments

Comments
 (0)