diff -r 4bfd91a45c81 Lib/distutils/sysconfig.py --- a/Lib/distutils/sysconfig.py Sun Sep 18 11:22:29 2016 +0300 +++ b/Lib/distutils/sysconfig.py Sun Sep 18 13:45:31 2016 +0100 @@ -73,6 +73,20 @@ return '%d.%d' % sys.version_info[:2] +def _get_build_dir(name, plat_specific): + # Assume the executable is in the build directory. The + # pyconfig.h file should be in the same directory. Since + # the build directory may not be the source directory, we + # must use "srcdir" from the makefile to find the "Include" + # directory. + base = _sys_home or project_base + if plat_specific: + return base + else: + thedir = os.path.join(base, name) + return os.path.normpath(thedir) + + def get_python_inc(plat_specific=0, prefix=None): """Return the directory containing installed Python header files. @@ -88,19 +102,7 @@ prefix = plat_specific and BASE_EXEC_PREFIX or BASE_PREFIX if os.name == "posix": if python_build: - # Assume the executable is in the build directory. The - # pyconfig.h file should be in the same directory. Since - # the build directory may not be the source directory, we - # must use "srcdir" from the makefile to find the "Include" - # directory. - base = _sys_home or project_base - if plat_specific: - return base - if _sys_home: - incdir = os.path.join(_sys_home, get_config_var('AST_H_DIR')) - else: - incdir = os.path.join(get_config_var('srcdir'), 'Include') - return os.path.normpath(incdir) + return _get_build_dir('Include', plat_specific) python_dir = 'python' + get_python_version() + build_flags return os.path.join(prefix, "include", python_dir) elif os.name == "nt": @@ -131,6 +133,9 @@ else: prefix = plat_specific and EXEC_PREFIX or PREFIX + if python_build: + return _get_build_dir('Lib', plat_specific) + if os.name == "posix": libpython = os.path.join(prefix, "lib", "python" + get_python_version()) diff -r 4bfd91a45c81 Lib/distutils/tests/test_sysconfig.py --- a/Lib/distutils/tests/test_sysconfig.py Sun Sep 18 11:22:29 2016 +0300 +++ b/Lib/distutils/tests/test_sysconfig.py Sun Sep 18 13:45:31 2016 +0100 @@ -36,8 +36,9 @@ # XXX doesn't work on Linux when Python was never installed before #self.assertTrue(os.path.isdir(lib_dir), lib_dir) # test for pythonxx.lib? - self.assertNotEqual(sysconfig.get_python_lib(), - sysconfig.get_python_lib(prefix=TESTFN)) + if not sysconfig.python_build: + self.assertNotEqual(sysconfig.get_python_lib(), + sysconfig.get_python_lib(prefix=TESTFN)) def test_get_python_inc(self): inc_dir = sysconfig.get_python_inc() diff -r 4bfd91a45c81 Lib/sysconfig.py --- a/Lib/sysconfig.py Sun Sep 18 11:22:29 2016 +0300 +++ b/Lib/sysconfig.py Sun Sep 18 13:45:31 2016 +0100 @@ -135,9 +135,11 @@ _PYTHON_BUILD = is_python_build(True) if _PYTHON_BUILD: - for scheme in ('posix_prefix', 'posix_home'): - _INSTALL_SCHEMES[scheme]['include'] = '{srcdir}/Include' + for scheme in ('posix_prefix', 'posix_home', 'posix_user', + 'nt', 'nt_user'): + _INSTALL_SCHEMES[scheme]['include'] = '{projectbase}/Include' _INSTALL_SCHEMES[scheme]['platinclude'] = '{projectbase}/.' + _INSTALL_SCHEMES[scheme]['stdlib'] = '{projectbase}/Lib' def _subst_vars(s, local_vars): diff -r 4bfd91a45c81 Lib/test/test_sysconfig.py --- a/Lib/test/test_sysconfig.py Sun Sep 18 11:22:29 2016 +0300 +++ b/Lib/test/test_sysconfig.py Sun Sep 18 13:45:31 2016 +0100 @@ -260,6 +260,7 @@ finally: unlink(link) + @unittest.skipIf(os.name != 'posix', 'Test is for POSIX only') def test_user_similar(self): # Issue #8759: make sure the posix scheme for the users # is similar to the global posix_prefix one @@ -280,7 +281,8 @@ global_path = global_path.replace(sys.base_prefix, sys.prefix) base = base.replace(sys.base_prefix, sys.prefix) user_path = get_path(name, 'posix_user') - self.assertEqual(user_path, global_path.replace(base, user, 1)) + self.assertEqual(user_path, global_path.replace(base, user, 1), + 'Failed for %s' % name) def test_main(self): # just making sure _main() runs and returns things in the stdout