File: BUILDING.md

package info (click to toggle)
zeroc-ice 3.7.10-3.1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 75,696 kB
  • sloc: cpp: 356,894; java: 226,081; cs: 98,312; javascript: 35,027; python: 28,716; objc: 27,050; php: 7,526; ruby: 7,190; yacc: 2,949; ansic: 2,469; xml: 1,589; lex: 1,241; makefile: 472; sh: 52
file content (165 lines) | stat: -rw-r--r-- 5,130 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# Ice for Python Build Instructions

This document describes how to build and install Ice for Python from source.
You can also download and install a [binary distribution].

* [Building with Pip](#building-with-pip)
* [Building with Visual Studio 2015 and MSBuild (Python 3\.11 for Windows)](#building-with-visual-studio-2015-and-msbuild-python-311-for-windows)
* [Building on Linux or macOS](#building-on-linux-or-macos)
* [Configuring your Environment for Python](#configuring-your-environment-for-python)
* [Running the Python Tests](#running-the-python-tests)

## Building with Pip

You can build the Ice for Python extension from source using `pip`:

```shell
pip install <URL of Ice source distribution for Python>
```

## Building with Visual Studio 2015 and MSBuild (Python 3.11 for Windows)

You can build an Ice for Python extension that links with the Ice C++ DLLs using Visual Studio and MSBuild.

First, open a Visual Studio 2015 command prompt:

* VS2015 x86 Native Tools Command Prompt

or

* VS2015 x64 Native Tools Command Prompt

Using the first Command Prompt produces `Win32` binaries by default, while
the second Command Prompt produces `x64` binaries by default.

In the Command Prompt, change to the `python` subdirectory:

```shell
cd python
```

You must build Ice for C++ from the `cpp` subdirectory. If you have not done so,
refer to the [C++ build instructions](../cpp/BUILDING.md).

Then build the extension:

```shell
msbuild msbuild\ice.proj
```

This builds the extension with `Release` binaries for the default platform. The
extension will be placed in `python\x64\Release\IcePy.pyd` for the `x64`
platform and `python\Win32\Release\IcePy.pyd` for the `Win32` platform.

If you want to build a debug version of the extension, set the MSBuild
`Configuration` property to `Debug`:

```shell
msbuild msbuild\ice.proj /p:Configuration=Debug
```

The debug version of the extension will be placed in
`python\x64\Debug\IcePy_d.pyd` for the `x64` platform and
`python\Win32\Debug\IcePy_d.pyd` for the `Win32` platform.

For Debug builds, a debug version of the Python interpreter must be installed
as well.

If you want to build the extension for a different platform than the Command
Prompt's default platform, you need to set the MSBuild property `Platform`. The
supported values for this property are `Win32` and `x64`.

The following command builds the `x64` platform binaries with the `Release`
configuration:

```shell
msbuild msbuild\ice.proj /p:Configuration=Release /p:Platform=x64
```

This command builds the `Win32` platform binaries with the `Release`
configuration:

```shell
msbuild msbuild\ice.proj /p:Configuration=Release /p:Platform=Win32
```

When using the MSBuild Platform property, the build platform doesn't depend
on the command prompt's default platform.

The build will use the default location for Python defined in
`python\msbuild\ice.props`. You can override it by setting the `PythonHome`
MSBuild property. For example, the following command will use the Python
installation from `C:\Python310-AMD64` instead of the default location:

```shell
msbuild msbuild\ice.proj /p:Configuration=Release /p:Platform=x64 /p:PythonHome=C:\Python310-AMD64
```

## Building on Linux or macOS

Ice for Python supports Python versions 2.7 and 3.11. Note however that
your Python installation must have been built with a C++ compiler that is
compatible with the compiler used to build Ice for C++.

The build of Ice for Python requires to first build Ice for C++ in the `cpp`
subdirectory.

From the top-level source directory, edit `config/Make.rules` to establish your
build configuration. The comments in the file provide more information.

Change to the Ice for Python source subdirectory:

```shell
cd python
```

Execute `python -V` to verify that the correct Python interpreter is in your
executable search path.

Run `make` to build the extension.

Upon successful completion, run `make install`. You may need additional user
permissions to install in the directory specified by `config/Make.rules`.

## Configuring your Environment for Python

Modify your environment to allow Python to find the Ice extension for Python.
The python interpreter must be able to locate the IcePy extension as well as
the Python source files in the `python` subdirectory. This is normally
accomplished by setting the `PYTHONPATH` environment variable to contain the
necessary subdirectory.

For example on Windows, with Ice for Python installed in `C:\Ice`:

```shell
set PYTHONPATH=C:\Ice\python;C:\Ice\python\Win32\Release
```

For example on Linux or macOS, with Ice for Python installed in `/opt/Ice`:

```shell
export PYTHONPATH=/opt/Ice/python
```

## Running the Python Tests

After a successful build, you can run the tests as follows:

Windows:

```shell
python allTests.py --config=Release --platform=Win32
```

(adjust `--config` and `--platform` to match your build)

Linux/macOS:

```shell
python allTests.py
```

If everything worked out, you should see lots of `ok` messages. In case of a
failure, the tests abort with `failed`.

[binary distribution]: https://zeroc.com/downloads/ice