Skip to content

requirement on mock can't install dependency #60

@4ZM

Description

@4ZM

On Linux with Python 2.7, adding a requirement("mock") to a py_test target (and possibly other targets) breaks like so:

INFO: Running command line: .bazel/bin/toolchain/generate_crosstool_test
Traceback (most recent call last):
  File "/tmp/bazel/out/db099189d67c0d8a/faedb999bdce730c9c495251de1ca1a4/execroot/__main__/bazel-out/k8-fastbuild/bin/toolchain/generate_crosstool_test.runfiles/__main__/toolchain/generate_crosstool_test.py", line 2, in <module>
    import mock
  File "/tmp/bazel/out/db099189d67c0d8a/faedb999bdce730c9c495251de1ca1a4/execroot/__main__/bazel-out/k8-fastbuild/bin/toolchain/generate_crosstool_test.runfiles/pypi__mock_2_0_0/mock/__init__.py", line 2, in <module>
    import mock.mock as _mock
  File "/tmp/bazel/out/db099189d67c0d8a/faedb999bdce730c9c495251de1ca1a4/execroot/__main__/bazel-out/k8-fastbuild/bin/toolchain/generate_crosstool_test.runfiles/pypi__mock_2_0_0/mock/mock.py", line 80, in <module>
    import funcsigs
ImportError: No module named funcsigs
ERROR: Non-zero return code '1' from command: Process exited with status 1

The mock library has a dependency on funcsigs. It gets installed automatically if you pip install mock For some reason this transitive dependency breaks in the bazel world.

A workaround is to add funcsigs explicitly to the requirements.txt and also as a requirement("funcsigs") to the py_test target. Then everything works fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions