6363 "aws_lambda" ,
6464 "cloud_resource_context" ,
6565 "common" ,
66+ "gcp" ,
6667 "gevent" ,
6768 "opentelemetry" ,
6869 "potel" ,
6970 # Integrations that can be migrated -- we should eventually remove all
7071 # of these from the IGNORE list
71- "gcp" ,
72- "httpx" ,
7372 "redis" ,
7473 "requests" ,
7574 "rq" ,
@@ -240,9 +239,9 @@ def _supports_lowest(release: Version) -> bool:
240239 sys .exit (1 )
241240
242241 py_versions = determine_python_versions (pypi_data )
243- target_python_versions = TEST_SUITE_CONFIG [ integration ]. get ( "python" )
244- if target_python_versions :
245- target_python_versions = SpecifierSet ( target_python_versions )
242+ target_python_versions = _transform_target_python_versions (
243+ TEST_SUITE_CONFIG [ integration ]. get ( "python" )
244+ )
246245 return bool (supported_python_versions (py_versions , target_python_versions ))
247246
248247 if not _supports_lowest (releases [0 ]):
@@ -327,7 +326,10 @@ def _pick_releases(
327326
328327def supported_python_versions (
329328 package_python_versions : Union [SpecifierSet , list [Version ]],
330- custom_supported_versions : Optional [SpecifierSet ] = None ,
329+ custom_supported_versions : Optional [
330+ Union [SpecifierSet , dict [SpecifierSet , SpecifierSet ]]
331+ ] = None ,
332+ version : Optional [Version ] = None ,
331333) -> list [Version ]:
332334 """
333335 Get the intersection of Python versions supported by the package and the SDK.
@@ -354,9 +356,25 @@ def supported_python_versions(
354356 curr = MIN_PYTHON_VERSION
355357 while curr <= MAX_PYTHON_VERSION :
356358 if curr in package_python_versions :
357- if not custom_supported_versions or curr in custom_supported_versions :
359+ if not custom_supported_versions :
358360 supported .append (curr )
359361
362+ else :
363+ if isinstance (custom_supported_versions , SpecifierSet ):
364+ if curr in custom_supported_versions :
365+ supported .append (curr )
366+
367+ elif version is not None and isinstance (
368+ custom_supported_versions , dict
369+ ):
370+ for v , py in custom_supported_versions .items ():
371+ if version in v :
372+ if curr in py :
373+ supported .append (curr )
374+ break
375+ else :
376+ supported .append (curr )
377+
360378 # Construct the next Python version (i.e., bump the minor)
361379 next = [int (v ) for v in str (curr ).split ("." )]
362380 next [1 ] += 1
@@ -535,20 +553,38 @@ def _add_python_versions_to_release(
535553
536554 time .sleep (PYPI_COOLDOWN ) # give PYPI some breathing room
537555
538- target_python_versions = TEST_SUITE_CONFIG [ integration ]. get ( "python" )
539- if target_python_versions :
540- target_python_versions = SpecifierSet ( target_python_versions )
556+ target_python_versions = _transform_target_python_versions (
557+ TEST_SUITE_CONFIG [ integration ]. get ( "python" )
558+ )
541559
542560 release .python_versions = pick_python_versions_to_test (
543561 supported_python_versions (
544562 determine_python_versions (release_pypi_data ),
545563 target_python_versions ,
564+ release ,
546565 )
547566 )
548567
549568 release .rendered_python_versions = _render_python_versions (release .python_versions )
550569
551570
571+ def _transform_target_python_versions (
572+ python_versions : Union [str , dict [str , str ], None ]
573+ ) -> Union [SpecifierSet , dict [SpecifierSet , SpecifierSet ], None ]:
574+ """Wrap the contents of the `python` key in SpecifierSets."""
575+ if not python_versions :
576+ return None
577+
578+ if isinstance (python_versions , str ):
579+ return SpecifierSet (python_versions )
580+
581+ if isinstance (python_versions , dict ):
582+ updated = {}
583+ for key , value in python_versions .items ():
584+ updated [SpecifierSet (key )] = SpecifierSet (value )
585+ return updated
586+
587+
552588def get_file_hash () -> str :
553589 """Calculate a hash of the tox.ini file."""
554590 hasher = hashlib .md5 ()
0 commit comments