Skip to content

Commit

Permalink
Merge pull request #276 from mapnik/pybind11
Browse files Browse the repository at this point in the history
Pybind11 [WIP]
  • Loading branch information
artemp authored Jun 14, 2024
2 parents 5ab32f0 + 7edaed1 commit 248003c
Show file tree
Hide file tree
Showing 109 changed files with 5,139 additions and 5,899 deletions.
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@
[submodule "test/data"]
path = test/data
url = https://github.com/mapnik/test-data.git
[submodule "extern/pybind11"]
path = extern/pybind11
url = ../../pybind/pybind11
branch = stable
93 changes: 0 additions & 93 deletions .travis.yml

This file was deleted.

91 changes: 5 additions & 86 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,106 +1,25 @@
**New** Python bindings for Mapnik **[WIP]**

[![Build Status](https://travis-ci.org/mapnik/python-mapnik.svg)](https://travis-ci.org/mapnik/python-mapnik)

Python bindings for Mapnik.
https://github.com/pybind/pybind11

## Installation

Eventually we hope that many people will simply be able to `pip install mapnik` in order to get prebuilt binaries,
this currently does not work though. So for now here are the instructions

### Create a virtual environment

It is highly suggested that you have [a python virtualenv](http://docs.python-guide.org/en/latest/dev/virtualenvs/) when developing
on mapnik.

### Building from Mason

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.

```bash
export MASON_BUILD=true
```

After this is done simply follow the directions as per a source build.

### Building from Source

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:

```
python setup.py develop
```

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.


```
python setup.py install
```

If you wish to just install the package.

```
python setup.py develop --uninstall
```

Will de-activate the development install by removing the `python-mapnik` entry from `site-packages/easy-install.pth`.


If you need Pycairo, make sure that PYCAIRO is set to true in your environment or run:
Make sure 'mapnik-config' is present and accessible via $PATH env variable

```
PYCAIRO=true python setup.py develop
pip install . -v
```

### Building against Mapnik 3.0.x

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.

## Testing

Once you have installed you can test the package by running:

```
git submodule update --init
python setup.py test
```

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


### Troubleshooting

If you hit an error like:

```
Fatal Python error: PyThreadState_Get: no current thread
Abort trap: 6
pytest test/python_tests/
```

That means you likely have built python-mapnik linked against a different python version than what you are running. To solve this try running:

```
/usr/bin/python <your script.py>
```

If you hit an error like the following when building with mason:

```
EnvironmentError:
Missing boost_python boost library, try to add its name with BOOST_PYTHON_LIB environment var.
```

Try to set `export BOOST_PYTHON_LIB=boost_python` before build.
Also, if `boost_thread` or `boost_system` is missing, do likewise:

```
export BOOST_SYSTEM_LIB=boost_system
export BOOST_THREAD_LIB=boost_thread
```

If you still hit a problem create an issue and we'll try to help.

## Tutorials

- [Getting started with Python bindings](docs/getting-started.md)
87 changes: 0 additions & 87 deletions bootstrap.sh

This file was deleted.

Loading

0 comments on commit 248003c

Please sign in to comment.