File tree Expand file tree Collapse file tree 5 files changed +312
-14
lines changed Expand file tree Collapse file tree 5 files changed +312
-14
lines changed Original file line number Diff line number Diff line change 11load ("@bazel_skylib//rules:common_settings.bzl" , "string_flag" )
2+ load ("@buildifier_prebuilt//:rules.bzl" , "buildifier" )
23load ("@rules_python//python:py_binary.bzl" , "py_binary" )
34
5+ buildifier (
6+     name  =  "buildifier" ,
7+     lint_mode  =  "fix" ,
8+     mode  =  "fix" ,
9+ )
10+ 
411# use default Python toolchain 
512py_binary (
613    name  =  "main" ,
714    srcs  =  ["main.py" ],
815    deps  =  [
9-       "@pypi//loguru" ,
16+          "@pypi//loguru" ,
1017    ],
1118)
1219
@@ -15,37 +22,38 @@ py_binary(
1522    name  =  "main-3_10" ,
1623    srcs  =  ["main.py" ],
1724    main  =  "main.py" ,
25+     python_version  =  "3.10" ,
1826    deps  =  [
19-       "@pypi//loguru" ,
27+          "@pypi//loguru" ,
2028    ],
21-     python_version = "3.10" 
2229)
2330
2431# use particular Python toolchain (3.11) 
2532py_binary (
2633    name  =  "main-3_11" ,
27-     main  =  "main.py" ,
2834    srcs  =  ["main.py" ],
35+     main  =  "main.py" ,
36+     python_version  =  "3.11" ,
2937    deps  =  [
30-       "@pypi//loguru" ,
38+          "@pypi//loguru" ,
3139    ],
32-     python_version = "3.11" 
3340)
3441
3542genrule (
3643    name  =  "python-helper" ,
3744    outs  =  ["data.json" ],
38-     toolchains = ["@rules_python//python:current_py_toolchain" ],
3945    # Path to Python interpreter via a MAKE variable 
4046    # https://rules-python.readthedocs.io/en/latest/toolchains.html#toolchain-usage-in-other-rules 
4147    cmd  =  "$(PYTHON3) -c \" import json; print(json.dumps({'a': 'b'}, indent=2))\"  > $@" ,
48+     toolchains  =  ["@rules_python//python:current_py_toolchain" ],
4249)
4350
4451# flag to request using a local Python interpreter 
4552config_setting (
4653    name  =  "is_py_local" ,
4754    flag_values  =  {":py" : "local-3_12" },
4855)
56+ 
4957string_flag (
5058    name  =  "py" ,
5159    build_setting_default  =  "" ,
Original file line number Diff line number Diff line change 1+ bazel_dep (name  =  "buildifier_prebuilt" , version  =  "8.0.3" , dev_dependency  =  True )
2+ 
13bazel_dep (name  =  "bazel_skylib" , version  =  "1.7.1" )
24bazel_dep (name  =  "rules_python" , version  =  "1.5.0-rc4" )
5+ bazel_dep (name  =  "aspect_rules_py" , version  =  "1.6.0" )
36
47python  =  use_extension ("@rules_python//python/extensions:python.bzl" , "python" )
58python .defaults (python_version  =  "3.11" )
69
710# register multiple toolchains with different Python versions 
811python .toolchain (python_version  =  "3.10" )
9- python .toolchain (python_version  =  "3.11" , configure_coverage_tool  =  True )
12+ python .toolchain (
13+     configure_coverage_tool  =  True ,
14+     python_version  =  "3.11" ,
15+ )
1016
1117pip  =  use_extension ("@rules_python//python/extensions:pip.bzl" , "pip" )
1218
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments