Commit ae50fdd2 authored by Christian Heimes's avatar Christian Heimes

Fixed get_config_h_filename for Windows. Without the patch it can't find the...

Fixed get_config_h_filename for Windows. Without the patch it can't find the pyconfig.h file inside a build tree.
Added several small unit tests for sysconfig.
parent c03780a3
......@@ -22,16 +22,17 @@ from distutils.errors import DistutilsPlatformError
PREFIX = os.path.normpath(sys.prefix)
EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
# Path to the base directory of the project. On Windows the binary may
# live in project/PCBuild9
project_base = os.path.dirname(os.path.abspath(sys.executable))
if os.name == "nt" and "pcbuild" in project_base[-8:].lower():
project_base = os.path.abspath(os.path.join(project_base, os.path.pardir))
# python_build: (Boolean) if true, we're either building Python or
# building an extension with an un-installed Python, so we use
# different (hard-wired) directories.
argv0_path = os.path.dirname(os.path.abspath(sys.executable))
landmark = os.path.join(argv0_path, "Modules", "Setup")
python_build = os.path.isfile(landmark)
del landmark
python_build = os.path.isfile(os.path.join(project_base, "Modules",
"Setup.dist"))
def get_python_version():
......@@ -185,7 +186,10 @@ def customize_compiler(compiler):
def get_config_h_filename():
"""Return full pathname of installed pyconfig.h file."""
if python_build:
inc_dir = argv0_path
if os.name == "nt":
inc_dir = os.path.join(project_base, "PC")
else:
inc_dir = project_base
else:
inc_dir = get_python_inc(plat_specific=1)
if get_python_version() < '2.2':
......@@ -428,6 +432,8 @@ def _init_nt():
g['SO'] = '.pyd'
g['EXE'] = ".exe"
g['VERSION'] = get_python_version().replace(".", "")
g['BINDIR'] = os.path.dirname(os.path.abspath(sys.executable))
global _config_vars
_config_vars = g
......
"""Tests for distutils.dist."""
from distutils import sysconfig
import os
import sys
import unittest
from test.test_support import TESTFN
class SysconfigTestCase(unittest.TestCase):
def test_get_config_h_filename(self):
config_h = sysconfig.get_config_h_filename()
self.assert_(os.path.isfile(config_h), config_h)
def test_get_python_lib(self):
lib_dir = sysconfig.get_python_lib()
self.assert_(os.path.isdir(lib_dir), lib_dir)
# test for pythonxx.lib?
def test_get_python_inc(self):
inc_dir = sysconfig.get_python_inc()
self.assert_(os.path.isdir(inc_dir), inc_dir)
python_h = os.path.join(inc_dir, "Python.h")
self.assert_(os.path.isfile(python_h), python_h)
def test_get_config_vars(self):
cvars = sysconfig.get_config_vars()
self.assert_(isinstance(cvars, dict))
self.assert_(cvars)
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(SysconfigTestCase))
return suite
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment