本文整理汇总了Python中distutils.command.build_py.build_py.get_package_dir方法的典型用法代码示例。如果您正苦于以下问题:Python build_py.get_package_dir方法的具体用法?Python build_py.get_package_dir怎么用?Python build_py.get_package_dir使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类distutils.command.build_py.build_py
的用法示例。
在下文中一共展示了build_py.get_package_dir方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_data_files
# 需要导入模块: from distutils.command.build_py import build_py [as 别名]
# 或者: from distutils.command.build_py.build_py import get_package_dir [as 别名]
def _get_data_files(self):
"""Generate list of '(package,src_dir,build_dir,filenames)' tuples"""
self.analyze_manifest()
data = []
for package in self.packages or ():
# Locate package source directory
src_dir = self.get_package_dir(package)
# Compute package build directory
build_dir = os.path.join(*([self.build_lib] + package.split('.')))
# Length of path to strip from found files
plen = len(src_dir)+1
# Strip directory from globbed filenames
filenames = [
file[plen:] for file in self.find_data_files(package, src_dir)
]
data.append((package, src_dir, build_dir, filenames))
return data
示例2: analyze_manifest
# 需要导入模块: from distutils.command.build_py import build_py [as 别名]
# 或者: from distutils.command.build_py.build_py import get_package_dir [as 别名]
def analyze_manifest(self):
self.manifest_files = mf = {}
if not self.distribution.include_package_data:
return
src_dirs = {}
for package in self.packages or ():
# Locate package source directory
src_dirs[assert_relative(self.get_package_dir(package))] = package
self.run_command('egg_info')
ei_cmd = self.get_finalized_command('egg_info')
for path in ei_cmd.filelist.files:
d,f = os.path.split(assert_relative(path))
prev = None
oldf = f
while d and d!=prev and d not in src_dirs:
prev = d
d, df = os.path.split(d)
f = os.path.join(df, f)
if d in src_dirs:
if path.endswith('.py') and f==oldf:
continue # it's a module, not data
mf.setdefault(src_dirs[d],[]).append(path)
示例3: _add_py_module
# 需要导入模块: from distutils.command.build_py import build_py [as 别名]
# 或者: from distutils.command.build_py.build_py import get_package_dir [as 别名]
def _add_py_module(dist, ffi, module_name):
from distutils.dir_util import mkpath
from distutils.command.build_py import build_py
from distutils.command.build_ext import build_ext
from distutils import log
from cffi import recompiler
def generate_mod(py_file):
log.info("generating cffi module %r" % py_file)
mkpath(os.path.dirname(py_file))
updated = recompiler.make_py_source(ffi, module_name, py_file)
if not updated:
log.info("already up-to-date")
base_class = dist.cmdclass.get('build_py', build_py)
class build_py_make_mod(base_class):
def run(self):
base_class.run(self)
module_path = module_name.split('.')
module_path[-1] += '.py'
generate_mod(os.path.join(self.build_lib, *module_path))
dist.cmdclass['build_py'] = build_py_make_mod
# the following is only for "build_ext -i"
base_class_2 = dist.cmdclass.get('build_ext', build_ext)
class build_ext_make_mod(base_class_2):
def run(self):
base_class_2.run(self)
if self.inplace:
# from get_ext_fullpath() in distutils/command/build_ext.py
module_path = module_name.split('.')
package = '.'.join(module_path[:-1])
build_py = self.get_finalized_command('build_py')
package_dir = build_py.get_package_dir(package)
file_name = module_path[-1] + '.py'
generate_mod(os.path.join(package_dir, file_name))
dist.cmdclass['build_ext'] = build_ext_make_mod
示例4: get_package_dir
# 需要导入模块: from distutils.command.build_py import build_py [as 别名]
# 或者: from distutils.command.build_py.build_py import get_package_dir [as 别名]
def get_package_dir(self, package):
res = _build_py.get_package_dir(self, package)
if self.distribution.src_root is not None:
return os.path.join(self.distribution.src_root, res)
return res
示例5: _patch_build_commands
# 需要导入模块: from distutils.command.build_py import build_py [as 别名]
# 或者: from distutils.command.build_py.build_py import get_package_dir [as 别名]
def _patch_build_commands(self):
base_build_ext = self.dist.cmdclass.get('build_ext', build_ext)
base_build_py = self.dist.cmdclass.get('build_py', build_py)
spec = self
class MilksnakeBuildPy(base_build_py):
def run(self):
base_build_py.run(self)
for func, module_base in spec._dist_build_funcs:
base_path = None
if module_base is not None:
base_path = os.path.join(
self.build_lib, *module_base.split('.'))
func(base_path=base_path, inplace=False)
class MilksnakeBuildExt(base_build_ext):
def get_ext_fullpath(self, ext_name):
milksnake_dummy_ext = None
for ext in spec.dist.ext_modules:
if ext.name == ext_name:
milksnake_dummy_ext = getattr(
ext, 'milksnake_dummy_ext', None)
break
if milksnake_dummy_ext is None:
return base_build_ext.get_ext_fullpath(self, ext_name)
fullname = self.get_ext_fullname(ext_name)
modpath = fullname.split('.')
package = '.'.join(modpath[0:-1])
build_py = self.get_finalized_command('build_py')
package_dir = os.path.abspath(build_py.get_package_dir(package))
return os.path.join(package_dir, milksnake_dummy_ext)
def run(self):
base_build_ext.run(self)
if self.inplace:
build_py = self.get_finalized_command('build_py')
for func, module_base in spec._dist_build_funcs:
base_path = None
if module_base is not None:
base_path = build_py.get_package_dir(
module_base)
func(base_path=base_path, inplace=True)
self.dist.cmdclass['build_py'] = MilksnakeBuildPy
self.dist.cmdclass['build_ext'] = MilksnakeBuildExt