benley / bazel_rules_pex

Python PEX rules for Bazel
Apache License 2.0
39 stars 36 forks source link

"Relative module names" when importing pex_binary from a bazel git_repository #33

Open kyessenov opened 7 years ago

kyessenov commented 7 years ago

Here is what I have in my build file:

pex_binary(
name = "example",
srcs = [
    "@tools//start_esp:fetch_service_config.py",
    "@tools//start_esp:start_esp.py",
],
main = "@tools//start_esp:start_esp.py",
reqs = [
    "certifi",
    "mako>=1.0.4",
    "oauth2client>=3.0.0",
    "pyasn1>=0.1.9",
    "pyasn1-modules>=0.0.8",
    "urllib3>=1.16",
],
)

@tools is an externa repository. Trying to run this gives me an error:

Traceback (most recent call last): File ".bootstrap/_pex/pex.py", line 326, in execute File ".bootstrap/_pex/pex.py", line 258, in _wrap_coverage File ".bootstrap/_pex/pex.py", line 290, in _wrap_profiling File ".bootstrap/_pex/pex.py", line 369, in _execute File ".bootstrap/_pex/pex.py", line 427, in execute_entry File ".bootstrap/_pex/pex.py", line 432, in execute_module File "/usr/lib/python2.7/runpy.py", line 170, in run_module mod_name, loader, code, fname = _get_module_details(mod_name) File "/usr/lib/python2.7/runpy.py", line 101, in _get_module_details loader = get_loader(mod_name) File "/usr/lib/python2.7/pkgutil.py", line 464, in get_loader return find_loader(fullname) File "/usr/lib/python2.7/pkgutil.py", line 474, in find_loader for importer in iter_importers(fullname): File "/usr/lib/python2.7/pkgutil.py", line 425, in iter_importers raise ImportError("Relative module names not supported") ImportError: Relative module names not supported

benley commented 7 years ago

Thank you for the bug report, and sorry for the slow response here! I'm just getting back from vacation. This is something I've run into as well and would like to fix.

kyessenov commented 7 years ago

You're welcome! Let me know if I can help with more context. For now, as a workaround, I'm copying the rule and the sources to the target repository with genrule.