bazel_rules_pex
bazel_rules_pex copied to clipboard
req_files only work when files is included in data attributes
Tried this
filegroup(
name = "requirements",
srcs = [
"requirements.txt",
],
)
pex_pytest(
name = "default_test",
srcs = glob(["**/*.py"]),
deps = [
":default_library",
],
req_files = [
":requirements",
],
)
And it fails with
File "/Users/mouad/.cache/bazel/_bazel_mouad/bazel-sandbox/8258116086626091877/execroot/__main__/.pex/install/pex_wrapper-0.1-py2-none-any.whl.213146efb1c3b3423224a6d8dabeba348a129f7e/pex_wrapper-0.1-py2-none-any.whl/pex_wrapper.py", line 131, in <module>
main()
File "/Users/mouad/.cache/bazel/_bazel_mouad/bazel-sandbox/8258116086626091877/execroot/__main__/.pex/install/pex_wrapper-0.1-py2-none-any.whl.213146efb1c3b3423224a6d8dabeba348a129f7e/pex_wrapper-0.1-py2-none-any.whl/pex_wrapper.py", line 85, in main
resolver_options_builder)
File "/Users/mouad/.cache/bazel/_bazel_mouad/bazel-sandbox/8258116086626091877/execroot/__main__/.pex/install/pex-1.2.9-py2.py3-none-any.whl.5c6ee6196c29e6a1d0cc5e5b4d54bb3369c2b93f/pex-1.2.9-py2.py3-none-any.whl/pex/bin/pex.py", line 528, in build_pex
resolvables.extend(requirements_from_file(requirements_txt, resolver_option_builder))
File "/Users/mouad/.cache/bazel/_bazel_mouad/bazel-sandbox/8258116086626091877/execroot/__main__/.pex/install/pex-1.2.9-py2.py3-none-any.whl.5c6ee6196c29e6a1d0cc5e5b4d54bb3369c2b93f/pex-1.2.9-py2.py3-none-any.whl/pex/requirements.py", line 97, in requirements_from_file
with open(filename, 'r') as fp:
IOError: [Errno 2] No such file or directory: 'services/delivery/requirements.txt'
After a bit of debugging, I found out that my requirements.txt is not actually in the folder /Users/mouad/.cache/bazel/_bazel_mouad/execroot/__main__/services/delivery
, but then when I changed the target to:
pex_pytest(
name = "default_test",
srcs = glob(["**/*.py"]),
deps = [
":default_library",
],
req_files = [
":requirements",
],
data = [
":requirements",
],
)
It worked!
Is this by design or I am missing something?
You have probably found a bug! I think this will be fairly easy to fix.