本文整理汇总了Python中pip._internal.utils.temp_dir.TempDirectory方法的典型用法代码示例。如果您正苦于以下问题:Python temp_dir.TempDirectory方法的具体用法?Python temp_dir.TempDirectory怎么用?Python temp_dir.TempDirectory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pip._internal.utils.temp_dir
的用法示例。
在下文中一共展示了temp_dir.TempDirectory方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _build_one_inside_env
# 需要导入模块: from pip._internal.utils import temp_dir [as 别名]
# 或者: from pip._internal.utils.temp_dir import TempDirectory [as 别名]
def _build_one_inside_env(self, req, output_dir, python_tag=None):
with TempDirectory(kind="wheel") as temp_dir:
if self.__build_one(req, temp_dir.path, python_tag=python_tag):
try:
wheel_name = os.listdir(temp_dir.path)[0]
wheel_path = os.path.join(output_dir, wheel_name)
shutil.move(
os.path.join(temp_dir.path, wheel_name), wheel_path
)
logger.info('Stored in directory: %s', output_dir)
return wheel_path
except:
pass
# Ignore return, we can't do anything else useful.
self._clean_one(req)
return None
示例2: _build_one_inside_env
# 需要导入模块: from pip._internal.utils import temp_dir [as 别名]
# 或者: from pip._internal.utils.temp_dir import TempDirectory [as 别名]
def _build_one_inside_env(self, req, output_dir, python_tag=None):
with TempDirectory(kind="wheel") as temp_dir:
if req.use_pep517:
builder = self._build_one_pep517
else:
builder = self._build_one_legacy
wheel_path = builder(req, temp_dir.path, python_tag=python_tag)
if wheel_path is not None:
wheel_name = os.path.basename(wheel_path)
dest_path = os.path.join(output_dir, wheel_name)
try:
shutil.move(wheel_path, dest_path)
logger.info('Stored in directory: %s', output_dir)
return dest_path
except Exception:
pass
# Ignore return, we can't do anything else useful.
self._clean_one(req)
return None
示例3: _get_directory_stash
# 需要导入模块: from pip._internal.utils import temp_dir [as 别名]
# 或者: from pip._internal.utils.temp_dir import TempDirectory [as 别名]
def _get_directory_stash(self, path):
# type: (str) -> str
"""Stashes a directory.
Directories are stashed adjacent to their original location if
possible, or else moved/copied into the user's temp dir."""
try:
save_dir = AdjacentTempDirectory(path) # type: TempDirectory
save_dir.create()
except OSError:
save_dir = TempDirectory(kind="uninstall")
save_dir.create()
self._save_dirs[os.path.normcase(path)] = save_dir
return save_dir.path
示例4: install_wheel
# 需要导入模块: from pip._internal.utils import temp_dir [as 别名]
# 或者: from pip._internal.utils.temp_dir import TempDirectory [as 别名]
def install_wheel(
name, # type: str
wheel_path, # type: str
scheme, # type: Scheme
req_description, # type: str
pycompile=True, # type: bool
warn_script_location=True, # type: bool
_temp_dir_for_testing=None, # type: Optional[str]
):
# type: (...) -> None
with TempDirectory(
path=_temp_dir_for_testing, kind="unpacked-wheel"
) as unpacked_dir:
unpack_file(wheel_path, unpacked_dir.path)
install_unpacked_wheel(
name=name,
wheeldir=unpacked_dir.path,
scheme=scheme,
req_description=req_description,
pycompile=pycompile,
warn_script_location=warn_script_location,
)
示例5: generate_metadata
# 需要导入模块: from pip._internal.utils import temp_dir [as 别名]
# 或者: from pip._internal.utils.temp_dir import TempDirectory [as 别名]
def generate_metadata(build_env, backend):
# type: (BuildEnvironment, Pep517HookCaller) -> str
"""Generate metadata using mechanisms described in PEP 517.
Returns the generated metadata directory.
"""
metadata_tmpdir = TempDirectory(
kind="modern-metadata", globally_managed=True
)
metadata_dir = metadata_tmpdir.path
with build_env:
# Note that Pep517HookCaller implements a fallback for
# prepare_metadata_for_build_wheel, so we don't have to
# consider the possibility that this hook doesn't exist.
runner = runner_with_spinner_message("Preparing wheel metadata")
with backend.subprocess_runner(runner):
distinfo_dir = backend.prepare_metadata_for_build_wheel(
metadata_dir
)
return os.path.join(metadata_dir, distinfo_dir)
示例6: ensure_build_location
# 需要导入模块: from pip._internal.utils import temp_dir [as 别名]
# 或者: from pip._internal.utils.temp_dir import TempDirectory [as 别名]
def ensure_build_location(self, build_dir):
# type: (str) -> str
assert build_dir is not None
if self._temp_build_dir is not None:
assert self._temp_build_dir.path
return self._temp_build_dir.path
if self.req is None:
# Some systems have /tmp as a symlink which confuses custom
# builds (such as numpy). Thus, we ensure that the real path
# is returned.
self._temp_build_dir = TempDirectory(kind="req-build")
return self._temp_build_dir.path
if self.editable:
name = self.name.lower()
else:
name = self.name
# FIXME: Is there a better place to create the build_dir? (hg and bzr
# need this)
if not os.path.exists(build_dir):
logger.debug('Creating directory %s', build_dir)
_make_build_dir(build_dir)
return os.path.join(build_dir, name)
示例7: _build_one_inside_env
# 需要导入模块: from pip._internal.utils import temp_dir [as 别名]
# 或者: from pip._internal.utils.temp_dir import TempDirectory [as 别名]
def _build_one_inside_env(self, req, output_dir, python_tag=None):
with TempDirectory(kind="wheel") as temp_dir:
if self.__build_one(req, temp_dir.path, python_tag=python_tag):
try:
wheel_name = os.listdir(temp_dir.path)[0]
wheel_path = os.path.join(output_dir, wheel_name)
shutil.move(
os.path.join(temp_dir.path, wheel_name), wheel_path
)
logger.info('Stored in directory: %s', output_dir)
return wheel_path
except Exception:
pass
# Ignore return, we can't do anything else useful.
self._clean_one(req)
return None
示例8: unpack_http_url
# 需要导入模块: from pip._internal.utils import temp_dir [as 别名]
# 或者: from pip._internal.utils.temp_dir import TempDirectory [as 别名]
def unpack_http_url(link, location, download_dir=None,
session=None, hashes=None, progress_bar="on"):
if session is None:
raise TypeError(
"unpack_http_url() missing 1 required keyword argument: 'session'"
)
with TempDirectory(kind="unpack") as temp_dir:
# If a download dir is specified, is the file already downloaded there?
already_downloaded_path = None
if download_dir:
already_downloaded_path = _check_download_dir(link,
download_dir,
hashes)
if already_downloaded_path:
from_path = already_downloaded_path
content_type = mimetypes.guess_type(from_path)[0]
else:
# let's download to a tmp dir
from_path, content_type = _download_http_url(link,
session,
temp_dir.path,
hashes,
progress_bar)
# unpack the archive to the build dir location. even when only
# downloading archives, they have to be unpacked to parse dependencies
unpack_file(from_path, location, content_type, link)
# a download dir is specified; let's copy the archive there
if download_dir and not already_downloaded_path:
_copy_file(from_path, download_dir, link)
if not already_downloaded_path:
os.unlink(from_path)
示例9: __init__
# 需要导入模块: from pip._internal.utils import temp_dir [as 别名]
# 或者: from pip._internal.utils.temp_dir import TempDirectory [as 别名]
def __init__(self, dist):
self.paths = set()
self._refuse = set()
self.pth = {}
self.dist = dist
self.save_dir = TempDirectory(kind="uninstall")
self._moved_paths = []
示例10: export
# 需要导入模块: from pip._internal.utils import temp_dir [as 别名]
# 或者: from pip._internal.utils.temp_dir import TempDirectory [as 别名]
def export(self, location):
"""Export the Hg repository at the url to the destination location"""
with TempDirectory(kind="export") as temp_dir:
self.unpack(temp_dir.path)
self.run_command(
['archive', location], show_stdout=False, cwd=temp_dir.path
)
示例11: export
# 需要导入模块: from pip._internal.utils import temp_dir [as 别名]
# 或者: from pip._internal.utils.temp_dir import TempDirectory [as 别名]
def export(self, location):
"""
Export the Bazaar repository at the url to the destination location
"""
# Remove the location to make sure Bazaar can export it correctly
if os.path.exists(location):
rmtree(location)
with TempDirectory(kind="export") as temp_dir:
self.unpack(temp_dir.path)
self.run_command(
['export', location],
cwd=temp_dir.path, show_stdout=False,
)
示例12: __init__
# 需要导入模块: from pip._internal.utils import temp_dir [as 别名]
# 或者: from pip._internal.utils.temp_dir import TempDirectory [as 别名]
def __init__(self, no_clean):
self._temp_dir = TempDirectory(kind="build-env")
self._no_clean = no_clean
示例13: __init__
# 需要导入模块: from pip._internal.utils import temp_dir [as 别名]
# 或者: from pip._internal.utils.temp_dir import TempDirectory [as 别名]
def __init__(self, format_control):
self._temp_dir = TempDirectory(kind="ephem-wheel-cache")
self._temp_dir.create()
super(EphemWheelCache, self).__init__(
self._temp_dir.path, format_control
)
示例14: export
# 需要导入模块: from pip._internal.utils import temp_dir [as 别名]
# 或者: from pip._internal.utils.temp_dir import TempDirectory [as 别名]
def export(self, location):
"""Export the Git repository at the url to the destination location"""
if not location.endswith('/'):
location = location + '/'
with TempDirectory(kind="export") as temp_dir:
self.unpack(temp_dir.path)
self.run_command(
['checkout-index', '-a', '-f', '--prefix', location],
show_stdout=False, cwd=temp_dir.path
)