コード例 #1
0
ファイル: test_sysconfig.py プロジェクト: termim/setuptools
 def test_parse_config_h(self):
     config_h = sysconfig.get_config_h_filename()
     input = {}
     with open(config_h, encoding="utf-8") as f:
         result = sysconfig.parse_config_h(f, g=input)
     self.assertTrue(input is result)
     with open(config_h, encoding="utf-8") as f:
         result = sysconfig.parse_config_h(f)
     self.assertTrue(isinstance(result, dict))
コード例 #2
0
ファイル: Util.py プロジェクト: yuetianle/binary_blobs
def GetConfigVars(*args):
    """Parse the installed pyconfig.h file.

    A dictionary containing name/value pairs is returned.  If an
    optional dictionary is passed in as the second argument, it is
    used instead of a new dictionary.
    """
    global _config_vars
    if _config_vars is None:
        _config_vars = {}
        filename = sysconfig.get_config_h_filename()
        try:
            fp = open(filename)
        except IOError, err:
            msg = "invalid Python installation: unable to open %s" % filename
            if err.strerror:
                msg += " (%s)" % msg.strerror
            raise DistutilsPlatformError(msg)
        try:
            if sys.version < '2.5':
                define_rx = re.compile("#define ([A-Z][a-zA-Z0-9_]+) (.*)$")
                undef_rx = re.compile("/[*] #undef ([A-Z][a-zA-Z0-9_]+) [*]/$")
                line = fp.readline()
                while line:
                    m = define_rx.match(line)
                    if m:
                        n, v = m.group(1, 2)
                        try:
                            v = int(v)
                        except ValueError:
                            pass
                        _config_vars[n] = v
                    else:
                        m = undef_rx.match(line)
                        if m:
                            _config_vars[m.group(1)] = 0
                    line = fp.readline()
            else:
                sysconfig.parse_config_h(fp, _config_vars)
        finally:
            fp.close()
コード例 #3
0
ファイル: Util.py プロジェクト: H1d3r/binary_blobs
def GetConfigVars(*args):
    """Parse the installed pyconfig.h file.

    A dictionary containing name/value pairs is returned.  If an
    optional dictionary is passed in as the second argument, it is
    used instead of a new dictionary.
    """
    global _config_vars
    if _config_vars is None:
        _config_vars = {}
        filename = sysconfig.get_config_h_filename()
        try:
            fp = open(filename)
        except IOError, err:
            msg = "invalid Python installation: unable to open %s" % filename
            if err.strerror:
                msg += " (%s)" % msg.strerror
            raise DistutilsPlatformError(msg)
        try:
            if sys.version < '2.5':
                define_rx = re.compile("#define ([A-Z][a-zA-Z0-9_]+) (.*)$")
                undef_rx = re.compile("/[*] #undef ([A-Z][a-zA-Z0-9_]+) [*]/$")
                line = fp.readline()
                while line:
                    m = define_rx.match(line)
                    if m:
                        n, v = m.group(1, 2)
                        try: v = int(v)
                        except ValueError: pass
                        _config_vars[n] = v
                    else:
                        m = undef_rx.match(line)
                        if m:
                            _config_vars[m.group(1)] = 0
                    line = fp.readline()
            else:
                sysconfig.parse_config_h(fp, _config_vars)
        finally:
            fp.close()
コード例 #4
0
ファイル: setup.py プロジェクト: jkloth/pyxml
        # HAVE_MEMMOVE is not in PC/pyconfig.h
        define_macros.extend([
         ('HAVE_MEMMOVE', '1'),
         ('XML_STATIC', ''),
        ])
    include_dirs = ['extensions/expat/lib']
    sources.extend([
        'extensions/expat/lib/xmlparse.c',
        'extensions/expat/lib/xmlrole.c',
        'extensions/expat/lib/xmltok.c',
        ])
    libraries = []
    library_dirs = []

config_h = get_config_h_filename()
config_h_vars = parse_config_h(open(config_h))
for feature_macro in ['HAVE_MEMMOVE', 'HAVE_BCOPY']:
    if config_h_vars.has_key(feature_macro):
        define_macros.append((feature_macro, '1'))

ext_modules.append(
    Extension(xml('.parsers.pyexpat'),
              define_macros=define_macros,
              include_dirs=include_dirs,
              library_dirs=library_dirs,
              libraries=libraries,
              extra_link_args=LDFLAGS,
              sources=sources
              ))

# Build sgmlop
コード例 #5
0
ファイル: setup.py プロジェクト: SublimeCodeIntel/codeintel
includes = [
    "src/expat",
]

defines = [
    ("XML_STATIC", None),
]

if sys.platform == "win32":
    # fake devstudio compilation to make sure winconfig.h is used
    defines.append(("COMPILED_FROM_DSP", None))
else:
    # determine suitable defines (based on Python's setup.py file)
    config_h = sysconfig.get_config_h_filename()
    config_h_vars = sysconfig.parse_config_h(open(config_h))
    for feature_macro in ["HAVE_MEMMOVE", "HAVE_BCOPY"]:
        if feature_macro in config_h_vars:
            defines.append((feature_macro, "1"))
    defines.append(("XML_NS", "1"))
    defines.append(("XML_DTD", "1"))
    if sys.byteorder == "little":
        defines.append(("BYTEORDER", "1234"))
    else:
        defines.append(("BYTEORDER", "4321"))
    defines.append(("XML_CONTEXT_BYTES", "1024"))


# --------------------------------------------------------------------
# distutils declarations
コード例 #6
0
ファイル: setup.py プロジェクト: machida-yuki/smart2
def copy_tree(*args, **kwargs):
    outputs = copy_tree_orig(*args, **kwargs)
    for i in range(len(outputs)):
        if outputs[i].endswith("bin/smart.py"):
            outputs[i] = outputs[i][:-3]
    return outputs
distutils.file_util.copy_file = copy_file
distutils.dir_util.copy_tree = copy_tree

# Some Python sysconfig use different directories for different prefixes
EXEC_PREFIX = get_config_var('exec_prefix')
PYTHONLIB = get_python_lib(plat_specific=1, standard_lib=0,
                           prefix=EXEC_PREFIX).replace(EXEC_PREFIX+os.sep, "")

config_h = sysconfig.get_config_h_filename()
config_h_vars = sysconfig.parse_config_h(open(config_h))

ext_modules = [
               Extension("smart.ccache", ["smart/ccache.c"]),
               Extension("smart.backends.rpm.crpmver",
                         ["smart/backends/rpm/crpmver.c"]),
               Extension("smart.backends.deb.cdebver",
                         ["smart/backends/deb/cdebver.c"]),
               Extension("smart.backends.deb._base",
                         ["smart/backends/deb/_base.c"]),
               Extension("smart.util.ctagfile",
                         ["smart/util/ctagfile.c"]),
               Extension("smart.util.cdistance",
                         ["smart/util/cdistance.c"])
              ]
コード例 #7
0
ファイル: setup_nolib.py プロジェクト: mc01104/CTR
from distutils.core import setup, Extension
from distutils.sysconfig import get_python_lib, parse_config_h
import os

lwprsources = ['lwprmodule.c', 
               '../src/lwpr.c', 
               '../src/lwpr_xml.c', 
               '../src/lwpr_math.c', 
               '../src/lwpr_binio.c', 
               '../src/lwpr_mem.c', 
               '../src/lwpr_aux.c']

configs = parse_config_h(file('../include/lwpr_config.h'))

if configs.has_key('HAVE_LIBEXPAT') and configs['HAVE_LIBEXPAT']:
   module = Extension('lwpr', 
      include_dirs = ['../include', os.path.join(get_python_lib(),'numpy','core','include')],
      libraries = ['expat'],   
      sources = lwprsources)
else:
   module = Extension('lwpr',
      include_dirs = ['../include', os.path.join(get_python_lib(),'numpy','core','include')],
      sources = lwprsources)

setup (name = 'LWPR Module',
       version = '1.1',
       description = 'Python wrapper around LWPR library',
       ext_modules = [module])
コード例 #8
0
from distutils.core import setup, Extension
from distutils.sysconfig import get_python_lib, parse_config_h
import os

requirements = ['numpy']

lwprsources = [
    'lwprmodule.c', 'src/lwpr.c', 'src/lwpr_xml.c', 'src/lwpr_math.c',
    'src/lwpr_binio.c', 'src/lwpr_mem.c', 'src/lwpr_aux.c'
]

configs = parse_config_h(open('include/lwpr_config.h'))

if 'HAVE_LIBEXPAT' in configs and configs['HAVE_LIBEXPAT']:
    module = Extension('lwpr',
                       include_dirs=[
                           'include',
                           os.path.join(get_python_lib(), 'numpy', 'core',
                                        'include')
                       ],
                       libraries=['expat'],
                       sources=lwprsources)
else:
    module = Extension('lwpr',
                       include_dirs=[
                           'include',
                           os.path.join(get_python_lib(), 'numpy', 'core',
                                        'include')
                       ],
                       sources=lwprsources)
コード例 #9
0
from distutils.core import setup, Extension
from distutils.sysconfig import get_python_lib, parse_config_h
import os

lwprsources = ['lwprmodule.c', 
               '../src/lwpr.c', 
               '../src/lwpr_xml.c', 
               '../src/lwpr_math.c', 
               '../src/lwpr_binio.c', 
               '../src/lwpr_mem.c', 
               '../src/lwpr_aux.c']

configs = parse_config_h(file('../include/lwpr_config.h'))

if configs.has_key('HAVE_LIBEXPAT') and configs['HAVE_LIBEXPAT']:
   module = Extension('lwpr', 
      include_dirs = ['../include', os.path.join(get_python_lib(),'numpy','core','include')],
      libraries = ['expat'],   
      sources = lwprsources)
else:
   module = Extension('lwpr',
      include_dirs = ['../include', os.path.join(get_python_lib(),'numpy','core','include')],
      sources = lwprsources)

setup (name = 'LWPR Module',
       version = '1.1',
       description = 'Python wrapper around LWPR library',
       ext_modules = [module])