You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: mapscript/python/README.rst
+46-12
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@ Python MapScript for MapServer 7.2.1 README
2
2
===========================================
3
3
4
4
:Author: MapServer Team
5
-
:Last Updated: 2018-10-12
5
+
:Last Updated: 2018-11-28
6
6
7
7
Introduction
8
8
------------
@@ -51,8 +51,8 @@ running correctly.
51
51
..
52
52
py3 SWIG flag adds type annotations
53
53
54
-
Installation
55
-
------------
54
+
Installation on Windows
55
+
-----------------------
56
56
57
57
To use mapscript you will need to add the MapServer binaries to your system path.
58
58
On Windows you can use the following, replacing ``C:\MapServer\bin`` with the location of your MapServer binaries.
@@ -61,11 +61,11 @@ On Windows you can use the following, replacing ``C:\MapServer\bin`` with the lo
61
61
62
62
SETPATH=C:\MapServer\bin;%PATH%
63
63
64
-
Windows binary packages can be downloaded from `GIS Internals <https://www.gisinternals.com/stable.php>`.
64
+
Windows binary packages can be downloaded from `GIS Internals <https://www.gisinternals.com/stable.php>`_.
65
65
To ensure compatibility with the wheels, please use identical release packages, e.g. ``release-1911-x64-gdal-2-3-mapserver-7-2``
66
66
for mapscript 7.2.
67
67
68
-
When using these packages the MapServer path will be similar to `C:\release-1911-x64-gdal-2-3-mapserver-7-2\bin`.
68
+
When using these packages the MapServer path will be similar to ``C:\release-1911-x64-gdal-2-3-mapserver-7-2\bin``.
69
69
70
70
Prior to installing mapscript it is recommended to update pip to the latest version with the following command:
71
71
@@ -106,6 +106,40 @@ If your version of mapscript does not match your version of MapServer you may in
106
106
ImportError: DLL load failed: The specified module could not be found.
107
107
ImportError: DLL load failed: The specified procedure could not be found.
108
108
109
+
Installation on Unix
110
+
--------------------
111
+
112
+
For Unix users there are two approaches to installing mapscript. The first is to install the ``python-mapscript`` package using a package manager. For example on
113
+
Ubuntu the following command can be used:
114
+
115
+
.. code-block:: bat
116
+
117
+
sudo apt-get install python-mapscript
118
+
119
+
The second approach is to build and install the Python mapscript module from source. Full details on compiling MapServer from source are detailed on the
120
+
`Compiling on Unix <https://www.mapserver.org/installation/unix.html>`_ page. To make sure Python mapscript is built alongside MapServer the following flag needs to be set:
121
+
122
+
.. code-block:: bat
123
+
124
+
-DWITH_PYTHON=ON
125
+
126
+
To configure the path of the mapscript installation location ``-DCMAKE_INSTALL_PREFIX`` can be set, e.g.
127
+
128
+
.. code-block:: bat
129
+
130
+
sudo cmake .. -DCMAKE_INSTALL_PREFIX=/usr
131
+
132
+
When installing the `DESTDIR <https://cmake.org/cmake/help/latest/envvar/DESTDIR.html>`_ variable can be set (note ``DESTDIR`` is not used on Windows)
133
+
to install mapscript to a non-default location. E.g.
134
+
135
+
.. code-block:: bat
136
+
137
+
make install DESTDIR=/tmp
138
+
139
+
In summary the ``install`` target runs the ``setup.py install`` command using custom paths (when set) similar to below:
>>>lo= mapscript.fromstring("""LAYER NAME "test" TYPE POINT END""")
129
-
>>>lo
162
+
>>>layer= mapscript.fromstring("""LAYER NAME "test" TYPE POINT END""")
163
+
>>>layer
130
164
<mapscript.layerObj; proxy of C layerObj instance at ...>
131
-
>>>lo.name
165
+
>>>layer.name
132
166
'test'
133
-
>>>lo.type == mapscript.MS_LAYER_POINT
167
+
>>>layer.type == mapscript.MS_LAYER_POINT
134
168
True
135
169
136
170
Building the Mapscript Module
@@ -139,14 +173,14 @@ Building the Mapscript Module
139
173
The mapscript module is built as part of the MapServer CMake build process. This is configured using the ``mapserver/mapscript/CMakeLists.txt`` file.
140
174
141
175
Before the switch to CMake MapServer mapscript was built using distutils and ``setup.py``. Now the ``setup.py.in`` file is used as a template that
142
-
is filled with the MapServer version number and used to created wheel files for distribution.
176
+
is filled with the MapServer version number and used to created wheel files for distribution, or install mapscript directly on the build machine.
143
177
144
178
The build process works as follows.
145
179
146
180
+ CMake runs SWIG. This uses the SWIG interface files to create a ``mapscriptPYTHON_wrap.c`` file,
147
181
and a ``mapscript.py`` file containing the Python wrapper to the mapscript binary module.
148
182
+ CMake then uses the appropriate compiler on the system to compile the ``mapscriptPYTHON_wrap.c`` file into a Python binary module -
149
-
``_mapscript.pyd`` file on Windows, and a ``_mapscript.so`` file on Windows.
183
+
``_mapscript.pyd`` file on Windows, and a ``_mapscript.so`` file on Unix.
150
184
151
185
``CMakeLists.txt`` is configured with a ``pythonmapscript-wheel`` target that copies all the required files to the output build folder where they are then packaged
152
186
into a Python wheel. The wheel can be built using the following command:
0 commit comments