Last active
May 11, 2023 22:47
-
-
Save benboughton1/e38ba6d53e46e668ffe21b1cd478397f to your computer and use it in GitHub Desktop.
Build Mapnik on Ubuntu 22.04 with python bindings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash -e | |
| #Version: 0.2 | |
| #Author: Kaloyan Petrov https://www.upwork.com/freelancers/~01541a6d5035cf25e4 | |
| # Funded by Agriobs: agriobs.com | |
| # Copyright 2022 Agriobs Ben Boughton | |
| # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | |
| # The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | |
| # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
| # Usage: Make script executable and run it. It builds and installs the packages. | |
| # $ chmod +x ./build.sh | |
| # $ ./build.sh | |
| PROJ_VER='7.2.1' | |
| # PROJ 8 provided by Ubuntu can't be used. We build version 7, and install in /usr/local/ | |
| function install_proj_7(){ | |
| apt-get -y install cmake sqlite3 libsqlite3-dev libtiff-dev libcurl4-openssl-dev | |
| wget -P/tmp/ https://github.com/OSGeo/PROJ/releases/download/${PROJ_VER}/proj-${PROJ_VER}.tar.gz | |
| tar -xf /tmp/proj-${PROJ_VER}.tar.gz | |
| rm -f /tmp/proj-${PROJ_VER}.tar.gz | |
| pushd proj-${PROJ_VER} | |
| mkdir -p build | |
| pushd build | |
| cmake .. | |
| cmake --build . | |
| cmake --build . --target install | |
| ldconfig | |
| popd | |
| popd | |
| rm -rf proj-${PROJ_VER} | |
| } | |
| function build_mapnik(){ | |
| apt-get -y source mapnik | |
| apt-get -y build-dep mapnik | |
| pushd mapnik-3.1.0+ds | |
| # use PROJ 7 from /usr/local/ | |
| sed -i.save 's|PROJ_INCLUDES=/usr/include|PROJ_INCLUDES=/usr/local/include/|' debian/rules | |
| sed -i.save 's|PROJ_LIBS=/usr/lib|PROJ_LIBS=/usr/local/lib/|' debian/rules | |
| # disable error for local proj shared lib, without a package/dep | |
| cat >>debian/rules <<CAT_EOF | |
| override_dh_shlibdeps: | |
| dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info | |
| CAT_EOF | |
| # build and install the packages | |
| debuild -i -us -uc -b | |
| rm -rf build-python/ | |
| popd | |
| } | |
| function build_python_mapnik(){ | |
| apt-get -y source python-mapnik | |
| apt-get -y build-dep python-mapnik | |
| pushd python-mapnik-0.0~20200224-7da019cf9 | |
| # build and install the packages | |
| debuild -i -us -uc -b | |
| rm -rf build/ | |
| popd | |
| } | |
| function install_packages(){ | |
| dpkg -i python3-mapnik_*_amd64.deb mapnik-utils_3.1.0+ds-1ubuntu2_amd64.deb libmapnik3.1_3.1.0+ds-1ubuntu2_amd64.deb | |
| } | |
| export DEBIAN_FRONTEND=noninteractive | |
| sed -i.save 's/^deb \(.*\)/deb \1\ndeb-src \1/g' /etc/apt/sources.list | |
| apt-get -y clean | |
| apt-get -y update | |
| apt-get -y install dpkg-dev build-essential pbuilder | |
| install_proj_7 | |
| build_mapnik | |
| build_python_mapnik | |
| install_packages |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I had the same problem. this snippet almost worked for me:
line 59
Python bindings still produce segfault upon exit but seem to work anyhow.