Skip to content

Commit

Permalink
Add poetry entrypoints metadata(#489)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelotrevisani authored Sep 20, 2023
1 parent b1848ba commit 7636a80
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
6 changes: 6 additions & 0 deletions grayskull/strategy/py_toml.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,12 @@ def add_poetry_metadata(metadata: dict, toml_metadata: dict) -> dict:
metadata["requirements"]["run_constrained"].extend(req_run_constrained)

host_metadata = metadata["requirements"].get("host", [])
if toml_metadata["tool"].get("poetry", {}).get("scripts"):
metadata["build"]["entry_points"] = []
for entry_name, entry_path in toml_metadata["tool"]["poetry"][
"scripts"
].items():
metadata["build"]["entry_points"].append(f"{entry_name} = {entry_path}")
if "poetry" not in host_metadata and "poetry-core" not in host_metadata:
metadata["requirements"]["host"] = host_metadata + ["poetry-core"]

Expand Down
31 changes: 31 additions & 0 deletions tests/test_poetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,34 @@ def test_get_constrained_dep_version_not_present():
)
== "pytest-kind"
)


def test_entrypoints():
poetry = {
"requirements": {"host": ["setuptools"], "run": ["python"]},
"build": {},
"test": {},
}
toml_metadata = {
"tool": {
"poetry": {
"scripts": {
"grayskull": "grayskull.main:main",
"grayskull-recipe": "grayskull.main:recipe",
}
}
}
}
assert add_poetry_metadata(poetry, toml_metadata) == {
"requirements": {
"host": ["setuptools", "poetry-core"],
"run": ["python"],
},
"build": {
"entry_points": [
"grayskull = grayskull.main:main",
"grayskull-recipe = grayskull.main:recipe",
]
},
"test": {},
}

0 comments on commit 7636a80

Please sign in to comment.