|
| 1 | +**New** Python bindings for Mapnik **[WIP]** |
1 | 2 |
|
2 |
| -[](https://travis-ci.org/mapnik/python-mapnik) |
3 |
| - |
4 |
| -Python bindings for Mapnik. |
| 3 | +https://github.com/pybind/pybind11 |
5 | 4 |
|
6 | 5 | ## Installation
|
7 | 6 |
|
8 |
| -Eventually we hope that many people will simply be able to `pip install mapnik` in order to get prebuilt binaries, |
9 |
| -this currently does not work though. So for now here are the instructions |
10 |
| - |
11 |
| -### Create a virtual environment |
12 |
| - |
13 |
| -It is highly suggested that you have [a python virtualenv](http://docs.python-guide.org/en/latest/dev/virtualenvs/) when developing |
14 |
| -on mapnik. |
15 |
| - |
16 |
| -### Building from Mason |
17 |
| - |
18 |
| -If you do not have mapnik built from source and simply wish to develop from the latest version in [mapnik master branch](https://github.com/mapnik/mapnik) you can setup your environment with a mason build. In order to trigger a mason build prior to building you must set the `MASON_BUILD` environment variable. |
19 |
| - |
20 |
| -```bash |
21 |
| -export MASON_BUILD=true |
22 |
| -``` |
23 |
| - |
24 |
| -After this is done simply follow the directions as per a source build. |
25 |
| - |
26 | 7 | ### Building from Source
|
27 | 8 |
|
28 |
| -Assuming that you built your own mapnik from source, and you have run `make install`. Set any compiler or linking environment variables as necessary so that your installation of mapnik is found. Next simply run one of the two methods: |
29 |
| - |
30 |
| -``` |
31 |
| -python setup.py develop |
32 |
| -``` |
33 |
| - |
34 |
| -If you are currently developing on mapnik-python and wish to change the code in place and immediately have python changes reflected in your environment. |
35 |
| - |
36 |
| - |
37 |
| -``` |
38 |
| -python setup.py install |
39 |
| -``` |
40 |
| - |
41 |
| -If you wish to just install the package. |
42 |
| - |
43 |
| -``` |
44 |
| -python setup.py develop --uninstall |
45 |
| -``` |
46 |
| - |
47 |
| -Will de-activate the development install by removing the `python-mapnik` entry from `site-packages/easy-install.pth`. |
48 |
| - |
49 |
| - |
50 |
| -If you need Pycairo, make sure that PYCAIRO is set to true in your environment or run: |
| 9 | +Make sure 'mapnik-config' is present and accessible via $PATH env variable |
51 | 10 |
|
52 | 11 | ```
|
53 |
| -PYCAIRO=true python setup.py develop |
| 12 | +pip install . -v |
54 | 13 | ```
|
55 | 14 |
|
56 |
| -### Building against Mapnik 3.0.x |
57 |
| - |
58 |
| -The `master` branch is no longer compatible with `3.0.x` series of Mapnik. To build against Mapnik 3.0.x, use [`v3.0.x`](https://github.com/mapnik/python-mapnik/tree/v3.0.x) branch. |
59 |
| - |
60 | 15 | ## Testing
|
61 | 16 |
|
62 | 17 | Once you have installed you can test the package by running:
|
63 | 18 |
|
64 | 19 | ```
|
65 |
| -git submodule update --init |
66 |
| -python setup.py test |
67 |
| -``` |
68 |
| - |
69 |
| -The test data in `./test/data` and `./test/data-visual` are standalone modules. If you need to update them see https://github.com/mapnik/mapnik/blob/master/docs/contributing.md#testing |
70 |
| - |
71 |
| - |
72 |
| -### Troubleshooting |
73 |
| - |
74 |
| -If you hit an error like: |
75 |
| - |
76 |
| -``` |
77 |
| -Fatal Python error: PyThreadState_Get: no current thread |
78 |
| -Abort trap: 6 |
| 20 | +pytest test/python_tests/ |
79 | 21 | ```
|
80 | 22 |
|
81 |
| -That means you likely have built python-mapnik linked against a different python version than what you are running. To solve this try running: |
82 |
| - |
83 |
| -``` |
84 |
| -/usr/bin/python <your script.py> |
85 |
| -``` |
86 |
| - |
87 |
| -If you hit an error like the following when building with mason: |
88 |
| - |
89 |
| -``` |
90 |
| -EnvironmentError: |
91 |
| -Missing boost_python boost library, try to add its name with BOOST_PYTHON_LIB environment var. |
92 |
| -``` |
93 |
| - |
94 |
| -Try to set `export BOOST_PYTHON_LIB=boost_python` before build. |
95 |
| -Also, if `boost_thread` or `boost_system` is missing, do likewise: |
96 |
| - |
97 |
| -``` |
98 |
| -export BOOST_SYSTEM_LIB=boost_system |
99 |
| -export BOOST_THREAD_LIB=boost_thread |
100 |
| -``` |
101 | 23 |
|
102 |
| -If you still hit a problem create an issue and we'll try to help. |
103 | 24 |
|
104 |
| -## Tutorials |
105 | 25 |
|
106 |
| -- [Getting started with Python bindings](docs/getting-started.md) |
0 commit comments