root/galaxy-central/lib/galaxy/__init__.py

リビジョン 2, 3.4 KB (コミッタ: hatakeyama, 14 年 前)

import galaxy-central

行番号 
1"""
2Galaxy root package -- this is a namespace package.
3"""
4
5__import__( "pkg_resources" ).declare_namespace( __name__ )
6
7import os, sys, re
8from distutils.sysconfig import get_config_var, get_config_vars
9
10import pkg_resources
11
12# patch get_platform() for better ABI recognition
13def _get_build_platform():
14    plat = pkg_resources._get_build_platform()
15    if sys.version_info[:2] == ( 2, 5 ) and \
16        ( ( os.uname()[-1] in ( 'i386', 'ppc' ) and sys.platform == 'darwin' and os.path.abspath( sys.prefix ).startswith( '/System' ) ) or \
17          ( sys.platform == 'darwin' and get_config_vars().get('UNIVERSALSDK', '').strip() ) ):
18        plat = 'macosx-10.3-fat'
19    if sys.platform == "sunos5" and not (plat.endswith('_32') or plat.endswith('_64')):
20        if sys.maxint > 2**31:
21            plat += '_64'
22        else:
23            plat += '_32'
24    if not (plat.endswith('-ucs2') or plat.endswith('-ucs4')):
25        if sys.maxunicode > 2**16:
26            plat += '-ucs4'
27        else:
28            plat += '-ucs2'
29    return plat
30try:
31    assert pkg_resources._get_build_platform
32except:
33    pkg_resources._get_build_platform = pkg_resources.get_build_platform
34    pkg_resources.get_build_platform = _get_build_platform
35    pkg_resources.get_platform = _get_build_platform
36
37# patch compatible_platforms() to allow for Solaris binary compatibility
38solarisVersionString = re.compile(r"solaris-(\d)\.(\d+)-(.*)")
39def _compatible_platforms(provided,required):
40    # this is a bit kludgey since we need to know a bit about what happened in
41    # the original method
42    if provided is None or required is None or provided==required:
43        return True     # easy case
44    reqMac = pkg_resources.macosVersionString.match(required)
45    if reqMac:
46        return pkg_resources._compatible_platforms(provided,required)
47    reqSol = solarisVersionString.match(required)
48    if reqSol:
49        provSol = solarisVersionString.match(provided)
50        if not provSol:
51            return False
52        if provSol.group(1) != reqSol.group(1) or \
53            provSol.group(3) != reqSol.group(3):
54            return False
55        if int(provSol.group(2)) > int(reqSol.group(2)):
56            return False
57        return True
58    return False
59try:
60    assert pkg_resources._compatible_platforms
61except:
62    pkg_resources._compatible_platforms = pkg_resources.compatible_platforms
63    pkg_resources.compatible_platforms = _compatible_platforms
64
65# patch to insert eggs at the beginning of sys.path instead of at the end
66def _insert_on(self, path, loc = None):
67    """Insert self.location in path before its nearest parent directory"""
68
69    loc = loc or self.location
70    if not loc:
71        return
72
73    nloc = pkg_resources._normalize_cached(loc)
74    npath= [(p and pkg_resources._normalize_cached(p) or p) for p in path]
75
76    if path is sys.path:
77        self.check_version_conflict()
78    path.insert(0, loc)
79
80    # remove dups
81    while 1:
82        try:
83            np = npath.index(nloc, 1)
84        except ValueError:
85            break
86        else:
87            del npath[np], path[np]
88
89    return
90try:
91    assert pkg_resources.Distribution._insert_on
92except:
93    pkg_resources.Distribution._insert_on = pkg_resources.Distribution.insert_on
94    pkg_resources.Distribution.insert_on = _insert_on
95
96# patch to add the NullHandler class to logging
97if sys.version_info[:2] < ( 2, 7 ):
98    import logging
99    class NullHandler( logging.Handler ):
100        def emit( self, record ):
101            pass
102    logging.NullHandler = NullHandler
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。