Skip to content

Commit e461383

Browse files
committed
remove the setup reader
1 parent 658d964 commit e461383

File tree

8 files changed

+28
-795
lines changed

8 files changed

+28
-795
lines changed

src/poetry/inspection/info.py

+5-69
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
from poetry.utils.env import EnvCommandError
2626
from poetry.utils.env import ephemeral_environment
2727
from poetry.utils.helpers import extractall
28-
from poetry.utils.setup_reader import SetupReader
2928

3029

3130
if TYPE_CHECKING:
@@ -322,58 +321,6 @@ def _from_sdist_file(cls, path: Path) -> PackageInfo:
322321

323322
return info.update(new_info)
324323

325-
@staticmethod
326-
def has_setup_files(path: Path) -> bool:
327-
return any((path / f).exists() for f in SetupReader.FILES)
328-
329-
@classmethod
330-
def from_setup_files(cls, path: Path) -> PackageInfo:
331-
"""
332-
Mechanism to parse package information from a `setup.[py|cfg]` file. This uses
333-
the implementation at `poetry.utils.setup_reader.SetupReader` in order to parse
334-
the file. This is not reliable for complex setup files and should only attempted
335-
as a fallback.
336-
337-
:param path: Path to `setup.py` file
338-
"""
339-
if not cls.has_setup_files(path):
340-
raise PackageInfoError(
341-
path, "No setup files (setup.py, setup.cfg) was found."
342-
)
343-
344-
try:
345-
result = SetupReader.read_from_directory(path)
346-
except Exception as e:
347-
raise PackageInfoError(path, e)
348-
349-
python_requires = result["python_requires"]
350-
if python_requires is None:
351-
python_requires = "*"
352-
353-
requires = "".join(dep + "\n" for dep in result["install_requires"])
354-
if result["extras_require"]:
355-
requires += "\n"
356-
357-
for extra_name, deps in result["extras_require"].items():
358-
requires += f"[{extra_name}]\n"
359-
360-
for dep in deps:
361-
requires += dep + "\n"
362-
363-
requires += "\n"
364-
365-
requirements = parse_requires(requires)
366-
367-
info = cls(
368-
name=result.get("name"),
369-
version=result.get("version"),
370-
summary=result.get("description", ""),
371-
requires_dist=requirements,
372-
requires_python=python_requires,
373-
)
374-
375-
return info
376-
377324
@staticmethod
378325
def _find_dist_info(path: Path) -> Iterator[Path]:
379326
"""
@@ -472,16 +419,13 @@ def _get_poetry_package(path: Path) -> ProjectPackage | None:
472419
return None
473420

474421
@classmethod
475-
def from_directory(cls, path: Path, disable_build: bool = False) -> PackageInfo:
422+
def from_directory(cls, path: Path) -> PackageInfo:
476423
"""
477-
Generate package information from a package source directory. If `disable_build`
478-
is not `True` and introspection of all available metadata fails, the package is
479-
attempted to be built in an isolated environment so as to generate required
480-
metadata.
424+
Generate package information from a package source directory. If introspection
425+
of all available metadata fails, the package is attempted to be built in an
426+
isolated environment so as to generate required metadata.
481427
482428
:param path: Path to generate package information from.
483-
:param disable_build: If not `True` and setup reader fails, PEP 517 isolated
484-
build is attempted in order to gather metadata.
485429
"""
486430
project_package = cls._get_poetry_package(path)
487431
info: PackageInfo | None
@@ -492,10 +436,7 @@ def from_directory(cls, path: Path, disable_build: bool = False) -> PackageInfo:
492436

493437
if not info or info.requires_dist is None:
494438
try:
495-
if disable_build:
496-
info = cls.from_setup_files(path)
497-
else:
498-
info = get_pep517_metadata(path)
439+
info = get_pep517_metadata(path)
499440
except PackageInfoError:
500441
if not info:
501442
raise
@@ -572,11 +513,6 @@ def get_pep517_metadata(path: Path) -> PackageInfo:
572513
"""
573514
info = None
574515

575-
with contextlib.suppress(PackageInfoError):
576-
info = PackageInfo.from_setup_files(path)
577-
if all(x is not None for x in (info.version, info.name, info.requires_dist)):
578-
return info
579-
580516
with ephemeral_environment(
581517
flags={"no-pip": False, "no-setuptools": True, "no-wheel": True}
582518
) as venv:

0 commit comments

Comments
 (0)