summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/distutils/sysconfig.py22
-rw-r--r--Lib/distutils/tests/test_sysconfig.py36
2 files changed, 50 insertions, 8 deletions
diff --git a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py
index 0cfafab..2ea7c78 100644
--- a/Lib/distutils/sysconfig.py
+++ b/Lib/distutils/sysconfig.py
@@ -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
diff --git a/Lib/distutils/tests/test_sysconfig.py b/Lib/distutils/tests/test_sysconfig.py
new file mode 100644
index 0000000..8337b0d
--- /dev/null
+++ b/Lib/distutils/tests/test_sysconfig.py
@@ -0,0 +1,36 @@
+"""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