Skip to content

Commit

Permalink
Fix for the google namespace package on python2
Browse files Browse the repository at this point in the history
we have to set the pep517 isolated build directory as the site dir for the google .pth file to work and find the nested protobuf package
  • Loading branch information
chadrik committed Jan 17, 2020
1 parent 80aaa37 commit ed06bf1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions sdks/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,14 @@ def generate_urn_files(log, out_dir):
This is executed at build time rather than dynamically on import to ensure
that it is compatible with static type checkers like mypy.
"""
if sys.version_info[0] == 2:
# this is a hack to make the google namespace package work on python2
import site
for path in sys.path:
if 'pep517-build-env' in path:
site.addsitedir(path)
break

import google.protobuf.message as message
import google.protobuf.pyext._message as pyext_message

Expand Down

0 comments on commit ed06bf1

Please sign in to comment.