File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments