本文整理汇总了Python中sysconfig.get_makefile_filename函数的典型用法代码示例。如果您正苦于以下问题:Python get_makefile_filename函数的具体用法?Python get_makefile_filename怎么用?Python get_makefile_filename使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_makefile_filename函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: test_srcdir
def test_srcdir(self):
# See Issues #15322, #15364.
srcdir = sysconfig.get_config_var('srcdir')
self.assertTrue(os.path.isabs(srcdir), srcdir)
self.assertTrue(os.path.isdir(srcdir), srcdir)
if sysconfig._PYTHON_BUILD:
# The python executable has not been installed so srcdir
# should be a full source checkout.
Python_h = os.path.join(srcdir, 'Include', 'Python.h')
self.assertTrue(os.path.exists(Python_h), Python_h)
self.assertTrue(sysconfig._is_python_source_dir(srcdir))
elif os.name == 'posix':
self.assertEqual(os.path.dirname(sysconfig.get_makefile_filename()),
srcdir)
示例5: test_srcdir
def test_srcdir(self):
# See Issues #15322, #15364.
srcdir = sysconfig.get_config_var("srcdir")
self.assertTrue(os.path.isabs(srcdir), srcdir)
self.assertTrue(os.path.isdir(srcdir), srcdir)
if sysconfig._PYTHON_BUILD:
# The python executable has not been installed so srcdir
# should be a full source checkout.
Python_h = os.path.join(srcdir, "Include", "Python.h")
self.assertTrue(os.path.exists(Python_h), Python_h)
self.assertTrue(sysconfig._is_python_source_dir(srcdir))
elif os.name == "posix":
makefile_dir = os.path.dirname(sysconfig.get_makefile_filename())
# Issue #19340: srcdir has been realpath'ed already
makefile_dir = os.path.realpath(makefile_dir)
self.assertEqual(makefile_dir, srcdir)
示例6: 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)))
示例7: test_get_makefile_filename
def test_get_makefile_filename(self):
makefile = sysconfig.get_makefile_filename()
self.assertTrue(os.path.isfile(makefile), makefile)
示例8: print
# for distributing bootloader.
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
# distutils module requires Makefile and pyconfig.h files from Python
# installation.
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'):
makefile = sysconfig.get_makefile_filename()
print(('Makefile: ' + makefile))
files.append(makefile)
for f in files:
if not os.path.exists(f):
raise SystemExit('File does not exist: %s' % f)
示例9: test_get_makefile_filename
def test_get_makefile_filename(self):
makefile = sysconfig.get_makefile_filename()
self.assertTrue(os.path.isfile(makefile), makefile)
# Issue 22199
self.assertEqual(sysconfig._get_makefile_filename(), makefile)