@@ -450,6 +450,16 @@ def constant_replace(
450450 os .rename (filename + ".new" , filename )
451451
452452
453+ def get_version_suffix (tag : Tag , done : bool = False ) -> str :
454+ # 3.15+ uses "+dev" for PEP 440 local-version compliance;
455+ # 3.14 and earlier keep the bare "+" suffix.
456+ if done :
457+ suffix = "+dev" if tag .as_tuple () >= (3 , 15 ) else "+"
458+ else :
459+ suffix = ""
460+ return suffix
461+
462+
453463def tweak_patchlevel (
454464 tag : Tag , filename : str = "Include/patchlevel.h" , done : bool = False
455465) -> None :
@@ -470,12 +480,7 @@ def tweak_patchlevel(
470480 "rc" : "PY_RELEASE_LEVEL_GAMMA" ,
471481 "f" : "PY_RELEASE_LEVEL_FINAL" ,
472482 }[tag .level ]
473- if done :
474- # 3.15+ uses "+dev" for PEP 440 local-version compliance;
475- # 3.14 and earlier keep the bare "+" suffix.
476- plus = "+dev" if tag .as_tuple () >= (3 , 15 ) else "+"
477- else :
478- plus = ""
483+ plus = get_version_suffix (tag , done = done )
479484 new_constants = template .format (tag = tag , level_def = level_def , plus = plus )
480485 if tag .as_tuple () >= (3 , 7 , 0 , "a" , 3 ):
481486 new_constants = new_constants .expandtabs ()
@@ -499,19 +504,28 @@ def get_pep_number(version: str) -> str:
499504 return "TODO"
500505
501506
502- def tweak_readme (tag : Tag , filename : str = "README.rst" ) -> None :
507+ def tweak_readme (tag : Tag , filename : str = "README.rst" , done : bool = False ) -> None :
503508 print (f"Updating { filename } ..." , end = " " )
504509 readme = Path (filename )
505510
506511 # Update first line: "This is Python version X.Y.Z {release_level} N"
507512 # and update length of underline in second line to match.
508513 lines = readme .read_text ().split ("\n " )
509- this_is = f"This is Python version { tag .long_name } "
514+ this_is = (
515+ f"This is Python version { tag .long_name } { get_version_suffix (tag , done = done )} "
516+ )
510517 underline = "=" * len (this_is )
511518 lines [0 ] = this_is
512519 lines [1 ] = underline
513520 content = "\n " .join (lines )
514521
522+ if done :
523+ # Post-release only changes the version line; the substitutions below
524+ # already ran at bump time, and skipping them avoids the PEP fetch.
525+ readme .write_text (content )
526+ print ("done" )
527+ return
528+
515529 DOCS_URL = r"https://docs\.python\.org/"
516530 X_Y = r"\d+\.\d+"
517531
@@ -858,6 +872,7 @@ def make_tag(tag: Tag, *, sign_gpg: bool = True) -> bool:
858872
859873
860874def done (tag : Tag ) -> None :
875+ tweak_readme (tag , done = True )
861876 tweak_patchlevel (tag , done = True )
862877
863878
0 commit comments