【发布时间】:2017-10-28 03:54:51
【问题描述】:
我在尝试使用 new_http_archive 规则获取请求时收到“ImportError: No module named requests”错误。
工作空间:
new_http_archive(
name = "requests",
urls = ["https://github.com/requests/requests/tarball/master/requests-requests-v2.18.4-90-g81b6341.tar.gz"],
build_file_content = """
py_library(
name = "srcs",
srcs = glob(["requests/*.py"]),
visibility = ["//visibility:public"]
)"""
)
构建:
py_library(
name = "foo",
deps = ["@requests//:srcs"],
srcs = glob(["foo.py",]),
)
py_test(
name = "foo_test",
srcs = glob(["foo_test.py",]),
deps = glob([":foo",]),
)
如果我在 new_http_archive 规则中使用 'srcs = glob(["*"])',我会收到关于丢失 .py 文件的各种错误(这很有意义 - 请求存储库中有各种文件)
我的问题是,如何指定 build_file_content 以提供一个工作请求库? (此时我不确定我是否使用了正确的 url,以及 build_file_content 的正确规则) 我只想能够使用 Bazel 运行我的 python 代码,并让 Bazel 管理提供请求库。
【问题讨论】:
标签: python python-requests bazel