diff --git a/setup.py b/setup.py index 1bf0bcff5..07163d001 100755 --- a/setup.py +++ b/setup.py @@ -15,6 +15,7 @@ import shutil import struct import subprocess import sys +import sysconfig import warnings from setuptools import Extension, setup @@ -504,8 +505,16 @@ class pil_build_ext(build_ext): for d in os.environ[k].split(os.path.pathsep): _add_directory(library_dirs, d) - _add_directory(library_dirs, os.path.join(sys.prefix, "lib")) - _add_directory(include_dirs, os.path.join(sys.prefix, "include")) + _add_directory( + library_dirs, + (sys.prefix == sys.base_prefix and sysconfig.get_config_var("LIBDIR")) + or os.path.join(sys.prefix, "lib"), + ) + _add_directory( + include_dirs, + (sys.prefix == sys.base_prefix and sysconfig.get_config_var("INCLUDEDIR")) + or os.path.join(sys.prefix, "include"), + ) # # add platform directories