Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
python-poetry
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
python-poetry
Commits
ac3d3827
Commit
ac3d3827
authored
Apr 30, 2022
by
David Hotham
Committed by
Bjorn Neergaard
May 17, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
retire temporary_directory()
parent
a00eb5c3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
19 deletions
+8
-19
src/poetry/inspection/info.py
+2
-2
src/poetry/repositories/http.py
+4
-4
src/poetry/utils/env.py
+2
-2
src/poetry/utils/helpers.py
+0
-11
No files found.
src/poetry/inspection/info.py
View file @
ac3d3827
...
@@ -8,6 +8,7 @@ import tarfile
...
@@ -8,6 +8,7 @@ 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
Iterator
from
typing
import
Iterator
...
@@ -18,7 +19,6 @@ from poetry.core.packages.dependency import Dependency
...
@@ -18,7 +19,6 @@ 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
...
@@ -286,7 +286,7 @@ class PackageInfo:
...
@@ -286,7 +286,7 @@ class PackageInfo:
context
=
tarfile
.
open
context
=
tarfile
.
open
with
temporary_d
irectory
()
as
tmp
:
with
TemporaryD
irectory
()
as
tmp
:
tmp
=
Path
(
tmp
)
tmp
=
Path
(
tmp
)
with
context
(
path
.
as_posix
())
as
archive
:
with
context
(
path
.
as_posix
())
as
archive
:
archive
.
extractall
(
tmp
.
as_posix
())
archive
.
extractall
(
tmp
.
as_posix
())
...
...
src/poetry/repositories/http.py
View file @
ac3d3827
...
@@ -8,6 +8,7 @@ import urllib.parse
...
@@ -8,6 +8,7 @@ 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
...
@@ -24,7 +25,6 @@ from poetry.repositories.exceptions import RepositoryError
...
@@ -24,7 +25,6 @@ from poetry.repositories.exceptions import RepositoryError
from
poetry.repositories.link_sources.html
import
HTMLPage
from
poetry.repositories.link_sources.html
import
HTMLPage
from
poetry.utils.authenticator
import
Authenticator
from
poetry.utils.authenticator
import
Authenticator
from
poetry.utils.helpers
import
download_file
from
poetry.utils.helpers
import
download_file
from
poetry.utils.helpers
import
temporary_directory
from
poetry.utils.patterns
import
wheel_file_re
from
poetry.utils.patterns
import
wheel_file_re
...
@@ -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
temporary_d
irectory
()
as
temp_dir
:
with
TemporaryD
irectory
()
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
temporary_d
irectory
()
as
temp_dir
:
with
TemporaryD
irectory
()
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
temporary_d
irectory
()
as
temp_dir
:
with
TemporaryD
irectory
()
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
))
...
...
src/poetry/utils/env.py
View file @
ac3d3827
...
@@ -15,6 +15,7 @@ from contextlib import contextmanager
...
@@ -15,6 +15,7 @@ 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
ContextManager
from
typing
import
ContextManager
...
@@ -45,7 +46,6 @@ from poetry.utils._compat import metadata
...
@@ -45,7 +46,6 @@ from poetry.utils._compat import metadata
from
poetry.utils.helpers
import
is_dir_writable
from
poetry.utils.helpers
import
is_dir_writable
from
poetry.utils.helpers
import
paths_csv
from
poetry.utils.helpers
import
paths_csv
from
poetry.utils.helpers
import
remove_directory
from
poetry.utils.helpers
import
remove_directory
from
poetry.utils.helpers
import
temporary_directory
if
TYPE_CHECKING
:
if
TYPE_CHECKING
:
...
@@ -1831,7 +1831,7 @@ def ephemeral_environment(
...
@@ -1831,7 +1831,7 @@ def ephemeral_environment(
executable
:
str
|
Path
|
None
=
None
,
executable
:
str
|
Path
|
None
=
None
,
flags
:
dict
[
str
,
bool
]
=
None
,
flags
:
dict
[
str
,
bool
]
=
None
,
)
->
ContextManager
[
VirtualEnv
]:
)
->
ContextManager
[
VirtualEnv
]:
with
temporary_d
irectory
()
as
tmp_dir
:
with
TemporaryD
irectory
()
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
(
...
...
src/poetry/utils/helpers.py
View file @
ac3d3827
...
@@ -7,12 +7,10 @@ import stat
...
@@ -7,12 +7,10 @@ import stat
import
tempfile
import
tempfile
from
collections.abc
import
Mapping
from
collections.abc
import
Mapping
from
contextlib
import
contextmanager
from
pathlib
import
Path
from
pathlib
import
Path
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
from
typing
import
Iterator
if
TYPE_CHECKING
:
if
TYPE_CHECKING
:
...
@@ -34,15 +32,6 @@ def module_name(name: str) -> str:
...
@@ -34,15 +32,6 @@ def module_name(name: str) -> str:
return
canonicalize_name
(
name
)
.
replace
(
"."
,
"_"
)
.
replace
(
"-"
,
"_"
)
return
canonicalize_name
(
name
)
.
replace
(
"."
,
"_"
)
.
replace
(
"-"
,
"_"
)
@contextmanager
def
temporary_directory
(
*
args
:
Any
,
**
kwargs
:
Any
)
->
Iterator
[
str
]:
name
=
tempfile
.
mkdtemp
(
*
args
,
**
kwargs
)
yield
name
remove_directory
(
name
,
force
=
True
)
def
get_cert
(
config
:
Config
,
repository_name
:
str
)
->
Path
|
None
:
def
get_cert
(
config
:
Config
,
repository_name
:
str
)
->
Path
|
None
:
cert
=
config
.
get
(
f
"certificates.{repository_name}.cert"
)
cert
=
config
.
get
(
f
"certificates.{repository_name}.cert"
)
if
cert
:
if
cert
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment