diff options
author | Ned Deily <nad@acm.org> | 2012-02-05 23:55:50 (GMT) |
---|---|---|
committer | Ned Deily <nad@acm.org> | 2012-02-05 23:55:50 (GMT) |
commit | 2c8bf04308a078cc8c24dfe16afa816efebeb2da (patch) | |
tree | 74963ad9fa3c36897c8d262f6887962c5bae54e9 /Lib | |
parent | adb87e2677caad4cd167e4915763dda105bc982c (diff) | |
download | cpython-2c8bf04308a078cc8c24dfe16afa816efebeb2da.zip cpython-2c8bf04308a078cc8c24dfe16afa816efebeb2da.tar.gz cpython-2c8bf04308a078cc8c24dfe16afa816efebeb2da.tar.bz2 |
Issue #10881: Fix test_site failures with OS X framework builds.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/site.py | 2 | ||||
-rw-r--r-- | Lib/sysconfig.py | 5 | ||||
-rw-r--r-- | Lib/test/test_site.py | 26 |
3 files changed, 17 insertions, 16 deletions
diff --git a/Lib/site.py b/Lib/site.py index 90cf331..54e5154 100644 --- a/Lib/site.py +++ b/Lib/site.py @@ -312,7 +312,7 @@ def getsitepackages(): # locations. from sysconfig import get_config_var framework = get_config_var("PYTHONFRAMEWORK") - if framework and "/%s.framework/"%(framework,) in prefix: + if framework: sitepackages.append( os.path.join("/Library", framework, sys.version[:3], "site-packages")) diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py index 6000024..6314cfe 100644 --- a/Lib/sysconfig.py +++ b/Lib/sysconfig.py @@ -176,8 +176,9 @@ def _getuserbase(): if sys.platform == "darwin": framework = get_config_var("PYTHONFRAMEWORK") if framework: - return joinuser("~", "Library", framework, "%d.%d"%( - sys.version_info[:2])) + return env_base if env_base else \ + joinuser("~", "Library", framework, "%d.%d" + % (sys.version_info[:2])) return env_base if env_base else joinuser("~", ".local") diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py index 9fd23fa..f4b5fc6 100644 --- a/Lib/test/test_site.py +++ b/Lib/test/test_site.py @@ -228,7 +228,19 @@ class HelperFunctionsTests(unittest.TestCase): self.assertEqual(len(dirs), 1) wanted = os.path.join('xoxo', 'Lib', 'site-packages') self.assertEqual(dirs[0], wanted) + elif (sys.platform == "darwin" and + sysconfig.get_config_var("PYTHONFRAMEWORK")): + # OS X framework builds + site.PREFIXES = ['Python.framework'] + dirs = site.getsitepackages() + self.assertEqual(len(dirs), 3) + wanted = os.path.join('/Library', + sysconfig.get_config_var("PYTHONFRAMEWORK"), + sys.version[:3], + 'site-packages') + self.assertEqual(dirs[2], wanted) elif os.sep == '/': + # OS X non-framwework builds, Linux, FreeBSD, etc self.assertEqual(len(dirs), 2) wanted = os.path.join('xoxo', 'lib', 'python' + sys.version[:3], 'site-packages') @@ -236,24 +248,12 @@ class HelperFunctionsTests(unittest.TestCase): wanted = os.path.join('xoxo', 'lib', 'site-python') self.assertEqual(dirs[1], wanted) else: + # other platforms self.assertEqual(len(dirs), 2) self.assertEqual(dirs[0], 'xoxo') wanted = os.path.join('xoxo', 'lib', 'site-packages') self.assertEqual(dirs[1], wanted) - # let's try the specific Apple location - if (sys.platform == "darwin" and - sysconfig.get_config_var("PYTHONFRAMEWORK")): - site.PREFIXES = ['Python.framework'] - dirs = site.getsitepackages() - self.assertEqual(len(dirs), 4) - wanted = os.path.join('~', 'Library', 'Python', - sys.version[:3], 'site-packages') - self.assertEqual(dirs[2], os.path.expanduser(wanted)) - wanted = os.path.join('/Library', 'Python', sys.version[:3], - 'site-packages') - self.assertEqual(dirs[3], wanted) - class PthFile(object): """Helper class for handling testing of .pth files""" |