@@ -130,7 +130,8 @@ def _save_to_cache(package: str, version: Version, release: Optional[dict]) -> N
130130
131131
132132def _prefilter_releases (
133- integration : str , releases : dict [str , dict ], older_than : Optional [datetime ] = None
133+ integration : str ,
134+ releases : dict [str , dict ],
134135) -> tuple [list [Version ], Optional [Version ]]:
135136 """
136137 Filter `releases`, removing releases that are for sure unsupported.
@@ -178,9 +179,6 @@ def _prefilter_releases(
178179
179180 uploaded = datetime .fromisoformat (meta ["upload_time_iso_8601" ])
180181
181- if older_than is not None and uploaded > older_than :
182- continue
183-
184182 if CUTOFF is not None and uploaded < CUTOFF :
185183 continue
186184
@@ -224,7 +222,7 @@ def _prefilter_releases(
224222
225223
226224def get_supported_releases (
227- integration : str , pypi_data : dict , older_than : Optional [ datetime ] = None
225+ integration : str , pypi_data : dict
228226) -> tuple [list [Version ], Optional [Version ]]:
229227 """
230228 Get a list of releases that are currently supported by the SDK.
@@ -236,17 +234,15 @@ def get_supported_releases(
236234 We return the list of supported releases and optionally also the newest
237235 prerelease, if it should be tested (meaning it's for a version higher than
238236 the current stable version).
239-
240- If an `older_than` timestamp is provided, no release newer than that will be
241- considered.
242237 """
243238 package = pypi_data ["info" ]["name" ]
244239
245240 # Get a consolidated list without taking into account Python support yet
246241 # (because that might require an additional API call for some
247242 # of the releases)
248243 releases , latest_prerelease = _prefilter_releases (
249- integration , pypi_data ["releases" ], older_than
244+ integration ,
245+ pypi_data ["releases" ],
250246 )
251247
252248 def _supports_lowest (release : Version ) -> bool :
@@ -665,32 +661,10 @@ def _normalize_release(release: dict) -> dict:
665661 return normalized
666662
667663
668- def main (fail_on_changes : bool = False ) -> dict [str , list ]:
664+ def main () -> dict [str , list ]:
669665 """
670666 Generate tox.ini from the tox.jinja template.
671-
672- The script has two modes of operation:
673- - fail on changes mode (if `fail_on_changes` is True)
674- - normal mode (if `fail_on_changes` is False)
675-
676- Fail on changes mode is run on every PR to make sure that `tox.ini`,
677- `tox.jinja` and this script don't go out of sync because of manual changes
678- in one place but not the other.
679-
680- Normal mode is meant to be run as a cron job, regenerating tox.ini and
681- proposing the changes via a PR.
682667 """
683- print (f"Running in { 'fail_on_changes' if fail_on_changes else 'normal' } mode." )
684- last_updated = get_last_updated ()
685- if fail_on_changes :
686- # We need to make the script ignore any new releases after the last updated
687- # timestamp so that we don't fail CI on a PR just because a new package
688- # version was released, leading to unrelated changes in tox.ini.
689- print (
690- f"Since we're in fail_on_changes mode, we're only considering "
691- f"releases before the last tox.ini update at { last_updated .isoformat ()} ."
692- )
693-
694668 global MIN_PYTHON_VERSION , MAX_PYTHON_VERSION
695669 meta = _fetch_sdk_metadata ()
696670 sdk_python_versions = _parse_python_versions_from_classifiers (
@@ -736,12 +710,7 @@ def main(fail_on_changes: bool = False) -> dict[str, list]:
736710
737711 # Get the list of all supported releases
738712
739- # If in fail-on-changes mode, ignore releases newer than `last_updated`
740- older_than = last_updated if fail_on_changes else None
741-
742- releases , latest_prerelease = get_supported_releases (
743- integration , pypi_data , older_than
744- )
713+ releases , latest_prerelease = get_supported_releases (integration , pypi_data )
745714
746715 if not releases :
747716 print (" Found no supported releases." )
@@ -778,9 +747,6 @@ def main(fail_on_changes: bool = False) -> dict[str, list]:
778747 }
779748 )
780749
781- if fail_on_changes :
782- old_file_hash = get_file_hash ()
783-
784750 write_tox_file (packages )
785751
786752 # Sort the release cache file
@@ -798,36 +764,13 @@ def main(fail_on_changes: bool = False) -> dict[str, list]:
798764 ):
799765 releases_cache .write (json .dumps (release ) + "\n " )
800766
801- if fail_on_changes :
802- new_file_hash = get_file_hash ()
803- if old_file_hash != new_file_hash :
804- raise RuntimeError (
805- dedent (
806- """
807- Detected that `tox.ini` is out of sync with
808- `scripts/populate_tox/tox.jinja` and/or
809- `scripts/populate_tox/populate_tox.py`. This might either mean
810- that `tox.ini` was changed manually, or the `tox.jinja`
811- template and/or the `populate_tox.py` script were changed without
812- regenerating `tox.ini`.
813-
814- Please don't make manual changes to `tox.ini`. Instead, make the
815- changes to the `tox.jinja` template and/or the `populate_tox.py`
816- script (as applicable) and regenerate the `tox.ini` file by
817- running scripts/generate-test-files.sh
818- """
819- )
820- )
821- print ("Done checking tox.ini. Looking good!" )
822- else :
823- print (
824- "Done generating tox.ini. Make sure to also update the CI YAML "
825- "files to reflect the new test targets."
826- )
767+ print (
768+ "Done generating tox.ini. Make sure to also update the CI YAML "
769+ "files to reflect the new test targets."
770+ )
827771
828772 return packages
829773
830774
831775if __name__ == "__main__" :
832- fail_on_changes = len (sys .argv ) == 2 and sys .argv [1 ] == "--fail-on-changes"
833- main (fail_on_changes )
776+ main ()
0 commit comments