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
42768116
Unverified
Commit
42768116
authored
Sep 30, 2020
by
Arun Babu Neelicattu
Committed by
GitHub
Sep 30, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
inspection: improve package info error message (#2997)
parent
09071b0b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
12 deletions
+28
-12
poetry/inspection/info.py
+28
-12
No files found.
poetry/inspection/info.py
View file @
42768116
...
@@ -43,9 +43,14 @@ PEP517_META_BUILD_DEPS = ["pep517===0.8.2", "toml==0.10.1"]
...
@@ -43,9 +43,14 @@ PEP517_META_BUILD_DEPS = ["pep517===0.8.2", "toml==0.10.1"]
class
PackageInfoError
(
ValueError
):
class
PackageInfoError
(
ValueError
):
def
__init__
(
self
,
path
):
# type: (Union[Path, str]) -> None
def
__init__
(
self
,
path
,
*
reasons
):
# type: (Union[Path, str], *Union[BaseException, str]) -> None
reasons
=
(
"Unable to determine package info for path: {}"
.
format
(
str
(
path
)),
)
+
reasons
super
(
PackageInfoError
,
self
)
.
__init__
(
super
(
PackageInfoError
,
self
)
.
__init__
(
"
Unable to determine package info for path: {}"
.
format
(
str
(
path
)
)
"
\n\n
"
.
join
(
str
(
msg
)
.
strip
()
for
msg
in
reasons
if
msg
)
)
)
...
@@ -290,12 +295,14 @@ class PackageInfo:
...
@@ -290,12 +295,14 @@ class PackageInfo:
:param path: Path to `setup.py` file
:param path: Path to `setup.py` file
"""
"""
if
not
cls
.
has_setup_files
(
path
):
if
not
cls
.
has_setup_files
(
path
):
raise
PackageInfoError
(
path
)
raise
PackageInfoError
(
path
,
"No setup files (setup.py, setup.cfg) was found."
)
try
:
try
:
result
=
SetupReader
.
read_from_directory
(
path
)
result
=
SetupReader
.
read_from_directory
(
path
)
except
Exception
:
except
Exception
as
e
:
raise
PackageInfoError
(
path
)
raise
PackageInfoError
(
path
,
e
)
python_requires
=
result
[
"python_requires"
]
python_requires
=
result
[
"python_requires"
]
if
python_requires
is
None
:
if
python_requires
is
None
:
...
@@ -328,7 +335,10 @@ class PackageInfo:
...
@@ -328,7 +335,10 @@ class PackageInfo:
if
not
(
info
.
name
and
info
.
version
)
and
not
info
.
requires_dist
:
if
not
(
info
.
name
and
info
.
version
)
and
not
info
.
requires_dist
:
# there is nothing useful here
# there is nothing useful here
raise
PackageInfoError
(
path
)
raise
PackageInfoError
(
path
,
"No core metadata (name, version, requires-dist) could be retrieved."
,
)
return
info
return
info
...
@@ -463,15 +473,21 @@ class PackageInfo:
...
@@ -463,15 +473,21 @@ class PackageInfo:
cls
.
_log
(
"PEP517 build failed: {}"
.
format
(
e
),
level
=
"debug"
)
cls
.
_log
(
"PEP517 build failed: {}"
.
format
(
e
),
level
=
"debug"
)
setup_py
=
path
/
"setup.py"
setup_py
=
path
/
"setup.py"
if
not
setup_py
.
exists
():
if
not
setup_py
.
exists
():
raise
PackageInfoError
(
path
)
raise
PackageInfoError
(
path
,
e
,
"No fallback setup.py file was found to generate egg_info."
,
)
cwd
=
Path
.
cwd
()
cwd
=
Path
.
cwd
()
os
.
chdir
(
path
.
as_posix
())
os
.
chdir
(
path
.
as_posix
())
try
:
try
:
venv
.
run
(
"python"
,
"setup.py"
,
"egg_info"
)
venv
.
run
(
"python"
,
"setup.py"
,
"egg_info"
)
return
cls
.
from_metadata
(
path
)
return
cls
.
from_metadata
(
path
)
except
EnvCommandError
:
except
EnvCommandError
as
fbe
:
raise
PackageInfoError
(
path
)
raise
PackageInfoError
(
path
,
"Fallback egg_info generation failed."
,
fbe
)
finally
:
finally
:
os
.
chdir
(
cwd
.
as_posix
())
os
.
chdir
(
cwd
.
as_posix
())
...
@@ -482,7 +498,7 @@ class PackageInfo:
...
@@ -482,7 +498,7 @@ class PackageInfo:
return
info
return
info
# if we reach here, everything has failed and all hope is lost
# if we reach here, everything has failed and all hope is lost
raise
PackageInfoError
(
path
)
raise
PackageInfoError
(
path
,
"Exhausted all core metadata sources."
)
@classmethod
@classmethod
def
from_directory
(
def
from_directory
(
...
@@ -561,8 +577,8 @@ class PackageInfo:
...
@@ -561,8 +577,8 @@ class PackageInfo:
try
:
try
:
return
cls
.
_from_distribution
(
pkginfo
.
BDist
(
str
(
path
)))
return
cls
.
_from_distribution
(
pkginfo
.
BDist
(
str
(
path
)))
except
ValueError
:
except
ValueError
as
e
:
raise
PackageInfoError
(
path
)
raise
PackageInfoError
(
path
,
e
)
@classmethod
@classmethod
def
from_path
(
cls
,
path
):
# type: (Path) -> PackageInfo
def
from_path
(
cls
,
path
):
# type: (Path) -> PackageInfo
...
...
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