本文整理汇总了Python中distutils.errors.DistutilsInternalError方法的典型用法代码示例。如果您正苦于以下问题:Python errors.DistutilsInternalError方法的具体用法?Python errors.DistutilsInternalError怎么用?Python errors.DistutilsInternalError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类distutils.errors
的用法示例。
在下文中一共展示了errors.DistutilsInternalError方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_cmd
# 需要导入模块: from distutils import errors [as 别名]
# 或者: from distutils.errors import DistutilsInternalError [as 别名]
def get_cmd(cmdname, _cache={}):
if cmdname not in _cache:
import distutils.core
dist = distutils.core._setup_distribution
if dist is None:
from distutils.errors import DistutilsInternalError
raise DistutilsInternalError(
'setup distribution instance not initialized')
cmd = dist.get_command_obj(cmdname)
_cache[cmdname] = cmd
return _cache[cmdname]
示例2: _install_dist_package
# 需要导入模块: from distutils import errors [as 别名]
# 或者: from distutils.errors import DistutilsInternalError [as 别名]
def _install_dist_package(self):
# Get the name of the package that we just built
package_name = self.distribution.get_name()
# Get the dist directory that bdist_wheel put the package in
# Create the lambda build dir
self._lambda_build_dir = os.path.join('build', 'ldist-'+package_name)
build_dir = self._lambda_build_dir
if getattr(self, 'build_layer'):
build_dir = os.path.join(build_dir, getattr(self, 'layer_dir'))
try:
if os.path.exists(self._lambda_build_dir):
shutil.rmtree(self._lambda_build_dir)
log.info('creating {}'.format(self._lambda_build_dir))
os.makedirs(build_dir)
except OSError as exc:
if exc.errno == errno.EEXIST and os.path.isdir(self._lambda_build_dir):
pass
else:
raise DistutilsInternalError('{} already exists and is not a directory'.format(self._lambda_build_dir))
log.info('installing package {} from {} into {}'.format(package_name,
self._dist_dir,
build_dir))
pip = Popen(['pip', 'install',
'-f', self._dist_dir,
'-t', build_dir, package_name],
stdout=PIPE, stderr=PIPE)
stdout, stderr = pip.communicate()
if pip.returncode is not 0:
log.info("pip stdout: {}".format(stdout))
log.error("pip stderr: {}".format(stderr))
raise DistutilsPlatformError('pip returned unsuccessfully')
else:
log.debug("pip stdout: {}".format(stdout))
log.debug("pip stderr: {}".format(stderr))