Skip to content

Commit dea5abe

Browse files
committed
Remove support for Python 2
1 parent 27cd371 commit dea5abe

77 files changed

Lines changed: 61 additions & 392 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

debian/control

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ Build-Depends: debhelper (>= 9),
99
szn-libmapnik-dev (= 3:3.13.0),
1010
szn-mapnik-vector-tile-dev (>= 1.6.1),
1111
libprotobuf-dev,
12-
python-all-dev,
13-
python-setuptools,
14-
python-cairo,
15-
python-cairo-dev,
16-
python-nose,
1712
python3-all-dev,
1813
python3-setuptools,
1914
python3-cairo,
@@ -24,27 +19,6 @@ Standards-Version: 3.9.8
2419
Vcs-Browser: https://github.com/mapycz/python-mapnik
2520
Vcs-Git: https://github.com/mapycz/python-mapnik.git
2621
Homepage: https://github.com/mapycz/python-mapnik
27-
X-Python-Version: >= 2.7
28-
29-
Package: szn-python-mapnik
30-
Architecture: any
31-
Depends: python-cairo | szn-python-cairo,
32-
szn-libmapnik (= 3:3.13.0),
33-
${python:Depends},
34-
${shlibs:Depends},
35-
${misc:Depends}
36-
Provides: ${python:Provides}
37-
Description: Python 2 interface to the mapnik library
38-
Mapnik is an OpenSource C++ toolkit for developing GIS
39-
(Geographic Information Systems) applications. At the core is a C++
40-
shared library providing algorithms/patterns for spatial data access and
41-
visualization.
42-
.
43-
Essentially a collection of geographic objects (map, layer, datasource,
44-
feature, geometry), the library doesn't rely on "windowing systems" and
45-
is intended to work in multi-threaded environments
46-
.
47-
This package contains the bindings for Python 2.
4822

4923
Package: szn-python3-mapnik
5024
Architecture: any

debian/rules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export LIB_DIR_NAME=/mapnik/3.0
2121

2222
%:
2323
dh $@ \
24-
--with python2,python3 \
24+
--with python3 \
2525
--buildsystem=pybuild \
2626
--parallel
2727

debian/szn-python-mapnik.install

Lines changed: 0 additions & 1 deletion
This file was deleted.

debian/szn-python3-mapnik.install

Lines changed: 0 additions & 1 deletion
This file was deleted.

setup.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#! /usr/bin/env python
1+
#!/usr/bin/env python3
22

33
import os
44
import os.path
@@ -12,16 +12,12 @@
1212

1313
from setuptools import Command, Extension, setup
1414

15-
PYTHON3 = sys.version_info.major == 3
16-
1715
NEEDED_BOOST_LIBS = ['python', 'thread', 'system']
1816

1917
# Utils
2018
def check_output(args, shell=False):
2119
output = subprocess.check_output(args, shell=shell)
22-
if PYTHON3:
23-
# check_output returns bytes in PYTHON3.
24-
output = output.decode()
20+
output = output.decode()
2521
return output.rstrip('\n')
2622

2723
def boost_suffixes():

src/mapnik_datasource.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,7 @@ std::shared_ptr<mapnik::datasource> create_datasource(dict const& d)
6464
PyObject* temp = PyUnicode_AsUTF8String(obj.ptr());
6565
if (temp)
6666
{
67-
#if PY_VERSION_HEX >= 0x03000000
6867
char* c_str = PyBytes_AsString(temp);
69-
#else
70-
char* c_str = PyString_AsString(temp);
71-
#endif
7268
params[key] = std::string(c_str);
7369
Py_DecRef(temp);
7470
}

src/mapnik_feature.cpp

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,7 @@ struct unicode_string_from_python_str
117117

118118
static void* convertible(PyObject* obj_ptr)
119119
{
120-
if (!(
121-
#if PY_VERSION_HEX >= 0x03000000
122-
PyBytes_Check(obj_ptr)
123-
#else
124-
PyString_Check(obj_ptr)
125-
#endif
126-
|| PyUnicode_Check(obj_ptr)))
120+
if (!(PyBytes_Check(obj_ptr) || PyUnicode_Check(obj_ptr)))
127121
return 0;
128122
return obj_ptr;
129123
}
@@ -136,19 +130,11 @@ struct unicode_string_from_python_str
136130
if (PyUnicode_Check(obj_ptr)) {
137131
PyObject *encoded = PyUnicode_AsEncodedString(obj_ptr, "utf8", "replace");
138132
if (encoded) {
139-
#if PY_VERSION_HEX >= 0x03000000
140133
value = PyBytes_AsString(encoded);
141-
#else
142-
value = PyString_AsString(encoded);
143-
#endif
144134
Py_DecRef(encoded);
145135
}
146136
} else {
147-
#if PY_VERSION_HEX >= 0x03000000
148137
value = PyBytes_AsString(obj_ptr);
149-
#else
150-
value = PyString_AsString(obj_ptr);
151-
#endif
152138
}
153139
if (value == 0) boost::python::throw_error_already_set();
154140
void* storage = (

src/mapnik_geometry.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,7 @@ PyObject* to_wkb_impl(mapnik::geometry::geometry<double> const& geom, mapnik::wk
101101
mapnik::util::wkb_buffer_ptr wkb = mapnik::util::to_wkb(geom,byte_order);
102102
if (wkb)
103103
{
104-
return
105-
#if PY_VERSION_HEX >= 0x03000000
106-
::PyBytes_FromStringAndSize
107-
#else
108-
::PyString_FromStringAndSize
109-
#endif
110-
((const char*)wkb->buffer(),wkb->size());
104+
return ::PyBytes_FromStringAndSize((const char*)wkb->buffer(),wkb->size());
111105
}
112106
else
113107
{

src/mapnik_image.cpp

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,7 @@
6161
#if defined(HAVE_CAIRO) && defined(HAVE_PYCAIRO)
6262
#include <mapnik/cairo/cairo_context.hpp>
6363
#include <mapnik/cairo/cairo_image_util.hpp>
64-
#if PY_MAJOR_VERSION >= 3
6564
#include <py3cairo.h>
66-
#else
67-
#include <pycairo.h>
68-
#endif
6965
#include <cairo.h>
7066
#endif
7167

@@ -80,38 +76,20 @@ using namespace boost::python;
8076
// output 'raw' pixels
8177
PyObject* tostring1( image_any const& im)
8278
{
83-
return
84-
#if PY_VERSION_HEX >= 0x03000000
85-
::PyBytes_FromStringAndSize
86-
#else
87-
::PyString_FromStringAndSize
88-
#endif
89-
((const char*)im.bytes(),im.size());
79+
return ::PyBytes_FromStringAndSize((const char*)im.bytes(),im.size());
9080
}
9181

9282
// encode (png,jpeg)
9383
PyObject* tostring2(image_any const & im, std::string const& format)
9484
{
9585
std::string s = mapnik::save_to_string(im, format);
96-
return
97-
#if PY_VERSION_HEX >= 0x03000000
98-
::PyBytes_FromStringAndSize
99-
#else
100-
::PyString_FromStringAndSize
101-
#endif
102-
(s.data(),s.size());
86+
return ::PyBytes_FromStringAndSize (s.data(),s.size());
10387
}
10488

10589
PyObject* tostring3(image_any const & im, std::string const& format, mapnik::rgba_palette const& pal)
10690
{
10791
std::string s = mapnik::save_to_string(im, format, pal);
108-
return
109-
#if PY_VERSION_HEX >= 0x03000000
110-
::PyBytes_FromStringAndSize
111-
#else
112-
::PyString_FromStringAndSize
113-
#endif
114-
(s.data(),s.size());
92+
return ::PyBytes_FromStringAndSize(s.data(),s.size());
11593
}
11694

11795

src/mapnik_image_view.cpp

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,38 +46,20 @@ PyObject* view_tostring1(image_view_any const& view)
4646
{
4747
std::ostringstream ss(std::ios::out|std::ios::binary);
4848
mapnik::view_to_stream(view, ss);
49-
return
50-
#if PY_VERSION_HEX >= 0x03000000
51-
::PyBytes_FromStringAndSize
52-
#else
53-
::PyString_FromStringAndSize
54-
#endif
55-
((const char*)ss.str().c_str(),ss.str().size());
49+
return ::PyBytes_FromStringAndSize((const char*)ss.str().c_str(),ss.str().size());
5650
}
5751

5852
// encode (png,jpeg)
5953
PyObject* view_tostring2(image_view_any const & view, std::string const& format)
6054
{
6155
std::string s = save_to_string(view, format);
62-
return
63-
#if PY_VERSION_HEX >= 0x03000000
64-
::PyBytes_FromStringAndSize
65-
#else
66-
::PyString_FromStringAndSize
67-
#endif
68-
(s.data(),s.size());
56+
return ::PyBytes_FromStringAndSize(s.data(),s.size());
6957
}
7058

7159
PyObject* view_tostring3(image_view_any const & view, std::string const& format, mapnik::rgba_palette const& pal)
7260
{
7361
std::string s = save_to_string(view, format, pal);
74-
return
75-
#if PY_VERSION_HEX >= 0x03000000
76-
::PyBytes_FromStringAndSize
77-
#else
78-
::PyString_FromStringAndSize
79-
#endif
80-
(s.data(),s.size());
62+
return ::PyBytes_FromStringAndSize(s.data(),s.size());
8163
}
8264

8365
bool is_solid(image_view_any const& view)

0 commit comments

Comments
 (0)