Skip to content

Commit b5628dc

Browse files
committed
More WIP
1 parent 3c86352 commit b5628dc

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

dep_checker/__init__.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,3 +418,26 @@ def echo(text: str) -> None:
418418
ret |= 1
419419

420420
return ret
421+
422+
423+
# 3rd party
424+
from shippinglabel.requirements import parse_pyproject_dependencies, parse_pyproject_extras
425+
426+
427+
def get_requirements_from_pyproject(project_dir: PathLike) -> Dict[str, Set[ComparableRequirement]]:
428+
project_dir = PathPlus(project_dir)
429+
pyproject_file = project_dir / "pyproject.toml"
430+
431+
dynamic = dom_toml.load(pyproject_file)["project"].get("dynamic", ())
432+
433+
data = {}
434+
435+
if "requirements" in dynamic:
436+
data["$main"] = read_requirements(project_dir / "requirements.txt", include_invalid=True)[0]
437+
else:
438+
data["$main"] = parse_pyproject_dependencies(pyproject_file, flavour="pep621")
439+
440+
for extra_name, extra_requirements in parse_pyproject_extras(pyproject_file).items():
441+
data[extra_name] = extra_requirements
442+
443+
return data

0 commit comments

Comments
 (0)