From f2e013adee60b7ae8f1ec33ae3ffbae5057d230a Mon Sep 17 00:00:00 2001
From: Thomas Schneider <thomas@fsmpi.rwth-aachen.de>
Date: Tue, 17 Sep 2024 17:09:01 +0200
Subject: [PATCH] build: Generate optional dependencies meta groups

---
 pdm_build.py | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/pdm_build.py b/pdm_build.py
index a9a1eb3..49f4d25 100644
--- a/pdm_build.py
+++ b/pdm_build.py
@@ -12,6 +12,20 @@ if TYPE_CHECKING:
 def pdm_build_initialize(context: Context) -> None:
     if not context.target == "sdist":
         return
+
+    metadata = context.config.metadata
+    name = metadata["name"]
+    optdeps = metadata["optional-dependencies"]
+    groups = dict()
+    for opt in optdeps:
+        group = opt.split("-")[0]
+        if group not in groups:
+            groups[group] = []
+        groups[group].append(opt)
+    for k, v in groups.items():
+        optdeps[f"all-{k}"] = [f"{name}[{','.join(v)}]"]
+    optdeps["all"] = [f"{name}[{','.join('all-' + g for g in groups)}]"]
+
     context.config.build_config.includes.append("schilder2000/static/manifest.json")
     if "without-npm" not in context.config_settings:
         # Assume built webpack is already present otherwise
-- 
GitLab