@@ -170,6 +170,8 @@ pub enum PythonVariant {
170170 Debug ,
171171 Freethreaded ,
172172 FreethreadedDebug ,
173+ Gil ,
174+ GilDebug ,
173175}
174176
175177/// A Python discovery version request.
@@ -1685,41 +1687,57 @@ impl PythonVariant {
16851687 Self :: Debug => interpreter. debug_enabled ( ) ,
16861688 Self :: Freethreaded => interpreter. gil_disabled ( ) ,
16871689 Self :: FreethreadedDebug => interpreter. gil_disabled ( ) && interpreter. debug_enabled ( ) ,
1690+ Self :: Gil => !interpreter. gil_disabled ( ) ,
1691+ Self :: GilDebug => !interpreter. gil_disabled ( ) && interpreter. debug_enabled ( ) ,
16881692 }
16891693 }
16901694
16911695 /// Return the executable suffix for the variant, e.g., `t` for `python3.13t`.
16921696 ///
16931697 /// Returns an empty string for the default Python variant.
1694- pub fn suffix ( self ) -> & ' static str {
1698+ pub fn executable_suffix ( self ) -> & ' static str {
16951699 match self {
16961700 Self :: Default => "" ,
16971701 Self :: Debug => "d" ,
16981702 Self :: Freethreaded => "t" ,
16991703 Self :: FreethreadedDebug => "td" ,
1704+ Self :: Gil => "" ,
1705+ Self :: GilDebug => "d" ,
1706+ }
1707+ }
1708+
1709+ /// Return the suffix for display purposes, e.g., `+gil`.
1710+ pub fn display_suffix ( self ) -> & ' static str {
1711+ match self {
1712+ Self :: Default => "" ,
1713+ Self :: Debug => "+debug" ,
1714+ Self :: Freethreaded => "+freethreaded" ,
1715+ Self :: FreethreadedDebug => "+freethreaded+debug" ,
1716+ Self :: Gil => "+gil" ,
1717+ Self :: GilDebug => "+gil+debug" ,
17001718 }
17011719 }
17021720
17031721 /// Return the lib suffix for the variant, e.g., `t` for `python3.13t` but an empty string for
17041722 /// `python3.13d` or `python3.13`.
17051723 pub fn lib_suffix ( self ) -> & ' static str {
17061724 match self {
1707- Self :: Default | Self :: Debug => "" ,
1725+ Self :: Default | Self :: Debug | Self :: Gil | Self :: GilDebug => "" ,
17081726 Self :: Freethreaded | Self :: FreethreadedDebug => "t" ,
17091727 }
17101728 }
17111729
17121730 pub fn is_freethreaded ( self ) -> bool {
17131731 match self {
1714- Self :: Default | Self :: Debug => false ,
1732+ Self :: Default | Self :: Debug | Self :: Gil | Self :: GilDebug => false ,
17151733 Self :: Freethreaded | Self :: FreethreadedDebug => true ,
17161734 }
17171735 }
17181736
17191737 pub fn is_debug ( self ) -> bool {
17201738 match self {
1721- Self :: Default | Self :: Freethreaded => false ,
1722- Self :: Debug | Self :: FreethreadedDebug => true ,
1739+ Self :: Default | Self :: Freethreaded | Self :: Gil => false ,
1740+ Self :: Debug | Self :: FreethreadedDebug | Self :: GilDebug => true ,
17231741 }
17241742 }
17251743}
@@ -2450,7 +2468,7 @@ impl fmt::Display for ExecutableName {
24502468 if let Some ( prerelease) = & self . prerelease {
24512469 write ! ( f, "{prerelease}" ) ?;
24522470 }
2453- f. write_str ( self . variant . suffix ( ) ) ?;
2471+ f. write_str ( self . variant . executable_suffix ( ) ) ?;
24542472 f. write_str ( EXE_SUFFIX ) ?;
24552473 Ok ( ( ) )
24562474 }
@@ -3067,6 +3085,8 @@ impl FromStr for PythonVariant {
30673085 "t" | "freethreaded" => Ok ( Self :: Freethreaded ) ,
30683086 "d" | "debug" => Ok ( Self :: Debug ) ,
30693087 "td" | "freethreaded+debug" => Ok ( Self :: FreethreadedDebug ) ,
3088+ "gil" => Ok ( Self :: Gil ) ,
3089+ "gil+debug" => Ok ( Self :: GilDebug ) ,
30703090 "" => Ok ( Self :: Default ) ,
30713091 _ => Err ( ( ) ) ,
30723092 }
@@ -3080,6 +3100,8 @@ impl fmt::Display for PythonVariant {
30803100 Self :: Debug => f. write_str ( "debug" ) ,
30813101 Self :: Freethreaded => f. write_str ( "freethreaded" ) ,
30823102 Self :: FreethreadedDebug => f. write_str ( "freethreaded+debug" ) ,
3103+ Self :: Gil => f. write_str ( "gil" ) ,
3104+ Self :: GilDebug => f. write_str ( "gil+debug" ) ,
30833105 }
30843106 }
30853107}
@@ -3109,15 +3131,15 @@ impl fmt::Display for VersionRequest {
31093131 match self {
31103132 Self :: Any => f. write_str ( "any" ) ,
31113133 Self :: Default => f. write_str ( "default" ) ,
3112- Self :: Major ( major, variant) => write ! ( f, "{major}{}" , variant. suffix ( ) ) ,
3134+ Self :: Major ( major, variant) => write ! ( f, "{major}{}" , variant. display_suffix ( ) ) ,
31133135 Self :: MajorMinor ( major, minor, variant) => {
3114- write ! ( f, "{major}.{minor}{}" , variant. suffix ( ) )
3136+ write ! ( f, "{major}.{minor}{}" , variant. display_suffix ( ) )
31153137 }
31163138 Self :: MajorMinorPatch ( major, minor, patch, variant) => {
3117- write ! ( f, "{major}.{minor}.{patch}{}" , variant. suffix ( ) )
3139+ write ! ( f, "{major}.{minor}.{patch}{}" , variant. display_suffix ( ) )
31183140 }
31193141 Self :: MajorMinorPrerelease ( major, minor, prerelease, variant) => {
3120- write ! ( f, "{major}.{minor}{prerelease}{}" , variant. suffix ( ) )
3142+ write ! ( f, "{major}.{minor}{prerelease}{}" , variant. display_suffix ( ) )
31213143 }
31223144 Self :: Range ( specifiers, _) => write ! ( f, "{specifiers}" ) ,
31233145 }
0 commit comments