本文整理匯總了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))