• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

config/H03-May-2022-195146

modules/IcePy/H05-Feb-2019-27,39522,521

msbuild/H05-Feb-2019-148130

python/H03-May-2022-2,3521,599

scripts/H03-May-2022-147

test/H03-May-2022-28,76221,965

MakefileH A D03-May-2022983 4513

README.mdH A D05-Feb-20194.9 KiB147112

allTests.pyH A D03-May-2022233 124

README.md

1# Building Ice for Python
2
3This document describes how to build and install Ice for Python from source.
4You can also download and install a [binary distribution][1].
5
6* [Building with Pip](#building-with-pip)
7* [Building with Visual Studio 2015 and MSBuild (Python 3\.7 for Windows)](#building-with-visual-studio-2015-and-msbuild-python-37-for-windows)
8* [Building on Linux or macOS](#building-on-linux-or-macos)
9* [Configuring your Environment for Python](#configuring-your-environment-for-python)
10* [Running the Python Tests](#running-the-python-tests)
11
12## Building with Pip
13
14You can build the Ice for Python extension from source using `pip`:
15```
16pip install <URL of Ice source distribution for Python>
17```
18
19## Building with Visual Studio 2015 and MSBuild (Python 3.7 for Windows)
20
21You can  build an Ice for Python 3.7 extension that links with the Ice C++
22DLLs using Visual Studio and MSBuild.
23
24First, open a Visual Studio 2015 command prompt:
25
26- VS2015 x86 Native Tools Command Prompt
27or
28- VS2015 x64 Native Tools Command Prompt
29
30Using the first Command Prompt produces `Win32` binaries by default, while
31the second Command Prompt produces `x64` binaries by default.
32
33In the Command Prompt, change to the `python` subdirectory:
34```
35cd python
36```
37You must build Ice for C++ from the `cpp` subdirectory. If you have not done so,
38refer to the [C++ build instructions](../cpp/BuildInstructionsWindows.md).
39
40Then build the extension:
41```
42msbuild msbuild\ice.proj
43```
44This builds the extension with `Release` binaries for the default platform. The
45extension will be placed in `python\x64\Release\IcePy.pyd` for the `x64`
46platform and `python\Win32\Release\IcePy.pyd` for the `Win32` platform.
47
48If you want to build a debug version of the extension, set the MSBuild
49`Configuration` property to `Debug`:
50```
51msbuild msbuild\ice.proj /p:Configuration=Debug
52```
53The debug version of the extension will be placed in
54`python\x64\Debug\IcePy_d.pyd` for the `x64` platform and
55`python\Win32\Debug\IcePy_d.pyd` for the `Win32` platform.
56
57For Debug builds, a debug version of the Python interpreter must be installed
58as well.
59
60If you want to build the extension for a different platform than the Command
61Prompt's default platform, you need to set the MSBuild property `Platform`. The
62supported values for this property are `Win32` and `x64`.
63
64The following command builds the `x64` platform binaries with the `Release`
65configuration:
66```
67msbuild msbuild\ice.proj /p:Configuration=Release /p:Platform=x64
68```
69This command builds the `Win32` platform binaries with the `Release`
70configuration:
71```
72msbuild msbuild\ice.proj /p:Configuration=Release /p:Platform=Win32
73```
74When using the MSBuild Platform property, the build platform doesn't depend
75on the command prompt's default platform.
76
77The build will use the default location for Python defined in
78`python\msbuild\ice.props`. You can override it by setting the `PythonHome`
79MSBuild property. For example, the following command will use the Python
80installation from `C:\Python36-AMD64` instead of the default location:
81```
82msbuild msbuild\ice.proj /p:Configuration=Release /p:Platform=x64 /p:PythonHome=C:\Python36-AMD64
83```
84
85## Building on Linux or macOS
86
87Ice for Python supports Python versions 2.7 and 3.7. Note however that
88your Python installation must have been built with a C++ compiler that is
89compatible with the compiler used to build Ice for C++.
90
91The build of Ice for Python requires to first build Ice for C++ in the `cpp`
92subdirectory.
93
94From the top-level source directory, edit `config/Make.rules` to establish your
95build configuration. The comments in the file provide more information.
96
97Change to the Ice for Python source subdirectory:
98```
99cd python
100```
101
102Execute `python -V` to verify that the correct Python interpreter is in your
103executable search path.
104
105Run `make` to build the extension.
106
107Upon successful completion, run `make install`. You may need additional user
108permissions to install in the directory specified by `config/Make.rules`.
109
110## Configuring your Environment for Python
111
112Modify your environment to allow Python to find the Ice extension for Python.
113The python interpreter must be able to locate the IcePy extension as well as
114the Python source files in the `python` subdirectory. This is normally
115accomplished by setting the `PYTHONPATH` environment variable to contain the
116necessary subdirectory.
117
118For example on Windows, with Ice for Python installed in `C:\Ice`:
119```
120set PYTHONPATH=C:\Ice\python;C:\Ice\python\Win32\Release
121```
122
123For example on Linux or macOS, with Ice for Python installed in `/opt/Ice`:
124```
125export PYTHONPATH=/opt/Ice/python
126```
127
128## Running the Python Tests
129
130After a successful build, you can run the tests as follows:
131
132Windows:
133```
134python allTests.py --config=Release --platform=Win32
135```
136(adjust `--config` and `--platform` to match your build)
137
138Linux/macOS:
139```
140python allTests.py
141```
142
143If everything worked out, you should see lots of `ok` messages. In case of a
144failure, the tests abort with `failed`.
145
146[1]: https://zeroc.com/distributions/ice
147