Brian Silverman | 3fca9d7 | 2016-02-20 02:32:51 -0500 | [diff] [blame^] | 1 | # This repository is used to create helper __init__.py files which import things |
| 2 | # under third_party at the root of the Python import namespace instead of |
| 3 | # requiring third_party.xyz. in front of them. |
| 4 | |
| 5 | genrule( |
| 6 | name = 'google_protobuf_importer_init', |
| 7 | outs = ['google/__init__.py'], |
| 8 | cmd = 'echo "%s" > $@' % '\n'.join([ |
| 9 | 'import sys', |
| 10 | 'import third_party.protobuf.google.protobuf', |
| 11 | 'sys.modules[\'google.protobuf\'] = third_party.protobuf.google.protobuf', |
| 12 | ]), |
| 13 | ) |
| 14 | |
| 15 | py_library( |
| 16 | name = 'google_protobuf_importer', |
| 17 | visibility = ['//visibility:public'], |
| 18 | srcs = [':google_protobuf_importer_init'], |
| 19 | ) |