Compatibility fallback for absent sysconfig module on Python 2.6
@@ -14,7 +14,6 @@ import re
import shutil
import stat
import sys
-import sysconfig
import tempfile
import warnings
@@ -41,6 +40,31 @@ from pip._vendor import pkg_resources
from pip._vendor.packaging.utils import canonicalize_name
from pip._vendor import pytoml
+try:
+ from sysconfig import get_paths
+except ImportError:
+ # This section is for compatibility with Python 2.6, and can be removed once
+ # Python 2.7 is the minimum supported version.
+ sysconfig = None
+
+ def get_paths(install_scheme, vars):
+ prefix = vars['base']
+ if os.name == 'nt':
+ return {
+ 'purelib': '{0}/Lib/site-packages'.format(prefix),
+ 'platlib': '{0}/Lib/site-packages'.format(prefix),
+ 'scripts': '{0}/Scripts'.format(prefix),
+ }
+ else:
+ py_version_short = '{0}.{1}'.format(*sys.version_info[:2])
+ return {
+ 'purelib': '{0}/lib/python{1}/site-packages'.format(
+ prefix, py_version_short),
+ 'platlib': '{0}/lib/python{1}/site-packages'.format(
+ prefix, py_version_short),
+ 'scripts': '{0}/bin'.format(prefix),
+ }
+
wheel_ext = '.whl'
@@ -644,7 +668,7 @@ class BuildEnvironment(object):
self.save_pythonpath = os.environ.get('PYTHONPATH', None)
install_scheme = 'nt' if (os.name == 'nt') else 'posix_prefix'
- install_dirs = sysconfig.get_paths(install_scheme, vars={
+ install_dirs = get_paths(install_scheme, vars={
'base': self.prefix,
'platbase': self.prefix,
})
