Skip to content

py_library import path is wrong for certain pypi packages (like tensorflow) #189

@WesleyYue

Description

@WesleyYue

Inside where the py_library() is generated for each specified requirement, the import path is specified as "." (https://github.com/bazelbuild/rules_python/blob/master/rules_python/whl.py#L149). While this works for most packages, not all packages have the python module in the top level of the whl. For example, the tensorflow python module is inside tensorfow-<version_info>.whl/tensorfow-<version_info>.data/purelib/tensorflow. Because of this, import tensorflow will fail in a py_binary that has requirement("tensorflow"). What I believe rules_python/whl.py should be doing is to check whether the top-level folders have an __init__.py file inside of them, and if not, search the directory tree until it finds them.

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