Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions pip/flatpak-pip-generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@
"--pyproject-file",
help="Specify pyproject.toml file. Cannot be used with requirements file.",
)
parser.add_argument(
"--optdep-groups",
nargs="*",
metavar="GROUP",
help="Specify optional dependency groups to include. Can only be used with pyproject file.",
)
parser.add_argument(
"--build-only",
action="store_const",
Expand Down Expand Up @@ -116,6 +122,9 @@
if opts.requirements_file and opts.pyproject_file:
sys.exit("Can't use both requirements and pyproject files at the same time")

if opts.requirements_file and opts.optdep_groups:
sys.exit("Can only use optional dependency groups with pyproject file")

if opts.pyproject_file:
try:
from tomllib import load as toml_load
Expand Down Expand Up @@ -477,6 +486,16 @@ def to_ver(v: str) -> Version | None:
dependencies = get_poetry_deps(pyproject_data)
else:
dependencies = pyproject_data.get("project", {}).get("dependencies", [])
if opts.optdep_groups:
pyproject_optdep_groups = pyproject_data.get("project", {}).get(
"optional-dependencies", []
)
for group in opts.optdep_groups:
if group not in pyproject_optdep_groups:
sys.exit(
f"Optional dependency group {group} not found in pyproject file"
)
dependencies += pyproject_optdep_groups[group]

if not dependencies:
sys.exit("Pyproject file was specified but no dependencies were collected")
Expand Down