{"action":"created","issue":{"url":"https://api.github.com/repos/protocolbuffers/protobuf/issues/1491","repository_url":"https://api.github.com/repos/protocolbuffers/protobuf","labels_url":"https://api.github.com/repos/protocolbuffers/protobuf/issues/1491/labels{/name}","comments_url":"https://api.github.com/repos/protocolbuffers/protobuf/issues/1491/comments","events_url":"https://api.github.com/repos/protocolbuffers/protobuf/issues/1491/events","html_url":"https://github.com/protocolbuffers/protobuf/issues/1491","id":153287065,"node_id":"MDU6SXNzdWUxNTMyODcwNjU=","number":1491,"title":"python: use relative imports in generated modules","user":{"login":"little-dude","id":6646324,"node_id":"MDQ6VXNlcjY2NDYzMjQ=","avatar_url":"https://avatars2.githubusercontent.com/u/6646324?v=4","gravatar_id":"","url":"https://api.github.com/users/little-dude","html_url":"https://github.com/little-dude","followers_url":"https://api.github.com/users/little-dude/followers","following_url":"https://api.github.com/users/little-dude/following{/other_user}","gists_url":"https://api.github.com/users/little-dude/gists{/gist_id}","starred_url":"https://api.github.com/users/little-dude/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/little-dude/subscriptions","organizations_url":"https://api.github.com/users/little-dude/orgs","repos_url":"https://api.github.com/users/little-dude/repos","events_url":"https://api.github.com/users/little-dude/events{/privacy}","received_events_url":"https://api.github.com/users/little-dude/received_events","type":"User","site_admin":false},"labels":[{"id":250677130,"node_id":"MDU6TGFiZWwyNTA2NzcxMzA=","url":"https://api.github.com/repos/protocolbuffers/protobuf/labels/python","name":"python","color":"d4c5f9","default":false}],"state":"closed","locked":false,"assignee":{"login":"haberman","id":1270,"node_id":"MDQ6VXNlcjEyNzA=","avatar_url":"https://avatars2.githubusercontent.com/u/1270?v=4","gravatar_id":"","url":"https://api.github.com/users/haberman","html_url":"https://github.com/haberman","followers_url":"https://api.github.com/users/haberman/followers","following_url":"https://api.github.com/users/haberman/following{/other_user}","gists_url":"https://api.github.com/users/haberman/gists{/gist_id}","starred_url":"https://api.github.com/users/haberman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haberman/subscriptions","organizations_url":"https://api.github.com/users/haberman/orgs","repos_url":"https://api.github.com/users/haberman/repos","events_url":"https://api.github.com/users/haberman/events{/privacy}","received_events_url":"https://api.github.com/users/haberman/received_events","type":"User","site_admin":false},"assignees":[{"login":"haberman","id":1270,"node_id":"MDQ6VXNlcjEyNzA=","avatar_url":"https://avatars2.githubusercontent.com/u/1270?v=4","gravatar_id":"","url":"https://api.github.com/users/haberman","html_url":"https://github.com/haberman","followers_url":"https://api.github.com/users/haberman/followers","following_url":"https://api.github.com/users/haberman/following{/other_user}","gists_url":"https://api.github.com/users/haberman/gists{/gist_id}","starred_url":"https://api.github.com/users/haberman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haberman/subscriptions","organizations_url":"https://api.github.com/users/haberman/orgs","repos_url":"https://api.github.com/users/haberman/repos","events_url":"https://api.github.com/users/haberman/events{/privacy}","received_events_url":"https://api.github.com/users/haberman/received_events","type":"User","site_admin":false}],"milestone":null,"comments":43,"created_at":"2016-05-05T17:57:42Z","updated_at":"2018-11-12T20:03:59Z","closed_at":"2017-03-16T23:13:44Z","author_association":"NONE","body":"I have a package `foo` that looks like this:\n\n```\n.\n├── data\n│   ├── a.proto\n│   └── b.proto\n└── generated\n    ├── a_pb2.py\n    ├── b_pb2.py\n    └── __init__.py\n```\n\n```\n# a.proto\npackage foo;\n```\n\n```\n# b.proto\nimport \"a.proto\";\n\npackage foo;\n```\n\nGenerate the code: `protoc -I ./data --python_out=generated data/a.proto data/b.proto`.\nHere is the failure:\n\n```\nPython 3.5.1 (default, Mar  3 2016, 09:29:07) \n[GCC 5.3.0] on linux\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n>>> from generated import b_pb2\nTraceback (most recent call last):\n  File \"<stdin>\", line 1, in <module>\n  File \"/home/corentih/repro/generated/b_pb2.py\", line 16, in <module>\n    import a_pb2\nImportError: No module named 'a_pb2'\n```\n\nThis is beacuse the generated code looks like this:\n\n```\nimport a_pb2\n```\n\nIf the import was relative it would actually work:\n\n```\nfrom . import a_pb2\n```\n"},"comment":{"url":"https://api.github.com/repos/protocolbuffers/protobuf/issues/comments/438011036","html_url":"https://github.com/protocolbuffers/protobuf/issues/1491#issuecomment-438011036","issue_url":"https://api.github.com/repos/protocolbuffers/protobuf/issues/1491","id":438011036,"node_id":"MDEyOklzc3VlQ29tbWVudDQzODAxMTAzNg==","user":{"login":"kunalspathak","id":12488060,"node_id":"MDQ6VXNlcjEyNDg4MDYw","avatar_url":"https://avatars0.githubusercontent.com/u/12488060?v=4","gravatar_id":"","url":"https://api.github.com/users/kunalspathak","html_url":"https://github.com/kunalspathak","followers_url":"https://api.github.com/users/kunalspathak/followers","following_url":"https://api.github.com/users/kunalspathak/following{/other_user}","gists_url":"https://api.github.com/users/kunalspathak/gists{/gist_id}","starred_url":"https://api.github.com/users/kunalspathak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kunalspathak/subscriptions","organizations_url":"https://api.github.com/users/kunalspathak/orgs","repos_url":"https://api.github.com/users/kunalspathak/repos","events_url":"https://api.github.com/users/kunalspathak/events{/privacy}","received_events_url":"https://api.github.com/users/kunalspathak/received_events","type":"User","site_admin":false},"created_at":"2018-11-12T20:03:59Z","updated_at":"2018-11-12T20:03:59Z","author_association":"NONE","body":"I can't even use the suggested hack because I have multiple projects for which I have to generate python files using `protoc`. Some of the message name/hierarchy might be same. If I import python files related to 1st project, the hack will add the python files location to `PYTHONPATH`. If I want to import python files related to 2nd project, the hack will add its path before the previous path and thus make discoverability of python files from 1st project problematic. "}}
{"actor":{"display_login":"kunalspathak"}}