Skip to content

Commit 19f19ac

Browse files
committed
Make the code future-proof against removal of distutils module.
1 parent 4fdb678 commit 19f19ac

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/setup_common.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@
3030
if sys.version_info[0] < 3:
3131
import commands as subprocess
3232
from os import path as os_path
33-
from distutils.sysconfig import get_python_lib
33+
try:
34+
from distutils.sysconfig import get_python_lib, get_config_var
35+
__python_lib = get_python_lib(1)
36+
except ImportError:
37+
from sysconfig import get_config_var, get_path
38+
__python_lib = get_path('platlib')
3439

3540
# libxml2 - C flags
3641
def libxml2_include(incdir):
@@ -50,7 +55,7 @@ def libxml2_include(incdir):
5055

5156
# libxml2 - library flags
5257
def libxml2_lib(libdir, libs):
53-
libdir.append(get_python_lib(1))
58+
libdir.append(__python_lib)
5459
if os_path.exists("/etc/debian_version"): #. XXX: Debian Workaround...
5560
libdir.append("/usr/lib/pymodules/python%d.%d"%sys.version_info[0:2])
5661

@@ -69,7 +74,10 @@ def libxml2_lib(libdir, libs):
6974
libs.append(l.replace("-l", "", 1))
7075

7176
# this library is not reported and we need it anyway
72-
libs.append('xml2mod')
77+
if get_config_var("SOABI"):
78+
libs.append('xml2mod.%s' % get_config_var("SOABI"))
79+
else:
80+
libs.append('xml2mod')
7381

7482

7583

0 commit comments

Comments
 (0)