Commit e38c045c by David Hotham Committed by Bjorn Neergaard

partially restore temporary_directory()

Use the version from poetry.core always, one implementation is enough
parent f897294a
...@@ -8,7 +8,6 @@ import tarfile ...@@ -8,7 +8,6 @@ import tarfile
import zipfile import zipfile
from pathlib import Path from pathlib import Path
from tempfile import TemporaryDirectory
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from typing import Any from typing import Any
from typing import Callable from typing import Callable
...@@ -23,6 +22,7 @@ from poetry.core.packages.dependency import Dependency ...@@ -23,6 +22,7 @@ from poetry.core.packages.dependency import Dependency
from poetry.core.packages.package import Package from poetry.core.packages.package import Package
from poetry.core.pyproject.toml import PyProjectTOML from poetry.core.pyproject.toml import PyProjectTOML
from poetry.core.utils.helpers import parse_requires from poetry.core.utils.helpers import parse_requires
from poetry.core.utils.helpers import temporary_directory
from poetry.core.version.markers import InvalidMarker from poetry.core.version.markers import InvalidMarker
from poetry.utils.env import EnvCommandError from poetry.utils.env import EnvCommandError
...@@ -293,7 +293,7 @@ class PackageInfo: ...@@ -293,7 +293,7 @@ class PackageInfo:
context = tarfile.open context = tarfile.open
with TemporaryDirectory() as tmp_str: with temporary_directory() as tmp_str:
tmp = Path(tmp_str) tmp = Path(tmp_str)
with context(path.as_posix()) as archive: with context(path.as_posix()) as archive:
archive.extractall(tmp.as_posix()) archive.extractall(tmp.as_posix())
......
...@@ -8,7 +8,6 @@ import urllib.parse ...@@ -8,7 +8,6 @@ import urllib.parse
from abc import ABC from abc import ABC
from collections import defaultdict from collections import defaultdict
from pathlib import Path from pathlib import Path
from tempfile import TemporaryDirectory
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from typing import Any from typing import Any
...@@ -17,6 +16,7 @@ import requests ...@@ -17,6 +16,7 @@ import requests
from poetry.core.packages.dependency import Dependency from poetry.core.packages.dependency import Dependency
from poetry.core.packages.utils.link import Link from poetry.core.packages.utils.link import Link
from poetry.core.semver.helpers import parse_constraint from poetry.core.semver.helpers import parse_constraint
from poetry.core.utils.helpers import temporary_directory
from poetry.core.version.markers import parse_marker from poetry.core.version.markers import parse_marker
from poetry.repositories.cached import CachedRepository from poetry.repositories.cached import CachedRepository
...@@ -87,7 +87,7 @@ class HTTPRepository(CachedRepository, ABC): ...@@ -87,7 +87,7 @@ class HTTPRepository(CachedRepository, ABC):
filename = os.path.basename(wheel_name) filename = os.path.basename(wheel_name)
with TemporaryDirectory() as temp_dir: with temporary_directory() as temp_dir:
filepath = Path(temp_dir) / filename filepath = Path(temp_dir) / filename
self._download(url, str(filepath)) self._download(url, str(filepath))
...@@ -103,7 +103,7 @@ class HTTPRepository(CachedRepository, ABC): ...@@ -103,7 +103,7 @@ class HTTPRepository(CachedRepository, ABC):
filename = os.path.basename(sdist_name) filename = os.path.basename(sdist_name)
with TemporaryDirectory() as temp_dir: with temporary_directory() as temp_dir:
filepath = Path(temp_dir) / filename filepath = Path(temp_dir) / filename
self._download(url, str(filepath)) self._download(url, str(filepath))
...@@ -232,7 +232,7 @@ class HTTPRepository(CachedRepository, ABC): ...@@ -232,7 +232,7 @@ class HTTPRepository(CachedRepository, ABC):
and link.hash_name not in ("sha256", "sha384", "sha512") and link.hash_name not in ("sha256", "sha384", "sha512")
and hasattr(hashlib, link.hash_name) and hasattr(hashlib, link.hash_name)
): ):
with TemporaryDirectory() as temp_dir: with temporary_directory() as temp_dir:
filepath = Path(temp_dir) / link.filename filepath = Path(temp_dir) / link.filename
self._download(link.url, str(filepath)) self._download(link.url, str(filepath))
......
...@@ -16,7 +16,6 @@ from contextlib import contextmanager ...@@ -16,7 +16,6 @@ from contextlib import contextmanager
from copy import deepcopy from copy import deepcopy
from pathlib import Path from pathlib import Path
from subprocess import CalledProcessError from subprocess import CalledProcessError
from tempfile import TemporaryDirectory
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from typing import Any from typing import Any
from typing import Iterable from typing import Iterable
...@@ -36,6 +35,7 @@ from poetry.core.poetry import Poetry ...@@ -36,6 +35,7 @@ from poetry.core.poetry import Poetry
from poetry.core.semver.helpers import parse_constraint from poetry.core.semver.helpers import parse_constraint
from poetry.core.semver.version import Version from poetry.core.semver.version import Version
from poetry.core.toml.file import TOMLFile from poetry.core.toml.file import TOMLFile
from poetry.core.utils.helpers import temporary_directory
from virtualenv.seed.wheels.embed import get_embed_wheel from virtualenv.seed.wheels.embed import get_embed_wheel
from poetry.locations import CACHE_DIR from poetry.locations import CACHE_DIR
...@@ -1833,7 +1833,7 @@ def ephemeral_environment( ...@@ -1833,7 +1833,7 @@ def ephemeral_environment(
executable: str | Path | None = None, executable: str | Path | None = None,
flags: dict[str, bool] = None, flags: dict[str, bool] = None,
) -> Iterator[VirtualEnv]: ) -> Iterator[VirtualEnv]:
with TemporaryDirectory() as tmp_dir: with temporary_directory() as tmp_dir:
# TODO: cache PEP 517 build environment corresponding to each project venv # TODO: cache PEP 517 build environment corresponding to each project venv
venv_dir = Path(tmp_dir) / ".venv" venv_dir = Path(tmp_dir) / ".venv"
EnvManager.build_venv( EnvManager.build_venv(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment