python-mapnik
python-mapnik copied to clipboard
Mapnik4.0.0 build erro
I am trying to build the Python bindings for Mapnik 4.0.0 but encountered some issues. Here are the details: NAME="Debian GNU/Linux"/VERSION_ID="11"/Mapnik version: 4.0.0/Python 3.9.2/gcc (Debian 10.2.1-6) 10.2.1 20210110
log:
root@62597b7940d4:/home/python-mapnik# python setup.py install
/usr/lib/python3/dist-packages/setuptools/dist.py:461: UserWarning: Normalizing '4.0.0.dev' to '4.0.0.dev0'
warnings.warn(tmpl.format(**locals()))
running install
running bdist_egg
running egg_info
creating packaging/mapnik.egg-info
writing packaging/mapnik.egg-info/PKG-INFO
writing dependency_links to packaging/mapnik.egg-info/dependency_links.txt
writing top-level names to packaging/mapnik.egg-info/top_level.txt
writing manifest file 'packaging/mapnik.egg-info/SOURCES.txt'
reading manifest file 'packaging/mapnik.egg-info/SOURCES.txt'
writing manifest file 'packaging/mapnik.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
creating build
creating build/lib.linux-x86_64-3.9
creating build/lib.linux-x86_64-3.9/mapnik
copying packaging/mapnik/mapnik_settings.py -> build/lib.linux-x86_64-3.9/mapnik
copying packaging/mapnik/paths.py -> build/lib.linux-x86_64-3.9/mapnik
copying packaging/mapnik/init.py -> build/lib.linux-x86_64-3.9/mapnik
creating build/lib.linux-x86_64-3.9/mapnik/printing
copying packaging/mapnik/printing/conversions.py -> build/lib.linux-x86_64-3.9/mapnik/printing
copying packaging/mapnik/printing/formats.py -> build/lib.linux-x86_64-3.9/mapnik/printing
copying packaging/mapnik/printing/scales.py -> build/lib.linux-x86_64-3.9/mapnik/printing
copying packaging/mapnik/printing/init.py -> build/lib.linux-x86_64-3.9/mapnik/printing
running build_ext
c++ -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -ffile-prefix-map=/build/python3.9-RNBry6/python3.9-3.9.2=. -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -ffile-prefix-map=/build/python3.9-RNBry6/python3.9-3.9.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.9 -c flagcheck.cpp -o flagcheck.o -std=c++17
building 'mapnik._mapnik' extension
creating build/temp.linux-x86_64-3.9
creating build/temp.linux-x86_64-3.9/src
c++ -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -ffile-prefix-map=/build/python3.9-RNBry6/python3.9-3.9.2=. -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -ffile-prefix-map=/build/python3.9-RNBry6/python3.9-3.9.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/local/lib/python3.9/dist-packages/pybind11/include -I/usr/include/python3.9 -c src/mapnik_building_symbolizer.cpp -o build/temp.linux-x86_64-3.9/src/mapnik_building_symbolizer.o -std=c++17 -fvisibility=hidden -g0 -I/usr/local/include -I/usr/local/include/mapnik/agg -I/usr/local/include/mapnik/deps -I/usr/local/include -I/usr/include -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/postgresql -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/uuid -DMAPNIK_MEMORY_MAPPED_FILE -DMAPNIK_HAS_DLCFN -DBIGINT -DBOOST_REGEX_HAS_ICU -DHAVE_JPEG -DMAPNIK_USE_PROJ -DMAPNIK_PROJ_VERSION=90400 -DHAVE_PNG -DHAVE_WEBP -DHAVE_TIFF -DLINUX -DMAPNIK_THREADSAFE -DBOOST_SPIRIT_NO_PREDEFINED_TERMINALS=1 -DBOOST_PHOENIX_NO_PREDEFINED_TERMINALS=1 -DBOOST_SPIRIT_USE_PHOENIX_V3=1 -DNDEBUG -DHAVE_CAIRO -DGRID_RENDERER -std=c++17 -DU_USING_ICU_NAMESPACE=0 -fvisibility-inlines-hidden -pthread -ftemplate-depth-300 -O3
c++ -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -ffile-prefix-map=/build/python3.9-RNBry6/python3.9-3.9.2=. -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -ffile-prefix-map=/build/python3.9-RNBry6/python3.9-3.9.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/local/lib/python3.9/dist-packages/pybind11/include -I/usr/include/python3.9 -c src/mapnik_color.cpp -o build/temp.linux-x86_64-3.9/src/mapnik_color.o -std=c++17 -fvisibility=hidden -g0 -I/usr/local/include -I/usr/local/include/mapnik/agg -I/usr/local/include/mapnik/deps -I/usr/local/include -I/usr/include -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/postgresql -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/uuid -DMAPNIK_MEMORY_MAPPED_FILE -DMAPNIK_HAS_DLCFN -DBIGINT -DBOOST_REGEX_HAS_ICU -DHAVE_JPEG -DMAPNIK_USE_PROJ -DMAPNIK_PROJ_VERSION=90400 -DHAVE_PNG -DHAVE_WEBP -DHAVE_TIFF -DLINUX -DMAPNIK_THREADSAFE -DBOOST_SPIRIT_NO_PREDEFINED_TERMINALS=1 -DBOOST_PHOENIX_NO_PREDEFINED_TERMINALS=1 -DBOOST_SPIRIT_USE_PHOENIX_V3=1 -DNDEBUG -DHAVE_CAIRO -DGRID_RENDERER -std=c++17 -DU_USING_ICU_NAMESPACE=0 -fvisibility-inlines-hidden -pthread -ftemplate-depth-300 -O3
c++ -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -ffile-prefix-map=/build/python3.9-RNBry6/python3.9-3.9.2=. -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -ffile-prefix-map=/build/python3.9-RNBry6/python3.9-3.9.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/local/lib/python3.9/dist-packages/pybind11/include -I/usr/include/python3.9 -c src/mapnik_composite_modes.cpp -o build/temp.linux-x86_64-3.9/src/mapnik_composite_modes.o -std=c++17 -fvisibility=hidden -g0 -I/usr/local/include -I/usr/local/include/mapnik/agg -I/usr/local/include/mapnik/deps -I/usr/local/include -I/usr/include -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/postgresql -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/uuid -DMAPNIK_MEMORY_MAPPED_FILE -DMAPNIK_HAS_DLCFN -DBIGINT -DBOOST_REGEX_HAS_ICU -DHAVE_JPEG -DMAPNIK_USE_PROJ -DMAPNIK_PROJ_VERSION=90400 -DHAVE_PNG -DHAVE_WEBP -DHAVE_TIFF -DLINUX -DMAPNIK_THREADSAFE -DBOOST_SPIRIT_NO_PREDEFINED_TERMINALS=1 -DBOOST_PHOENIX_NO_PREDEFINED_TERMINALS=1 -DBOOST_SPIRIT_USE_PHOENIX_V3=1 -DNDEBUG -DHAVE_CAIRO -DGRID_RENDERER -std=c++17 -DU_USING_ICU_NAMESPACE=0 -fvisibility-inlines-hidden -pthread -ftemplate-depth-300 -O3
c++ -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -ffile-prefix-map=/build/python3.9-RNBry6/python3.9-3.9.2=. -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -ffile-prefix-map=/build/python3.9-RNBry6/python3.9-3.9.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/local/lib/python3.9/dist-packages/pybind11/include -I/usr/include/python3.9 -c src/mapnik_coord.cpp -o build/temp.linux-x86_64-3.9/src/mapnik_coord.o -std=c++17 -fvisibility=hidden -g0 -I/usr/local/include -I/usr/local/include/mapnik/agg -I/usr/local/include/mapnik/deps -I/usr/local/include -I/usr/include -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/postgresql -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/uuid -DMAPNIK_MEMORY_MAPPED_FILE -DMAPNIK_HAS_DLCFN -DBIGINT -DBOOST_REGEX_HAS_ICU -DHAVE_JPEG -DMAPNIK_USE_PROJ -DMAPNIK_PROJ_VERSION=90400 -DHAVE_PNG -DHAVE_WEBP -DHAVE_TIFF -DLINUX -DMAPNIK_THREADSAFE -DBOOST_SPIRIT_NO_PREDEFINED_TERMINALS=1 -DBOOST_PHOENIX_NO_PREDEFINED_TERMINALS=1 -DBOOST_SPIRIT_USE_PHOENIX_V3=1 -DNDEBUG -DHAVE_CAIRO -DGRID_RENDERER -std=c++17 -DU_USING_ICU_NAMESPACE=0 -fvisibility-inlines-hidden -pthread -ftemplate-depth-300 -O3
c++ -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -ffile-prefix-map=/build/python3.9-RNBry6/python3.9-3.9.2=. -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -ffile-prefix-map=/build/python3.9-RNBry6/python3.9-3.9.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/local/lib/python3.9/dist-packages/pybind11/include -I/usr/include/python3.9 -c src/mapnik_datasource.cpp -o build/temp.linux-x86_64-3.9/src/mapnik_datasource.o -std=c++17 -fvisibility=hidden -g0 -I/usr/local/include -I/usr/local/include/mapnik/agg -I/usr/local/include/mapnik/deps -I/usr/local/include -I/usr/include -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/postgresql -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/uuid -DMAPNIK_MEMORY_MAPPED_FILE -DMAPNIK_HAS_DLCFN -DBIGINT -DBOOST_REGEX_HAS_ICU -DHAVE_JPEG -DMAPNIK_USE_PROJ -DMAPNIK_PROJ_VERSION=90400 -DHAVE_PNG -DHAVE_WEBP -DHAVE_TIFF -DLINUX -DMAPNIK_THREADSAFE -DBOOST_SPIRIT_NO_PREDEFINED_TERMINALS=1 -DBOOST_PHOENIX_NO_PREDEFINED_TERMINALS=1 -DBOOST_SPIRIT_USE_PHOENIX_V3=1 -DNDEBUG -DHAVE_CAIRO -DGRID_RENDERER -std=c++17 -DU_USING_ICU_NAMESPACE=0 -fvisibility-inlines-hidden -pthread -ftemplate-depth-300 -O3
In file included from /usr/local/include/mapnik/datasource.hpp:28,
from src/mapnik_datasource.cpp:26:
/usr/local/include/mapnik/params.hpp: In instantiation of ‘mapnik::value_holder::value_holder(T&&) [with T = long long int]’:
src/mapnik_value_converter.hpp:183:42: required from here
/usr/local/include/mapnik/params.hpp:58:49: error: no matching function for call to ‘mapbox::util::variant<mapnik::value_null, long int, double, std::__cxx11::basic_string<char, std::char_traits
| ^~~~~~~~~~~~
/usr/local/lib/python3.9/dist-packages/pybind11/include/pybind11/operators.h:163:1: note: in expansion of macro ‘PYBIND11_BINARY_OPERATOR’
163 | PYBIND11_BINARY_OPERATOR(eq, eq, operator==, l == r)
| ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from src/mapnik_datasource.cpp:26:
/usr/local/include/mapnik/datasource.hpp:60:19: note: because the following virtual functions are pure within ‘mapnik::datasource’:
60 | class MAPNIK_DECL datasource : private util::noncopyable
| ^~~~~~~~~~
/usr/local/include/mapnik/datasource.hpp:88:26: note: ‘virtual mapnik::datasource::datasource_t mapnik::datasource::type() const’
88 | virtual datasource_t type() const = 0;
| ^~~~
/usr/local/include/mapnik/datasource.hpp:95:50: note: ‘virtual std::optionalmapnik::datasource_geometry_t mapnik::datasource::get_geometry_type() const’
95 | virtual std::optional<datasource_geometry_t> get_geometry_type() const = 0;
| ^~~~~~~~~~~~~~~~~
/usr/local/include/mapnik/datasource.hpp:96:28: note: ‘virtual mapnik::featureset_ptr mapnik::datasource::features(const mapnik::query&) const’
96 | virtual featureset_ptr features(query const& q) const = 0;
| ^~~~~~~~
/usr/local/include/mapnik/datasource.hpp:97:28: note: ‘virtual mapnik::featureset_ptr mapnik::datasource::features_at_point(const coord2d&, double) const’
97 | virtual featureset_ptr features_at_point(coord2d const& pt, double tol = 0) const = 0;
| ^~~~~~~~~~~~~~~~~
/usr/local/include/mapnik/datasource.hpp:98:27: note: ‘virtual mapnik::box2d
I'm quite surprised you got that far given that python-mapnik relies on mapnik-config which has gone away in v4 builds!
I think https://github.com/tomhughes/python-mapnik/commit/effd0738dc7d93cbd1b295011db0f474e9c4b3ce#diff-a40f8e0fb493e5138d571e7f0c4feb8e56eac823e12e15a8d6ce67b8daf06913 should fix your problem but I'm not sure it's the right solution overall which is why I haven't opened a PR for it.
The problem is that in a 64 bit linux build std::int64_t is long and mapbox::variant doesn't seem to like doing a conversion from long long in the way std::variant would so it fails to find a way to put the long long value from PyLong_AsLongLong into the variant.
/usr/local/include/mapnik/params.hpp:58:49: error: no matching function for call to ‘mapbox::util::variant<mapnik::value_null, long int, double, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, bool>::variant(long long int)’
This error also prevents the Debian package from building successfully as reported in #279.
I'm quite surprised you got that far given that python-mapnik relies on
mapnik-configwhich has gone away in v4 builds!
Patching python-mapnik to use pkg-config is not difficult, see:
https://salsa.debian.org/debian-gis-team/python-mapnik/-/blob/master/debian/patches/mapnik-4.0.patch?ref_type=heads
The Scons build still installs mapnik-config AFAIK, it's only the CMake build that only provides pkg-config.
@sebastic Did you get a resolution to this? I'm stuck at this point as well. I tried the changes suggested here: https://github.com/tomhughes/python-mapnik/commit/effd0738dc7d93cbd1b295011db0f474e9c4b3ce#diff-a40f8e0fb493e5138d571e7f0c4feb8e56eac823e12e15a8d6ce67b8daf06913
I was eventually able to build, but I get some crazy errors when trying a basic test script like: import mapnik print(mapnik.version) print(mapnik.mapnik_version_string())
I'm really struggling to get a working version of Mapnik with python bindings on my M1 macbook. I've been trying for a couple days with no luck. Any helped would be greatly appreciated.
See the patches in the Debian & Fedora packages:
https://salsa.debian.org/debian-gis-team/python-mapnik/-/tree/master/debian/patches?ref_type=heads https://src.fedoraproject.org/rpms/python-mapnik/tree/
Also note the commit used for the packages, this is an older one. I never got the package to work after the pybind11 changes.