2828DOCS_DIR = Path ("docs/packages" )
2929PACKAGES_FILE = Path ("ci_scripts/packages.txt" )
3030ARTIFACTS_PATH = os .environ .get ("ARTIFACTS_PATH" , "dist" )
31+ GPL_SOURCES_URL = os .environ .get ("GPL_SOURCES_URL" )
32+ GPL_SOURCES_DESCRIPTION = os .environ .get ("GPL_SOURCES_DESCRIPTION" , "" ).strip ()
3133
3234
3335def find_wheel_file (path ):
@@ -102,6 +104,18 @@ def extract_metadata_from_whl(whl_path):
102104 }
103105
104106
107+ def render_gpl_sources_comment ():
108+ """
109+ Render a doc comment linking to a permanently-hosted GPL sources
110+ artifact (e.g. a manylinux toolchain's src.rpm), if the calling workflow
111+ published one for this build.
112+ """
113+ if not GPL_SOURCES_URL :
114+ return None
115+ suffix = f" ({ GPL_SOURCES_DESCRIPTION } )" if GPL_SOURCES_DESCRIPTION else ""
116+ return f"`Link <{ GPL_SOURCES_URL } >`__ to sources of bundled GPL libraries{ suffix } "
117+
118+
105119def find_patch_dir (slug , version ):
106120 """
107121 Look for a `patches/<slug>/<version_tag>` directory as described in
@@ -121,7 +135,7 @@ def yaml_line(key, value):
121135 ).rstrip ("\n " )
122136
123137
124- def render_new_yaml (slug , source_code , license , version , patch_dir ):
138+ def render_new_yaml (slug , source_code , license , version , patch_dir , comment = None ):
125139 """Render a brand-new docs/packages/<slug>.yaml for a package's first version."""
126140 lines = [yaml_line ("package-name" , slug )]
127141 if source_code :
@@ -131,10 +145,12 @@ def render_new_yaml(slug, source_code, license, version, patch_dir):
131145 lines .append (f" - { yaml_line ('version' , version )} " )
132146 if patch_dir is not None :
133147 lines .append (" patched:" )
148+ if comment :
149+ lines .append (f" { yaml_line ('comment' , comment )} " )
134150 return "\n " .join (lines ) + "\n "
135151
136152
137- def append_version (content , package_data , version , license , patch_dir ):
153+ def append_version (content , package_data , version , license , patch_dir , comment = None ):
138154 """
139155 Append a new version entry to the end of an existing package YAML file's
140156 `versions:` list, preserving the rest of the file byte-for-byte.
@@ -153,6 +169,8 @@ def append_version(content, package_data, version, license, patch_dir):
153169 lines .append (" patched:" )
154170 if license and license != top_level_license :
155171 lines .append (f" { yaml_line ('license' , license )} " )
172+ if comment :
173+ lines .append (f" { yaml_line ('comment' , comment )} " )
156174
157175 return content .rstrip ("\n " ) + "\n " + "\n " .join (lines ) + "\n "
158176
@@ -200,17 +218,20 @@ def main():
200218
201219 slug = normalize_name (display_name )
202220 patch_dir = find_patch_dir (slug , version )
221+ comment = render_gpl_sources_comment ()
203222 yaml_path = DOCS_DIR / f"{ slug } .yaml"
204223 is_new = not yaml_path .exists ()
205224
206225 if is_new :
207226 yaml_path .write_text (
208- render_new_yaml (slug , source_code , license , version , patch_dir )
227+ render_new_yaml (slug , source_code , license , version , patch_dir , comment )
209228 )
210229 else :
211230 content = yaml_path .read_text ()
212231 package_data = yaml .safe_load (content ) or {}
213- updated = append_version (content , package_data , version , license , patch_dir )
232+ updated = append_version (
233+ content , package_data , version , license , patch_dir , comment
234+ )
214235 if updated is None :
215236 print (f"{ slug } { version } is already documented; nothing to do" )
216237 return
0 commit comments