File tree Expand file tree Collapse file tree 2 files changed +13
-11
lines changed
Expand file tree Collapse file tree 2 files changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ boto3==1.9.253
1212
1313In ` WORKSPACE `
1414
15- ```
15+ ``` python
1616rules_python_external_version = " {COMMIT_SHA} "
1717
1818http_archive(
@@ -28,14 +28,14 @@ rules_python_external_dependencies()
2828
2929load(" @rules_python_external//:defs.bzl" , " pip_install" )
3030pip_install(
31- name = "py_deps"
31+ name = " py_deps" ,
3232 requirements = " //:requirements.txt" ,
3333)
3434```
3535
3636Example ` BUILD ` file.
3737
38- ```
38+ ``` python
3939load(" @py_deps//:requirements.bzl" , " requirement" )
4040
4141py_binary(
Original file line number Diff line number Diff line change @@ -9,6 +9,15 @@ def _pip_repository_impl(rctx):
99
1010 rctx .file ("BUILD" , "" )
1111
12+ # Get the root directory of these rules
13+ rules_root = rctx .path (Label ("//:BUILD" )).dirname
14+ thirdparty_roots = [
15+ # Includes all the external dependencies from repositories.bzl
16+ rctx .path (Label ("@" + repo + "//:BUILD.bazel" )).dirname
17+ for repo in all_requirements
18+ ]
19+ pypath = ":" .join ([str (p ) for p in [rules_root ] + thirdparty_roots ])
20+
1221 result = rctx .execute (
1322 [
1423 rctx .which (rctx .attr .python_interpreter ),
@@ -20,14 +29,7 @@ def _pip_repository_impl(rctx):
2029 ],
2130 environment = {
2231 # Manually construct the PYTHONPATH since we cannot use the toolchain here
23- "PYTHONPATH" : ":" .join (
24- # Includes the root of this repo and all the external dependencies from repositories.bzl
25- [str (rctx .path (rctx .attr ._script ).dirname .dirname )]
26- + [
27- str (rctx .path (Label ("@" + repo + "//:BUILD.bazel" )).dirname )
28- for repo in all_requirements
29- ]
30- )
32+ "PYTHONPATH" : pypath
3133 },
3234 )
3335 if result .return_code :
You can’t perform that action at this time.
0 commit comments