- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 636
 
feat(toolchain): support freethreaded toolchains #2372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 12 commits
c53ada9
              b182b52
              02e84f7
              0b57e4d
              330b9f2
              503acab
              fe35320
              0cee209
              aef8f47
              e58413c
              0d6366a
              1c54116
              472cc40
              c319b2b
              5fbbf9e
              2d6e11a
              465111e
              0f9954e
              daaa4de
              66a102a
              b53073a
              ffe70cb
              b39ff67
              a90dd54
              c2663ba
              8585991
              f9609e9
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| 
          
            
          
           | 
    @@ -45,11 +45,12 @@ def define_hermetic_runtime_toolchain_impl( | |
| python_version: {type}`str` The Python version, in `major.minor.micro` | ||
| format. | ||
| python_bin: {type}`str` The path to the Python binary within the | ||
| repositoroy. | ||
| repository. | ||
| coverage_tool: {type}`str` optional target to the coverage tool to | ||
| use. | ||
| """ | ||
| _ = name # @unused | ||
| is_freethreaded = Label("//python/config_settings:is_py_freethreaded") | ||
                
      
                  aignas marked this conversation as resolved.
               
              
                Outdated
          
            Show resolved
            Hide resolved
         | 
||
| version_info = semver(python_version) | ||
| version_dict = version_info.to_dict() | ||
| native.filegroup( | ||
| 
        
          
        
         | 
    @@ -65,21 +66,27 @@ def define_hermetic_runtime_toolchain_impl( | |
| # Platform-agnostic filegroup can't match on all patterns. | ||
| allow_empty = True, | ||
| exclude = [ | ||
| # Unused shared libraries. `python` executable and the `:libpython` target | ||
                
      
                  aignas marked this conversation as resolved.
               
          
            Show resolved
            Hide resolved
         | 
||
| # depend on `libpython{python_version}.so.1.0`. | ||
| "lib/libpython{major}.{minor}.so".format(**version_dict), | ||
| # static libraries | ||
| "lib/**/*.a", | ||
| # During pyc creation, temp files named *.pyc.NNN are created | ||
| "**/__pycache__/*.pyc.*", | ||
| # Do exclusions for all known ABIs | ||
| # Unused shared libraries. `python` executable and the `:libpython` target | ||
| # depend on `libpython{python_version}.so.1.0`. | ||
| "lib/libpython{major}.{minor}*.so".format(**version_dict), | ||
| 
         There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just checking/curious: I'm guessing the  There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is for exclusion, that is why   | 
||
| "lib/libpython{major}.{minor}*.so".format(**version_dict), | ||
| # tests for the standard libraries. | ||
| "lib/python{major}.{minor}/**/test/**".format(**version_dict), | ||
| "lib/python{major}.{minor}/**/tests/**".format(**version_dict), | ||
| "**/__pycache__/*.pyc.*", # During pyc creation, temp files named *.pyc.NNN are created | ||
| "lib/python{major}.{minor}*/**/test/**".format(**version_dict), | ||
| "lib/python{major}.{minor}*/**/tests/**".format(**version_dict), | ||
| ] + glob_excludes.version_dependent_exclusions() + extra_files_glob_exclude, | ||
| ), | ||
| ) | ||
| cc_import( | ||
| name = "interface", | ||
| interface_library = "libs/python{major}{minor}.lib".format(**version_dict), | ||
| interface_library = select({ | ||
| is_freethreaded: "libs/python{major}{minor}t.lib".format(**version_dict), | ||
| "//conditions:default": "libs/python{major}{minor}.lib".format(**version_dict), | ||
| }), | ||
| system_provided = True, | ||
| ) | ||
| 
     | 
||
| 
        
          
        
         | 
    @@ -96,14 +103,65 @@ def define_hermetic_runtime_toolchain_impl( | |
| hdrs = [":includes"], | ||
| includes = [ | ||
| "include", | ||
| "include/python{major}.{minor}".format(**version_dict), | ||
| "include/python{major}.{minor}m".format(**version_dict), | ||
| ] + select({ | ||
| is_freethreaded: [ | ||
| "include/python{major}.{minor}t".format(**version_dict), | ||
| # FIXME @aignas 2024-11-05: the following looks fishy - should | ||
| # we have a config setting for `m` (i.e. DEBUG builds)? | ||
| "include/python{major}.{minor}tm".format(**version_dict), | ||
                
      
                  aignas marked this conversation as resolved.
               
              
                Outdated
          
            Show resolved
            Hide resolved
         | 
||
| ], | ||
| "//conditions:default": [ | ||
| "include/python{major}.{minor}".format(**version_dict), | ||
| "include/python{major}.{minor}m".format(**version_dict), | ||
| ], | ||
| }), | ||
| ) | ||
| native.config_setting( | ||
| name = "is_freethreaded_linux", | ||
| flag_values = { | ||
| Label("//python/config_settings:py_freethreaded"): "yes", | ||
| }, | ||
| constraint_values = [ | ||
| "@platforms//os:linux", | ||
| ], | ||
| visibility = ["//visibility:private"], | ||
| ) | ||
| native.config_setting( | ||
| name = "is_freethreaded_osx", | ||
| flag_values = { | ||
| Label("//python/config_settings:py_freethreaded"): "yes", | ||
| }, | ||
| constraint_values = [ | ||
| "@platforms//os:osx", | ||
| ], | ||
| visibility = ["//visibility:private"], | ||
| ) | ||
| native.config_setting( | ||
| name = "is_freethreaded_windows", | ||
| flag_values = { | ||
| Label("//python/config_settings:py_freethreaded"): "yes", | ||
| }, | ||
| constraint_values = [ | ||
| "@platforms//os:windows", | ||
                
      
                  rickeylev marked this conversation as resolved.
               
          
            Show resolved
            Hide resolved
         | 
||
| ], | ||
| visibility = ["//visibility:private"], | ||
| ) | ||
| 
     | 
||
| cc_library( | ||
| name = "libpython", | ||
| hdrs = [":includes"], | ||
| srcs = select({ | ||
| ":is_freethreaded_linux": [ | ||
| "lib/libpython{major}.{minor}t.so".format(**version_dict), | ||
| "lib/libpython{major}.{minor}t.so.1.0".format(**version_dict), | ||
| ], | ||
| ":is_freethreaded_osx": [ | ||
| "lib/libpython{major}.{minor}t.dylib".format(**version_dict), | ||
| ], | ||
| ":is_freethreaded_windows": [ | ||
| "python3.dll", | ||
| "libs/python{major}{minor}t.lib".format(**version_dict), | ||
| ], | ||
| "@platforms//os:linux": [ | ||
| "lib/libpython{major}.{minor}.so".format(**version_dict), | ||
| "lib/libpython{major}.{minor}.so.1.0".format(**version_dict), | ||
| 
          
            
          
           | 
    @@ -137,7 +195,10 @@ def define_hermetic_runtime_toolchain_impl( | |
| python_version = "PY3", | ||
| implementation_name = "cpython", | ||
| # See https://peps.python.org/pep-3147/ for pyc tag infix format | ||
| pyc_tag = "cpython-{major}{minor}".format(**version_dict), | ||
| pyc_tag = select({ | ||
| is_freethreaded: "cpython-{major}{minor}t".format(**version_dict), | ||
| "//conditions:default": "cpython-{major}{minor}".format(**version_dict), | ||
| }), | ||
| ) | ||
| 
     | 
||
| py_runtime_pair( | ||
| 
          
            
          
           | 
    ||
Uh oh!
There was an error while loading. Please reload this page.