Commit a470738b authored by Florent Xicluna's avatar Florent Xicluna

Merged revisions 78828 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/trunk

........
  r78828 | florent.xicluna | 2010-03-11 00:58:42 +0100 (jeu, 11 mar 2010) | 2 lines

  Issue #7880: Fix sysconfig when the python executable is a symbolic link.
........
parent 0f64b0b9
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
""" """
import sys import sys
import os import os
from os.path import pardir, abspath from os.path import pardir, realpath
_INSTALL_SCHEMES = { _INSTALL_SCHEMES = {
'posix_prefix': { 'posix_prefix': {
...@@ -84,16 +84,16 @@ _PREFIX = os.path.normpath(sys.prefix) ...@@ -84,16 +84,16 @@ _PREFIX = os.path.normpath(sys.prefix)
_EXEC_PREFIX = os.path.normpath(sys.exec_prefix) _EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
_CONFIG_VARS = None _CONFIG_VARS = None
_USER_BASE = None _USER_BASE = None
_PROJECT_BASE = abspath(os.path.dirname(sys.executable)) _PROJECT_BASE = os.path.dirname(realpath(sys.executable))
if os.name == "nt" and "pcbuild" in _PROJECT_BASE[-8:].lower(): if os.name == "nt" and "pcbuild" in _PROJECT_BASE[-8:].lower():
_PROJECT_BASE = abspath(os.path.join(_PROJECT_BASE, pardir)) _PROJECT_BASE = realpath(os.path.join(_PROJECT_BASE, pardir))
# PC/VS7.1 # PC/VS7.1
if os.name == "nt" and "\\pc\\v" in _PROJECT_BASE[-10:].lower(): if os.name == "nt" and "\\pc\\v" in _PROJECT_BASE[-10:].lower():
_PROJECT_BASE = abspath(os.path.join(_PROJECT_BASE, pardir, pardir)) _PROJECT_BASE = realpath(os.path.join(_PROJECT_BASE, pardir, pardir))
# PC/AMD64 # PC/AMD64
if os.name == "nt" and "\\pcbuild\\amd64" in _PROJECT_BASE[-14:].lower(): if os.name == "nt" and "\\pcbuild\\amd64" in _PROJECT_BASE[-14:].lower():
_PROJECT_BASE = abspath(os.path.join(_PROJECT_BASE, pardir, pardir)) _PROJECT_BASE = realpath(os.path.join(_PROJECT_BASE, pardir, pardir))
def is_python_build(): def is_python_build():
for fn in ("Setup.dist", "Setup.local"): for fn in ("Setup.dist", "Setup.local"):
...@@ -296,7 +296,7 @@ def _init_non_posix(vars): ...@@ -296,7 +296,7 @@ def _init_non_posix(vars):
vars['SO'] = '.pyd' vars['SO'] = '.pyd'
vars['EXE'] = '.exe' vars['EXE'] = '.exe'
vars['VERSION'] = _PY_VERSION_SHORT_NO_DOT vars['VERSION'] = _PY_VERSION_SHORT_NO_DOT
vars['BINDIR'] = os.path.dirname(os.path.abspath(sys.executable)) vars['BINDIR'] = os.path.dirname(realpath(sys.executable))
# #
# public APIs # public APIs
......
...@@ -8,9 +8,10 @@ import unittest ...@@ -8,9 +8,10 @@ import unittest
import sys import sys
import test import test
import os import os
import subprocess
from copy import copy, deepcopy from copy import copy, deepcopy
from test.support import run_unittest, TESTFN from test.support import run_unittest, TESTFN, unlink, get_attribute
import sysconfig import sysconfig
from sysconfig import (get_paths, get_platform, get_config_vars, from sysconfig import (get_paths, get_platform, get_config_vars,
...@@ -237,6 +238,23 @@ class TestSysConfig(unittest.TestCase): ...@@ -237,6 +238,23 @@ class TestSysConfig(unittest.TestCase):
'posix_prefix', 'posix_user') 'posix_prefix', 'posix_user')
self.assertEquals(get_scheme_names(), wanted) self.assertEquals(get_scheme_names(), wanted)
def test_symlink(self):
# Issue 7880
symlink = get_attribute(os, "symlink")
def get(python):
cmd = [python, '-c',
'import sysconfig; print sysconfig.get_platform()']
p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
return p.communicate()
real = os.path.realpath(sys.executable)
link = os.path.abspath(TESTFN)
symlink(real, link)
try:
self.assertEqual(get(real), get(link))
finally:
unlink(link)
def test_main(): def test_main():
run_unittest(TestSysConfig) run_unittest(TestSysConfig)
......
...@@ -270,6 +270,8 @@ C-API ...@@ -270,6 +270,8 @@ C-API
Library Library
------- -------
- Issue #7880: Fix sysconfig when the python executable is a symbolic link.
- Issue #6509: fix re.sub to work properly when the pattern, the string, and - Issue #6509: fix re.sub to work properly when the pattern, the string, and
the replacement were all bytes. Patch by Antoine Pitrou. the replacement were all bytes. Patch by Antoine Pitrou.
......
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