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
7e58d536
Commit
7e58d536
authored
Jun 17, 2022
by
Bjorn Neergaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "refactor: use contextlib.suppress instead of except pass (#5840)"
This reverts commit
6d4c9fe6
.
parent
fda67376
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
12 deletions
+19
-12
src/poetry/inspection/info.py
+3
-2
src/poetry/utils/env.py
+10
-6
tests/utils/fixtures/setups/ansible/setup.py
+3
-2
tests/utils/fixtures/setups/pyyaml/setup.py
+3
-2
No files found.
src/poetry/inspection/info.py
View file @
7e58d536
from
__future__
import
annotations
from
__future__
import
annotations
import
contextlib
import
functools
import
functools
import
glob
import
glob
import
logging
import
logging
...
@@ -557,10 +556,12 @@ def get_pep517_metadata(path: Path) -> PackageInfo:
...
@@ -557,10 +556,12 @@ def get_pep517_metadata(path: Path) -> PackageInfo:
:param path: Path to package source to build and read metadata for.
:param path: Path to package source to build and read metadata for.
"""
"""
info
=
None
info
=
None
with
contextlib
.
suppress
(
PackageInfoError
)
:
try
:
info
=
PackageInfo
.
from_setup_files
(
path
)
info
=
PackageInfo
.
from_setup_files
(
path
)
if
all
([
info
.
version
,
info
.
name
,
info
.
requires_dist
]):
if
all
([
info
.
version
,
info
.
name
,
info
.
requires_dist
]):
return
info
return
info
except
PackageInfoError
:
pass
with
ephemeral_environment
(
with
ephemeral_environment
(
flags
=
{
"no-pip"
:
False
,
"no-setuptools"
:
False
,
"no-wheel"
:
False
}
flags
=
{
"no-pip"
:
False
,
"no-setuptools"
:
False
,
"no-wheel"
:
False
}
...
...
src/poetry/utils/env.py
View file @
7e58d536
from
__future__
import
annotations
from
__future__
import
annotations
import
base64
import
base64
import
contextlib
import
hashlib
import
hashlib
import
itertools
import
itertools
import
json
import
json
...
@@ -14,6 +13,7 @@ import sys
...
@@ -14,6 +13,7 @@ import sys
import
sysconfig
import
sysconfig
import
warnings
import
warnings
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
...
@@ -279,9 +279,11 @@ class SitePackages:
...
@@ -279,9 +279,11 @@ class SitePackages:
candidates
=
self
.
_candidates
if
not
writable_only
else
self
.
writable_candidates
candidates
=
self
.
_candidates
if
not
writable_only
else
self
.
writable_candidates
if
path
.
is_absolute
():
if
path
.
is_absolute
():
for
candidate
in
candidates
:
for
candidate
in
candidates
:
with
contextlib
.
suppress
(
ValueError
)
:
try
:
path
.
relative_to
(
candidate
)
path
.
relative_to
(
candidate
)
return
[
path
]
return
[
path
]
except
ValueError
:
pass
site_type
=
"writable "
if
writable_only
else
""
site_type
=
"writable "
if
writable_only
else
""
raise
ValueError
(
raise
ValueError
(
f
"{path} is not relative to any discovered {site_type}sites"
f
"{path} is not relative to any discovered {site_type}sites"
...
@@ -1332,9 +1334,11 @@ class Env:
...
@@ -1332,9 +1334,11 @@ class Env:
def
is_path_relative_to_lib
(
self
,
path
:
Path
)
->
bool
:
def
is_path_relative_to_lib
(
self
,
path
:
Path
)
->
bool
:
for
lib_path
in
[
self
.
purelib
,
self
.
platlib
]:
for
lib_path
in
[
self
.
purelib
,
self
.
platlib
]:
with
contextlib
.
suppress
(
ValueError
)
:
try
:
path
.
relative_to
(
lib_path
)
path
.
relative_to
(
lib_path
)
return
True
return
True
except
ValueError
:
pass
return
False
return
False
...
@@ -1733,7 +1737,7 @@ class VirtualEnv(Env):
...
@@ -1733,7 +1737,7 @@ class VirtualEnv(Env):
kwargs
[
"env"
]
=
self
.
get_temp_environ
(
environ
=
kwargs
.
get
(
"env"
))
kwargs
[
"env"
]
=
self
.
get_temp_environ
(
environ
=
kwargs
.
get
(
"env"
))
return
super
()
.
execute
(
bin
,
*
args
,
**
kwargs
)
return
super
()
.
execute
(
bin
,
*
args
,
**
kwargs
)
@context
lib.context
manager
@contextmanager
def
temp_environ
(
self
)
->
Iterator
[
None
]:
def
temp_environ
(
self
)
->
Iterator
[
None
]:
environ
=
dict
(
os
.
environ
)
environ
=
dict
(
os
.
environ
)
try
:
try
:
...
@@ -1867,7 +1871,7 @@ class NullEnv(SystemEnv):
...
@@ -1867,7 +1871,7 @@ class NullEnv(SystemEnv):
return
bin
return
bin
@context
lib.context
manager
@contextmanager
def
ephemeral_environment
(
def
ephemeral_environment
(
executable
:
str
|
Path
|
None
=
None
,
executable
:
str
|
Path
|
None
=
None
,
flags
:
dict
[
str
,
bool
]
|
None
=
None
,
flags
:
dict
[
str
,
bool
]
|
None
=
None
,
...
@@ -1883,7 +1887,7 @@ def ephemeral_environment(
...
@@ -1883,7 +1887,7 @@ def ephemeral_environment(
yield
VirtualEnv
(
venv_dir
,
venv_dir
)
yield
VirtualEnv
(
venv_dir
,
venv_dir
)
@context
lib.context
manager
@contextmanager
def
build_environment
(
def
build_environment
(
poetry
:
CorePoetry
,
env
:
Env
|
None
=
None
,
io
:
IO
|
None
=
None
poetry
:
CorePoetry
,
env
:
Env
|
None
=
None
,
io
:
IO
|
None
=
None
)
->
Iterator
[
Env
]:
)
->
Iterator
[
Env
]:
...
...
tests/utils/fixtures/setups/ansible/setup.py
View file @
7e58d536
from
__future__
import
annotations
from
__future__
import
annotations
import
contextlib
import
json
import
json
import
os
import
os
import
os.path
import
os.path
...
@@ -205,10 +204,12 @@ def read_extras():
...
@@ -205,10 +204,12 @@ def read_extras():
extra_req_file_path
=
os
.
path
.
join
(
extra_req_file_path
=
os
.
path
.
join
(
extra_requirements_dir
,
extra_requirements_filename
extra_requirements_dir
,
extra_requirements_filename
)
)
with
contextlib
.
suppress
(
RuntimeError
)
:
try
:
extras
[
filename_match
.
group
(
1
)]
=
read_file
(
extras
[
filename_match
.
group
(
1
)]
=
read_file
(
extra_req_file_path
extra_req_file_path
)
.
splitlines
()
)
.
splitlines
()
except
RuntimeError
:
pass
return
extras
return
extras
...
...
tests/utils/fixtures/setups/pyyaml/setup.py
View file @
7e58d536
...
@@ -56,7 +56,6 @@ int main(void) {
...
@@ -56,7 +56,6 @@ int main(void) {
"""
"""
import
contextlib
import
os.path
import
os.path
import
platform
import
platform
import
sys
import
sys
...
@@ -82,11 +81,13 @@ if "setuptools.extension" in sys.modules:
...
@@ -82,11 +81,13 @@ if "setuptools.extension" in sys.modules:
sys
.
modules
[
"distutils.command.build_ext"
]
.
Extension
=
_Extension
sys
.
modules
[
"distutils.command.build_ext"
]
.
Extension
=
_Extension
with_cython
=
False
with_cython
=
False
with
contextlib
.
suppress
(
ImportError
)
:
try
:
from
Cython.Distutils
import
build_ext
as
_build_ext
from
Cython.Distutils
import
build_ext
as
_build_ext
from
Cython.Distutils.extension
import
Extension
as
_Extension
from
Cython.Distutils.extension
import
Extension
as
_Extension
with_cython
=
True
with_cython
=
True
except
ImportError
:
pass
try
:
try
:
from
wheel.bdist_wheel
import
bdist_wheel
from
wheel.bdist_wheel
import
bdist_wheel
...
...
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