3333ROOT_DIR = Path (__file__ ).resolve ().parent .parent
3434DOCS_DIR = ROOT_DIR / "docs" / "packages"
3535PATCHES_DIR = ROOT_DIR / "patches"
36- PACKAGES_FILE = "ci_scripts/packages.txt"
37- DEPRECATED_FILE = "ci_scripts/deprecated.txt"
3836REPO = "riseproject-dev/python-wheels"
3937
4038# Python versions (interpreter tags) a package must have upstream riscv64
4442
4543
4644def read_packages () -> List [str ]:
47- """Read the list of packages from packages.txt ."""
45+ """Read active package names from docs/ packages/<pkg>.yaml files ."""
4846 packages = []
49- try :
50- with open (PACKAGES_FILE , 'r' ) as f :
51- for line in f :
52- line = line .strip ()
53- if line and not line .startswith ('#' ):
54- packages .append (line )
55- except FileNotFoundError :
56- print (f"Error: { PACKAGES_FILE } not found" )
57- sys .exit (1 )
47+ for yaml_file in sorted (DOCS_DIR .glob ("*.yaml" )):
48+ package_data = yaml .safe_load (yaml_file .read_text ()) or {}
49+ if "deprecated" in package_data :
50+ continue
51+ packages .append (yaml_file .stem )
5852 return packages
5953
6054
6155def package_yaml (package : str ) -> Path :
62- # packages.txt keeps PyPI's spelling (PyYAML), the YAMLs use the normalized name.
6356 return DOCS_DIR / f"{ normalize_name (package )} .yaml"
6457
6558
@@ -75,20 +68,15 @@ def declared_versions(package_data: Dict) -> Set[str]:
7568
7669
7770def get_registry_latest_version (package_data : Dict ) -> Optional [str ]:
78- """
79- Latest version published to the riscv64 registry, read from the package
80- YAML. Entries without `files` are declared but not built yet.
81- """
82- released = []
71+ """Latest version tracked in the package YAML, published or pending."""
72+ tracked = []
8373 for entry in package_data .get ("versions" ) or []:
84- if "files" not in entry :
85- continue
8674 raw = str (entry ["version" ])
8775 try :
88- released .append ((version .parse (raw ), raw ))
76+ tracked .append ((version .parse (raw ), raw ))
8977 except version .InvalidVersion :
9078 continue
91- return max (released )[1 ] if released else None
79+ return max (tracked )[1 ] if tracked else None
9280
9381
9482def get_pypi_package_info (package : str , retries : int = 3 ) -> Optional [Dict ]:
@@ -205,28 +193,15 @@ def find_upstream_issue(package: str) -> Optional[str]:
205193
206194def deprecate_package (package : str ) -> bool :
207195 """
208- Deprecate our wheel in the working tree: prefix docs/packages/<pkg>.yaml
209- with `deprecated:`, drop the package from packages.txt and add it to
210- deprecated.txt. Returns False when it is already deprecated.
196+ Deprecate our wheel in the working tree by prefixing
197+ docs/packages/<pkg>.yaml with `deprecated:`. Returns False when it is
198+ already deprecated.
211199 """
212200 yaml_file = package_yaml (package )
213201 content = yaml_file .read_text ()
214202 if content .startswith ("deprecated:" ):
215203 return False
216204 yaml_file .write_text (f"deprecated:\n { content } " )
217-
218- packages_file = Path (PACKAGES_FILE )
219- lines = [line for line in packages_file .read_text ().splitlines () if line .strip () != package ]
220- packages_file .write_text ("\n " .join (lines ) + "\n " )
221-
222- deprecated_file = Path (DEPRECATED_FILE )
223- lines = deprecated_file .read_text ().splitlines ()
224- i = next (i for i , line in enumerate (lines ) if line .strip () and not line .lstrip ().startswith ("#" ))
225- comments , deprecated_packages = lines [:i ], lines [i :]
226- if package not in deprecated_packages :
227- deprecated_packages .append (package )
228- deprecated_packages .sort (key = str .lower )
229- deprecated_file .write_text ("\n " .join (comments + deprecated_packages ) + "\n " )
230205 return True
231206
232207
@@ -440,7 +415,7 @@ def check_package(
440415 With `since`, every stable release uploaded since that date and missing
441416 from the YAML counts as an upgrade, not just the ones newer than the
442417 registry. With `declare`, the upgrade, deprecation or yanked marking is
443- written to docs/packages/<pkg>.yaml (and packages.txt/deprecated.txt) for
418+ written to docs/packages/<pkg>.yaml for
444419 the caller to commit. Versions yanked upstream are reported in the
445420 result's `yanked` alongside the upgrade/deprecation status.
446421 """
@@ -452,8 +427,8 @@ def check_package(
452427
453428 registry_version = get_registry_latest_version (package_data )
454429 if registry_version is None :
455- print (f"[X] No released version in { package_yaml (package ).relative_to (ROOT_DIR )} " )
456- return {"status" : "error" , "package" : package , "error" : "No released version in YAML" }
430+ print (f"[X] No tracked version in { package_yaml (package ).relative_to (ROOT_DIR )} " )
431+ return {"status" : "error" , "package" : package , "error" : "No tracked version in YAML" }
457432
458433 pypi_info = get_pypi_package_info (package )
459434 if pypi_info is None :
@@ -570,7 +545,7 @@ def check_upgrade(
570545def deprecation_result (package : str , registry_version : str , pypi_version : str , reason : str , declare : bool ) -> Dict [str , any ]:
571546 upstream_issue = find_upstream_issue (package )
572547 if declare and deprecate_package (package ):
573- print (f" [+] deprecated { package } in { package_yaml (package ).relative_to (ROOT_DIR )} , packages.txt and deprecated.txt " )
548+ print (f" [+] deprecated { package } in { package_yaml (package ).relative_to (ROOT_DIR )} " )
574549 return {
575550 "status" : "can_deprecate" ,
576551 "package" : package ,
@@ -809,13 +784,13 @@ def main():
809784 import argparse
810785
811786 parser = argparse .ArgumentParser (description = "Check package versions between riscv64 registry and PyPI" )
812- parser .add_argument ("packages" , nargs = "*" , help = "Specific packages to check (default: all packages from packages.txt )" )
787+ parser .add_argument ("packages" , nargs = "*" , help = "Specific packages to check (default: active docs/ packages/*.yaml files )" )
813788 parser .add_argument ("--since" , type = parse_since , metavar = "DATE|Nd|Nm" ,
814789 help = "Treat every stable release uploaded since this date (YYYY-MM-DD) or duration (e.g. 12m, 90d) "
815790 "that docs/packages/<pkg>.yaml does not list as a version to add, uncapped" )
816791 parser .add_argument ("--declare" , action = "store_true" ,
817792 help = "Apply the outcome to the working tree: declare new versions and mark yanked ones in "
818- "docs/packages/<pkg>.yaml, deprecate packages in the YAML, packages.txt and deprecated.txt " )
793+ "docs/packages/<pkg>.yaml, and deprecate packages in the YAML" )
819794 parser .add_argument ("--base-file" , type = Path , metavar = "FILE" ,
820795 help = "Base branch copy of the package YAML (as for pending_versions.py): with --declare, "
821796 "only versions it does not declare get the previous version's patches" )
0 commit comments