Skip to content

Commit

Permalink
inspection(dir): prefer poetry config over egg-info
Browse files Browse the repository at this point in the history
  • Loading branch information
abn committed Jul 24, 2020
1 parent 007bc31 commit f57d22e
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 4 deletions.
8 changes: 4 additions & 4 deletions poetry/inspection/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,16 +498,16 @@ def from_directory(
:param path: Path to generate package information from.
:param allow_build: If enabled, as a fallback, build the project to gather metadata.
"""
project_package = cls._get_poetry_package(path)
if project_package:
return cls.from_package(project_package)

info = cls.from_metadata(path)

if info and info.requires_dist is not None:
# return only if requirements are discovered
return info

project_package = cls._get_poetry_package(path)
if project_package:
return cls.from_package(project_package)

try:
if not allow_build:
return cls.from_setup_files(path)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Metadata-Version: 1.0
Name: demo
Version: 0.1.0
Summary: Demo project.
Home-page: https://github.com/demo/demo
Author: Sébastien Eustace
Author-email: [email protected]
License: MIT
Description: UNKNOWN
Platform: UNKNOWN
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cleo; extra == "foo"
pendulum (>=1.0.0)
tomlkit; extra == "bar"
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[tool.poetry]
name = "demo"
version = "0.1.0"
description = ""
authors = ["Sébastien Eustace <[email protected]>"]

[tool.poetry.dependencies]
python = "~2.7 || ^3.4"
pendulum = ">=1.4.4"
cleo = {version = "*", optional = true}
tomlkit = {version = "*", optional = true}

[tool.poetry.extras]
foo = ["cleo"]
bar = ["tomlkit"]

[tool.poetry.dev-dependencies]
pytest = "^3.0"
7 changes: 7 additions & 0 deletions tests/inspection/test_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,10 @@ def test_info_setup_complex_disable_build(mocker, demo_setup_complex):
assert info.name == "demo"
assert info.version == "0.1.0"
assert info.requires_dist is None


def test_info_prefer_poetry_config_over_egg_info():
info = PackageInfo.from_directory(
FIXTURE_DIR_INSPECTIONS / "demo_with_obsolete_egg_info"
)
demo_check_info(info)

0 comments on commit f57d22e

Please sign in to comment.