Blizzard / s2client-proto

StarCraft II Client - protocol definitions used to communicate with StarCraft II.
MIT License
3.76k stars 431 forks source link

Fix imports to work in python3 #26

Closed tewalds closed 6 years ago

tewalds commented 6 years ago

I don't see a way to get python3 to import the other compiled proto files without actually changing the imports in the proto themselves. Changing --proto_path only changes where protoc searches, not where python searches. Changing --python_out only changes where it's output, still not where python searches. That leaves either editing the files by hand, or changing the imports. I guess that might mean fixing some c++ imports somewhere as well.

tewalds commented 6 years ago

Btw, the way to test this is:

setup a fresh python3 env: $ virtualenv -p python3 /tmp/py3 $ source /tmp/py3/bin/activate

verify the code: s2client-proto$ ./setup.py build s2client-proto$ less s2clientprotocol/sc2api_pb2.py and verify that the imports are "from s2clientprotocol import ..."

verify it works: s2client-proto$ pip install --upgrade . $ python >>> from s2clientprotocol import sc2api should succeed, not say import error