{"action":"opened","issue":{"url":"https://api.github.com/repos/bazelbuild/bazel/issues/1196","repository_url":"https://api.github.com/repos/bazelbuild/bazel","labels_url":"https://api.github.com/repos/bazelbuild/bazel/issues/1196/labels{/name}","comments_url":"https://api.github.com/repos/bazelbuild/bazel/issues/1196/comments","events_url":"https://api.github.com/repos/bazelbuild/bazel/issues/1196/events","html_url":"https://github.com/bazelbuild/bazel/issues/1196","id":151012408,"number":1196,"title":"py_binary doesn't generate __init__.py file for workspace directory","user":{"login":"eldenseropian","id":2855180,"avatar_url":"https://avatars.githubusercontent.com/u/2855180?v=3","gravatar_id":"","url":"https://api.github.com/users/eldenseropian","html_url":"https://github.com/eldenseropian","followers_url":"https://api.github.com/users/eldenseropian/followers","following_url":"https://api.github.com/users/eldenseropian/following{/other_user}","gists_url":"https://api.github.com/users/eldenseropian/gists{/gist_id}","starred_url":"https://api.github.com/users/eldenseropian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eldenseropian/subscriptions","organizations_url":"https://api.github.com/users/eldenseropian/orgs","repos_url":"https://api.github.com/users/eldenseropian/repos","events_url":"https://api.github.com/users/eldenseropian/events{/privacy}","received_events_url":"https://api.github.com/users/eldenseropian/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-04-26T00:23:39Z","updated_at":"2016-04-26T00:23:39Z","closed_at":null,"body":"With this py_binary rule\r\n```\r\npy_binary(\r\n    name = \"kubectl_wrapper\",\r\n    srcs = [\r\n        \"kubectl_wrapper.py\"\r\n    ],\r\n    deps = [\r\n        \"//asana/server/kinesis:kinesis\",\r\n        \"//asana/server/kubernetes/tools:cloudformation\",\r\n    ]\r\n)\r\n```\r\nThe following is generated:\r\n```\r\n├── kubectl_wrapper.runfiles\r\n│   ├── MANIFEST\r\n│   └── asana2\r\n│       └── asana\r\n│           ├── __init__.py\r\n│           └── server\r\n│               ├── __init__.py\r\n│               ├── kinesis\r\n│               │   ├── __init__.py\r\n│               │   └── kinesis_helpers.py -> /Users/eldenseropian/sandbox/asana/asana2/asana/server/kinesis/kinesis_helpers.py\r\n│               ├── kubernetes\r\n│               │   ├── __init__.py\r\n│               │   ├── kubectl_wrapper -> /private/var/tmp/_bazel_eldenseropian/bab516a5c80085ba67cbbefbf571eae7/asana2/bazel-out/local_darwin-fastbuild/bin/asana/server/kubernetes/kubectl_wrapper\r\n│               │   ├── kubectl_wrapper.py -> /Users/eldenseropian/sandbox/asana/asana2/asana/server/kubernetes/kubectl_wrapper.py\r\n│               │   └── tools\r\n│               │       ├── __init__.py\r\n│               │       └── cloudformation_helpers.py -> /Users/eldenseropian/sandbox/asana/asana2/asana/server/kubernetes/tools/cloudformation_helpers.py\r\n│               └── utils\r\n│                   ├── __init__.py\r\n│                   └── common.py -> /Users/eldenseropian/sandbox/asana/asana2/asana/server/utils/common.py\r\n```\r\n\r\nHowever, we need an `__init__.py` under `asana2` in order for our imports to work correctly. We import things from this workspace both within and outside of the workspace.\r\n\r\nNote for anyone else with this problem:\r\n\r\nWe're currently getting around it by having a library in the root of our workspace depend on the `__init__.py` there:\r\n\r\n```\r\npy_library(\r\n    name = \"init\",\r\n    srcs = [\"__init__.py\"]\r\n)\r\n```\r\nbut this requires depending on this library in all entry points to our application."}}