summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2007-12-06 13:15:13 (GMT)
committerChristian Heimes <christian@cheimes.de>2007-12-06 13:15:13 (GMT)
commitd3fc07a4a076143b9b20f8236e9d1c07bfb818dc (patch)
tree7977e3d3ecb9088129b06480cf076bb8f81f681c /Lib
parentd6b20dc54fb46e699fe6358534ee8302ad91d303 (diff)
downloadcpython-d3fc07a4a076143b9b20f8236e9d1c07bfb818dc.zip
cpython-d3fc07a4a076143b9b20f8236e9d1c07bfb818dc.tar.gz
cpython-d3fc07a4a076143b9b20f8236e9d1c07bfb818dc.tar.bz2
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.
Diffstat (limited to 'Lib')
-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