本文整理汇总了Python中sysconfig.get_config_h_filename函数的典型用法代码示例。如果您正苦于以下问题:Python get_config_h_filename函数的具体用法?Python get_config_h_filename怎么用?Python get_config_h_filename使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_config_h_filename函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: copy_python_framework
def copy_python_framework(info, dst):
# XXX - In this particular case we know exactly what we can
# get away with.. should this be extended to the general
# case? Per-framework recipes?
indir = os.path.dirname(os.path.join(info["location"], info["name"]))
outdir = os.path.dirname(os.path.join(dst, info["name"]))
mkpath(os.path.join(outdir, "Resources"))
# Since python 3.2, the naming scheme for config files location has considerably
# complexified. The old, simple way doesn't work anymore. Fortunately, a new module was
# added to get such paths easily.
# It's possible that virtualenv is messing with us here, so we only use the rightmost part of
# each of the two paths below. For pyconfig_path, it's the last 3 elements of the path
# (include/python3.2m/pyconfig.h) and for makefile_path it's the last 4
# (lib/python3.2/config-3.2m/Makefile). Yes, this kind of location can change depending on the
# platform, but we're only supporting Mac OS X eh? We'll take these last path parts and append
# them to indir and we'll have our non-virtualenv paths.
pyconfig_path = sysconfig.get_config_h_filename()
makefile_path = sysconfig.get_makefile_filename()
pyconfig_path = op.join(*pyconfig_path.split(os.sep)[-3:])
makefile_path = op.join(*makefile_path.split(os.sep)[-4:])
assert pyconfig_path.startswith("include")
assert makefile_path.startswith("lib")
# distutils looks for some files relative to sys.executable, which
# means they have to be in the framework...
mkpath(op.join(outdir, op.dirname(pyconfig_path)))
mkpath(op.join(outdir, op.dirname(makefile_path)))
fmwkfiles = [os.path.basename(info["name"]), "Resources/Info.plist", pyconfig_path, makefile_path]
for fn in fmwkfiles:
copy_file(os.path.join(indir, fn), os.path.join(outdir, fn))
示例2: build_executable
def build_executable(self, target, copyexts, script):
# Build an executable for the target
appdir, resdir, plist = self.create_bundle(target, script)
self.appdir = appdir
self.opts.plist = plist
for src, dest in self.iter_data_files():
dest = os.path.join(resdir, dest)
mkpath(os.path.dirname(dest))
copy_resource(src, dest, dry_run=self.opts.dry_run)
bootfn = "__boot__"
bootfile = open(os.path.join(resdir, bootfn + ".py"), "w")
for fn in target.prescripts:
bootfile.write(get_bootstrap_data(fn))
bootfile.write("\n\n")
bootfile.write("_run(%r)\n" % (os.path.basename(script),))
bootfile.close()
copy_file(script, resdir)
pydir = os.path.join(resdir, "lib", "python" + sys.version[:3])
mkpath(pydir)
force_symlink("../../site.py", os.path.join(pydir, "site.py"))
realcfg = os.path.dirname(sysconfig.get_makefile_filename())
cfgdir = os.path.join(resdir, os.path.relpath(realcfg, sys.prefix))
mkpath(cfgdir)
for fn in "Makefile", "Setup", "Setup.local", "Setup.config":
rfn = os.path.join(realcfg, fn)
if os.path.exists(rfn):
copy_file(rfn, os.path.join(cfgdir, fn))
# see copy_python_framework() for explanation.
pyconfig_path = sysconfig.get_config_h_filename()
pyconfig_path_relative = os.path.relpath(os.path.dirname(pyconfig_path), sys.prefix)
inc_dir = os.path.join(resdir, pyconfig_path_relative)
mkpath(inc_dir)
copy_file(pyconfig_path, os.path.join(inc_dir, "pyconfig.h"))
copy_tree(self.folders.collect_dir, pydir)
ext_dir = os.path.join(pydir, os.path.basename(self.folders.ext_dir))
copy_tree(self.folders.ext_dir, ext_dir, preserve_symlinks=True)
copy_tree(self.folders.framework_dir, os.path.join(appdir, "Contents", "Frameworks"), preserve_symlinks=True)
for pkg in self.opts.packages:
pkg = get_bootstrap(pkg)
dst = os.path.join(pydir, os.path.basename(pkg))
mkpath(dst)
copy_tree(pkg, dst)
self.copyexts(copyexts, ext_dir)
target.appdir = appdir
return appdir
示例3: copy_sysconfig_files_for_embed
def copy_sysconfig_files_for_embed(destpath):
# This normally shouldn't be needed for Python 3.3+.
makefile = sysconfig.get_makefile_filename()
configh = sysconfig.get_config_h_filename()
shutil.copy(makefile, destpath)
shutil.copy(configh, destpath)
with open(op.join(destpath, 'site.py'), 'w') as fp:
fp.write("""
import os.path as op
from distutils import sysconfig
sysconfig.get_makefile_filename = lambda: op.join(op.dirname(__file__), 'Makefile')
sysconfig.get_config_h_filename = lambda: op.join(op.dirname(__file__), 'pyconfig.h')
""")
示例4: check_config_h
def check_config_h():
"""Check if the current Python installation appears amenable to building
extensions with GCC.
Returns a tuple (status, details), where 'status' is one of the following
constants:
- CONFIG_H_OK: all is well, go ahead and compile
- CONFIG_H_NOTOK: doesn't look good
- CONFIG_H_UNCERTAIN: not sure -- unable to read pyconfig.h
'details' is a human-readable string explaining the situation.
Note there are two ways to conclude "OK": either 'sys.version' contains
the string "GCC" (implying that this Python was built with GCC), or the
installed "pyconfig.h" contains the string "__GNUC__".
"""
# XXX since this function also checks sys.version, it's not strictly a
# "pyconfig.h" check -- should probably be renamed...
# if sys.version contains GCC then python was compiled with GCC, and the
# pyconfig.h file should be OK
if "GCC" in sys.version:
return CONFIG_H_OK, "sys.version mentions 'GCC'"
# let's see if __GNUC__ is mentioned in python.h
fn = sysconfig.get_config_h_filename()
try:
config_h = open(fn)
try:
if "__GNUC__" in config_h.read():
return CONFIG_H_OK, "'%s' mentions '__GNUC__'" % fn
else:
return CONFIG_H_NOTOK, "'%s' does not mention '__GNUC__'" % fn
finally:
config_h.close()
except IOError, exc:
return (CONFIG_H_UNCERTAIN,
"couldn't read '%s': %s" % (fn, exc.strerror))
示例5: main
def main():
target = os.path.dirname(sysconfig.get_config_h_filename())
try:
source = os.readlink(target)
except:
print(target, "is not a symlink. Perhaps this script has already been run.")
sys.exit(1)
tmp = target + ".tmp"
if os.path.exists(tmp):
shutil.rmtree(tmp)
os.mkdir(tmp)
for i in os.listdir(source):
if i == "pygame_sdl2":
continue
os.symlink(os.path.join(source, i), os.path.join(tmp, i))
os.unlink(target)
os.rename(tmp, target)
示例6: test_get_config_h_filename
def test_get_config_h_filename(self):
config_h = sysconfig.get_config_h_filename()
# import_module skips the test when the CPython C Extension API
# appears to not be supported
self.assertTrue(os.path.isfile(config_h) or
not import_module('_testcapi'), config_h)
示例7: test_get_config_h_filename
def test_get_config_h_filename(self):
config_h = sysconfig.get_config_h_filename()
self.assertTrue(os.path.isfile(config_h), config_h)
示例8: hasattr
#-----------------------------------------------------------------------------
"""
`distutils`-specific post-import hook.
This hook freezes the external `Makefile` and `pyconfig.h` files bundled with
the active Python interpreter, which the `distutils.sysconfig` module parses at
runtime for platform-specific metadata.
"""
# TODO Verify that bundling Makefile and pyconfig.h is still required for Python 3.
import os
import sysconfig
from PyInstaller.utils.hooks import relpath_to_config_or_make
_CONFIG_H = sysconfig.get_config_h_filename()
if hasattr(sysconfig, 'get_makefile_filename'):
# sysconfig.get_makefile_filename is missing in Python < 2.7.9
_MAKEFILE = sysconfig.get_makefile_filename()
else:
_MAKEFILE = sysconfig._get_makefile_filename()
# Data files in PyInstaller hook format.
datas = [(_CONFIG_H, relpath_to_config_or_make(_CONFIG_H))]
# The Makefile does not exist on all platforms, eg. on Windows
if os.path.exists(_MAKEFILE):
datas.append((_MAKEFILE, relpath_to_config_or_make(_MAKEFILE)))
示例9: Copyright
# Copyright (c) 2013, PyInstaller Development Team.
#
# Distributed under the terms of the GNU General Public License with exception
# for distributing bootloader.
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
# Test standard module sysconfig (new in Python 2.7 and Python 3.2)
import os
import sys
import sysconfig
config_h = sysconfig.get_config_h_filename()
print('pyconfig.h: ' + config_h)
files = [config_h]
# On Windows Makefile does not exist.
if not sys.platform.startswith('win'):
try:
get_makefile_filename = sysconfig.get_makefile_filename
except AttributeError:
# In Python 2.7, get_makefile_filename was private
get_makefile_filename = sysconfig._get_makefile_filename
makefile = get_makefile_filename()
print('Makefile: ' + makefile)
files.append(makefile)
示例10:
# coding=utf-8
# 使用sysconfig
import sysconfig
print sysconfig.get_config_var('Py_ENABLE_SHARED')
print sysconfig.get_config_var('LIBDIR')
print sysconfig.get_config_vars('AR', "CXX")
print sysconfig.get_scheme_names()
print sysconfig.get_path_names()
print sysconfig.get_python_version()
print sysconfig.get_platform()
# return true if current python installation was built from source
print sysconfig.is_python_build()
print sysconfig.get_config_h_filename()
print sysconfig._get_makefile_filename()
示例11: _get_settings
def _get_settings():
version = get_version()
settings = { 'define_macros' : [ ('PGLIB_VERSION', version) ] }
# This isn't the best or right way to do this, but I don't see how someone is supposed to sanely subclass the build
# command.
for option in ['assert', 'trace', 'leak-check']:
try:
sys.argv.remove('--%s' % option)
settings['define_macros'].append(('PGLIB_%s' % option.replace('-', '_').upper(), 1))
except ValueError:
pass
if os.name == 'nt':
settings['extra_compile_args'] = ['/Wall',
'/wd4668',
'/wd4820',
'/wd4711', # function selected for automatic inline expansion
'/wd4100', # unreferenced formal parameter
'/wd4127', # "conditional expression is constant" testing compilation constants
'/wd4191', # casts to PYCFunction which doesn't have the keywords parameter
]
if '--debug' in sys.argv:
# TODO: The build command already has debug. Pass it in.
sys.argv.remove('--debug')
settings['extra_compile_args'].extend('/Od /Ge /GS /GZ /RTC1 /Wp64 /Yd'.split())
settings['libraries'] = ['libpq', 'Ws2_32']
elif sys.platform == 'darwin':
# Apple is not making it easy for non-Xcode builds. We'll always build with the latest
# SDK we can find but we'll set the version we are targeting to the same one that
# Python was built with.
sdkpath = _get_osx_sdkpath()
settings['include_dirs'] = [
join(sdkpath, 'usr', 'include'),
abspath(dirname(sysconfig.get_config_h_filename().strip())),
subprocess.check_output(['pg_config', '--includedir']).strip().decode('utf-8')
]
settings['library_dirs'] = [ subprocess.check_output(['pg_config', '--libdir']).strip().decode('utf-8') ]
settings['libraries'] = ['pq']
settings['define_macros'].append( ('MAC_OS_X_VERSION_10_7',) )
settings['extra_compile_args'] = ['-Wall']
else:
# Other posix-like: Linux, Solaris, etc.
settings['include_dirs'] = [ subprocess.check_output(['pg_config', '--includedir']).strip().decode('utf-8') ]
settings['library_dirs'] = [ subprocess.check_output(['pg_config', '--libdir']).strip().decode('utf-8') ]
settings['libraries'] = ['pq']
# Python functions take a lot of 'char *' that really should be const. gcc complains about this *a lot*
settings['extra_compile_args'] = ['-Wno-write-strings']
return settings
示例12: get_python_header_folder
def get_python_header_folder():
return op.dirname(sysconfig.get_config_h_filename())
示例13: coordinates
#Custom Properties:
#scene.hzg_file_name - name of zip file to write
#object.hzg_type - type of object to be populated by the reading program
# - Defaults to "ENTITY"
# - GEO_MIPMAP - Used for terrain geometry
# - UI_ELEMENT - Drawn in the same position in front of the camera as UI elements
# - INPUT_AREA - Polygons drawn over UI area to detect input
#object.hzg_export_mode - how to export the data for this object
# - V - Write tightly packed vertex position data, no normals or texture coordinates (VVV)
# - VC - Write Vertex position and Texture Coordinates in VVVCC format.
# - VNC - Write packed Vertex/Normal/TexCoord data in VVVNNNCC format
#object.hzg_round - integer, how many places to round decimals
#object.hzg_texture - texture name to use
import sysconfig
print(sysconfig.get_config_h_filename())
import bpy
import bmesh
import zipfile
import struct
import sys
import os
import mathutils
from scipy.spatial import ConvexHull
try:
import zlib
compression = zipfile.ZIP_DEFLATED
except:
compression = zipfile.ZIP_STORED