@@ -192,35 +192,65 @@ http_archive(
192
192
193
193
git_repository (
194
194
name = "rules_python" ,
195
- commit = "a0fbf98d4e3a232144df4d0d80b577c7a693b570 " ,
195
+ commit = "c8c79aae9aa1b61d199ad03d5fe06338febd0774 " ,
196
196
remote = "https://github.com/bazelbuild/rules_python.git" ,
197
197
shallow_since = "1586444447 +0200" ,
198
198
)
199
199
200
- load ("@rules_python//python:repositories.bzl" , "py_repositories" )
200
+ # Based on the hermetic Python 3 guide found here
201
+ # https://thethoughtfulkoala.com/posts/2020/05/16/bazel-hermetic-python.html
202
+ _py_configure = "./configure --prefix=$(pwd)/bazel_install"
201
203
202
- py_repositories ()
204
+ http_archive (
205
+ name = "python_interpreter" ,
206
+ build_file_content = """
207
+ exports_files(["python_bin"])
208
+ filegroup(
209
+ name = "files",
210
+ srcs = glob(["bazel_install/**"], exclude = ["**/* *"]),
211
+ visibility = ["//visibility:public"],
212
+ )
213
+ """ ,
214
+ patch_cmds = [
215
+ "mkdir $(pwd)/bazel_install" ,
216
+ _py_configure ,
217
+ "make -j$(nproc)" ,
218
+ "make install" ,
219
+ "ln -s bazel_install/bin/python3 python_bin" ,
220
+ ],
221
+ sha256 = "91923007b05005b5f9bd46f3b9172248aea5abc1543e8a636d59e629c3331b01" ,
222
+ strip_prefix = "Python-3.7.9" ,
223
+ urls = ["https://www.python.org/ftp/python/3.7.9/Python-3.7.9.tar.xz" ],
224
+ )
203
225
204
- load ( "@rules_python//python:pip.bzl" , "pip_repositories " )
226
+ register_toolchains ( "//:py_toolchain " )
205
227
206
- pip_repositories ( )
228
+ load ( "@rules_python//python:repositories.bzl" , "py_repositories" )
207
229
208
- load ("@rules_python//python:pip.bzl" , "pip3_import" )
230
+ py_repositories ()
231
+
232
+ load ("@rules_python//python:pip.bzl" , "pip_install" )
209
233
210
- pip3_import (
234
+ pip_install (
211
235
name = "python_control_deps" ,
236
+ python_interpreter_target = "@python_interpreter//:python_bin" ,
212
237
requirements = "//firmware/app/control/python_controller:requirements.txt" ,
213
238
)
214
239
215
- load ("@python_control_deps//:requirements.bzl" , "pip_install" )
216
-
217
- pip_install ()
218
-
219
- pip3_import (
240
+ pip_install (
220
241
name = "dynamic_parameter_deps" ,
242
+ python_interpreter_target = "@python_interpreter//:python_bin" ,
221
243
requirements = "//shared/parameter_v2/generation_scripts:requirements.txt" ,
222
244
)
223
245
224
- load ("@dynamic_parameter_deps//:requirements.bzl" , "pip_install" )
246
+ pip_install (
247
+ name = "nanopb_deps" ,
248
+ python_interpreter_target = "@python_interpreter//:python_bin" ,
249
+ requirements = "//external:nanopb_requirements.txt" ,
250
+ )
225
251
226
- pip_install ()
252
+ pip_install (
253
+ name = "python_tools_deps" ,
254
+ python_interpreter_target = "@python_interpreter//:python_bin" ,
255
+ requirements = "//python_tools:requirements.txt" ,
256
+ )
0 commit comments