distutils init.py :  » Development » PyObjC » trunk » pyobjc » build-support » virtualenv-src » virtualenv_support » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Development » PyObjC 
PyObjC » trunk » pyobjc » build support » virtualenv src » virtualenv_support » distutils-init.py
import os
import sys
import warnings 
import ConfigParser # ConfigParser is not a virtualenv module, so we can use it to find the stdlib

dirname = os.path.dirname

distutils_path = os.path.join(os.path.dirname(ConfigParser.__file__), 'distutils')
if os.path.normpath(distutils_path) == os.path.dirname(os.path.normpath(__file__)):
    warnings.warn(
        "The virtualenv distutils package at %s appears to be in the same location as the system distutils?")
else:
    __path__.insert(0, distutils_path)
    exec open(os.path.join(distutils_path, '__init__.py')).read()

import dist
import sysconfig


## patch build_ext (distutils doesn't know how to get the libs directory
## path on windows - it hardcodes the paths around the patched sys.prefix)

if sys.platform == 'win32':
    from distutils.command.build_ext import build_ext
    class build_ext(old_build_ext):
        def finalize_options (self):
            if self.library_dirs is None:
                self.library_dirs = []
            
            self.library_dirs.insert(0, os.path.join(sys.real_prefix, "Libs"))
            old_build_ext.finalize_options(self)
            
    from distutils.command import build_ext
    build_ext_module.build_ext = build_ext

## distutils.dist patches:

old_find_config_files = dist.Distribution.find_config_files
def find_config_files(self):
    found = old_find_config_files(self)
    system_distutils = os.path.join(distutils_path, 'distutils.cfg')
    #if os.path.exists(system_distutils):
    #    found.insert(0, system_distutils)
        # What to call the per-user config file
    if os.name == 'posix':
        user_filename = ".pydistutils.cfg"
    else:
        user_filename = "pydistutils.cfg"
    user_filename = os.path.join(sys.prefix, user_filename)
    if os.path.isfile(user_filename):
        for item in list(found):
            if item.endswith('pydistutils.cfg'):
                found.remove(item)
        found.append(user_filename)
    return found
dist.Distribution.find_config_files = find_config_files

## distutils.sysconfig patches:

old_get_python_inc = sysconfig.get_python_inc
def sysconfig_get_python_inc(plat_specific=0, prefix=None):
    if prefix is None:
        prefix = sys.real_prefix
    return old_get_python_inc(plat_specific, prefix)
sysconfig_get_python_inc.__doc__ = old_get_python_inc.__doc__
sysconfig.get_python_inc = sysconfig_get_python_inc

old_get_python_lib = sysconfig.get_python_lib
def sysconfig_get_python_lib(plat_specific=0, standard_lib=0, prefix=None):
    if standard_lib and prefix is None:
        prefix = sys.real_prefix
    return old_get_python_lib(plat_specific, standard_lib, prefix)
sysconfig_get_python_lib.__doc__ = old_get_python_lib.__doc__
sysconfig.get_python_lib = sysconfig_get_python_lib

old_get_config_vars = sysconfig.get_config_vars
def sysconfig_get_config_vars(*args):
    real_vars = old_get_config_vars(*args)
    if sys.platform == 'win32':
        lib_dir = os.path.join(sys.real_prefix, "libs")
        if isinstance(real_vars, dict) and 'LIBDIR' not in real_vars:
            real_vars['LIBDIR'] = lib_dir # asked for all
        elif isinstance(real_vars, list) and 'LIBDIR' in args:
            real_vars = real_vars + [lib_dir] # asked for list
    return real_vars
sysconfig_get_config_vars.__doc__ = old_get_config_vars.__doc__
sysconfig.get_config_vars = sysconfig_get_config_vars
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.