mapnik / python-mapnik

Python bindings for mapnik
GNU Lesser General Public License v2.1
157 stars 90 forks source link

Mapnik4.0.0 build erro #281

Open JackIliffe opened 4 weeks ago

JackIliffe commented 4 weeks ago

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, std::allocator >, bool>::variant(long long int)’ 58 | : value_holder_base(std::forward(obj)) | ^ In file included from /usr/local/include/mapnik/util/variant.hpp:27, from /usr/local/include/mapnik/params.hpp:29, from /usr/local/include/mapnik/datasource.hpp:28, from src/mapnik_datasource.cpp:26: /usr/local/include/mapnik/deps/mapbox/variant.hpp:572:20: note: candidate: ‘mapbox::util::variant::variant(mapbox::util::variant&&) [with Types = {mapnik::value_null, long int, double, std::cxx11::basic_string<char, std::char_traits, std::allocator >, bool}]’ 572 | VARIANT_INLINE variant(variant&& old) | ^~~ /usr/local/include/mapnik/deps/mapbox/variant.hpp:572:48: note: no known conversion for argument 1 from ‘long long int’ to ‘mapbox::util::variant<mapnik::value_null, long int, double, std::cxx11::basic_string<char, std::char_traits, std::allocator >, bool>&&’ 572 | VARIANT_INLINE variant(variant&& old) | ~~~~^~~ /usr/local/include/mapnik/deps/mapbox/variant.hpp:566:20: note: candidate: ‘mapbox::util::variant::variant(const mapbox::util::variant&) [with Types = {mapnik::value_null, long int, double, std::cxx11::basic_string<char, std::char_traits, std::allocator >, bool}]’ 566 | VARIANT_INLINE variant(variant const& old) | ^~~ /usr/local/include/mapnik/deps/mapbox/variant.hpp:566:53: note: no known conversion for argument 1 from ‘long long int’ to ‘const mapbox::util::variant<mapnik::value_null, long int, double, std::cxx11::basic_string<char, std::char_traits, std::allocator >, bool>&’ 566 | VARIANT_INLINE variant(variant const& old) | ~~~~~^~~ /usr/local/include/mapnik/deps/mapbox/variant.hpp:560:20: note: candidate: ‘template<class T, class Traits, class Enable> mapbox::util::variant::variant(T&&) [with T = T; Traits = Traits; Enable = Enable; Types = {mapnik::value_null, long int, double, std::cxx11::basic_string<char, std::char_traits, std::allocator >, bool}]’ 560 | VARIANT_INLINE variant(T&& val) noexcept(std::is_nothrow_constructible<typename Traits::target_type, T&&>::value) | ^~~ /usr/local/include/mapnik/deps/mapbox/variant.hpp:560:20: note: template argument deduction/substitution failed: /usr/local/include/mapnik/deps/mapbox/variant.hpp:559:15: error: no type named ‘type’ in ‘struct std::enable_if<false, void>’ 559 | typename Enable = typename std::enable_if<Traits::is_valid && !std::is_same<variant, typename Traits::value_type>::value>::type > | ^~~~ /usr/local/include/mapnik/deps/mapbox/variant.hpp:554:20: note: candidate: ‘mapbox::util::variant::variant(mapbox::util::no_init) [with Types = {mapnik::value_null, long int, double, std::cxx11::basic_string<char, std::char_traits, std::allocator >, bool}]’ 554 | VARIANT_INLINE variant(no_init) noexcept | ^~~ /usr/local/include/mapnik/deps/mapbox/variant.hpp:554:28: note: no known conversion for argument 1 from ‘long long int’ to ‘mapbox::util::no_init’ 554 | VARIANT_INLINE variant(no_init) noexcept | ^~~ /usr/local/include/mapnik/deps/mapbox/variant.hpp:547:20: note: candidate: ‘mapbox::util::variant::variant() [with Types = {mapnik::value_null, long int, double, std::cxx11::basic_string<char, std::char_traits, std::allocator >, bool}]’ 547 | VARIANT_INLINE variant() noexcept(std::is_nothrow_default_constructible::value) | ^~~ /usr/local/include/mapnik/deps/mapbox/variant.hpp:547:20: note: candidate expects 0 arguments, 1 provided In file included from src/create_datasource.hpp:31, from src/mapnik_datasource.cpp:31: /usr/local/lib/python3.9/dist-packages/pybind11/include/pybind11/operators.h: In instantiation of ‘struct pybind11::detail::op_impl<pybind11::detail::op_eq, pybind11::detail::opl, mapnik::datasource, mapnik::datasource, mapnik::datasource>’: /usr/local/lib/python3.9/dist-packages/pybind11/include/pybind11/operators.h:94:24: required from ‘void pybind11::detail::op<id, ot, L, R>::execute(Class&, const Extra& ...) const [with Class = pybind11::class_<mapnik::datasource, std::shared_ptr >; Extra = {}; pybind11::detail::op_id id = pybind11::detail::op_eq; pybind11::detail::op_type ot = pybind11::detail::op_l; L = pybind11::detail::self_t; R = pybind11::detail::selft]’ /usr/local/lib/python3.9/dist-packages/pybind11/include/pybind11/pybind11.h:1659:19: required from ‘pybind11::class<type, options>& pybind11::class<type, options>::def(const T&, const Extra& ...) [with T = pybind11::detail::op<pybind11::detail::op_eq, pybind11::detail::op_l, pybind11::detail::self_t, pybind11::detail::self_t>; Extra = {}; typename std::enable_if<T::op_enable_ifhook, int>::type = 0; type = mapnik::datasource; options = {std::shared_ptr}]’ src/mapnik_datasource.cpp:156:34: required from here /usr/local/lib/python3.9/dist-packages/pybind11/include/pybind11/operators.h:111:18: error: invalid abstract return type ‘mapnik::datasource’ 111 | static B execute_cast(const L &l, const R &r) { return B(expr); } \ | ^~~~ /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::optional mapnik::datasource::get_geometry_type() const’ 95 | virtual std::optional 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 mapnik::datasource::envelope() const’ 98 | virtual box2d envelope() const = 0; | ^~~~ /usr/local/include/mapnik/datasource.hpp:99:30: note: ‘virtual mapnik::layer_descriptor mapnik::datasource::get_descriptor() const’ 99 | virtual layer_descriptor get_descriptor() const = 0; | ^~~~~~ error: command '/usr/bin/c++' failed with exit code 1 错误1 错误2

tomhughes commented 4 weeks ago

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.

sebastic commented 4 weeks ago
 /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-config which 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.