63
63
"aws_lambda" ,
64
64
"cloud_resource_context" ,
65
65
"common" ,
66
+ "gcp" ,
66
67
"gevent" ,
67
68
"opentelemetry" ,
68
69
"potel" ,
69
70
# Integrations that can be migrated -- we should eventually remove all
70
71
# of these from the IGNORE list
71
- "gcp" ,
72
- "httpx" ,
73
72
"redis" ,
74
73
"requests" ,
75
74
"rq" ,
@@ -240,9 +239,9 @@ def _supports_lowest(release: Version) -> bool:
240
239
sys .exit (1 )
241
240
242
241
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
+ )
246
245
return bool (supported_python_versions (py_versions , target_python_versions ))
247
246
248
247
if not _supports_lowest (releases [0 ]):
@@ -327,7 +326,10 @@ def _pick_releases(
327
326
328
327
def supported_python_versions (
329
328
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 ,
331
333
) -> list [Version ]:
332
334
"""
333
335
Get the intersection of Python versions supported by the package and the SDK.
@@ -354,9 +356,25 @@ def supported_python_versions(
354
356
curr = MIN_PYTHON_VERSION
355
357
while curr <= MAX_PYTHON_VERSION :
356
358
if curr in package_python_versions :
357
- if not custom_supported_versions or curr in custom_supported_versions :
359
+ if not custom_supported_versions :
358
360
supported .append (curr )
359
361
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
+
360
378
# Construct the next Python version (i.e., bump the minor)
361
379
next = [int (v ) for v in str (curr ).split ("." )]
362
380
next [1 ] += 1
@@ -535,20 +553,38 @@ def _add_python_versions_to_release(
535
553
536
554
time .sleep (PYPI_COOLDOWN ) # give PYPI some breathing room
537
555
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
+ )
541
559
542
560
release .python_versions = pick_python_versions_to_test (
543
561
supported_python_versions (
544
562
determine_python_versions (release_pypi_data ),
545
563
target_python_versions ,
564
+ release ,
546
565
)
547
566
)
548
567
549
568
release .rendered_python_versions = _render_python_versions (release .python_versions )
550
569
551
570
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
+
552
588
def get_file_hash () -> str :
553
589
"""Calculate a hash of the tox.ini file."""
554
590
hasher = hashlib .md5 ()
0 commit comments