From ad54adfc8152d8aa25e0351c9e69365186b952ae Mon Sep 17 00:00:00 2001 From: vam-google Date: Sun, 31 Jan 2021 02:57:28 -0800 Subject: [PATCH] fix: Fix namespace packages conflict issue This fixes the https://github.com/googleapis/gapic-generator/issues/3334 by excluding system-wide site-packages dir from python packages resolution path completely. This pretty much implements the long-standing featrue request for rules_python https://github.com/bazelbuild/bazel/issues/4939, but only in scope of gapic-generator-python. --- gapic/cli/generate_with_pandoc.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/gapic/cli/generate_with_pandoc.py b/gapic/cli/generate_with_pandoc.py index 264d1c8b0b..533701b86a 100644 --- a/gapic/cli/generate_with_pandoc.py +++ b/gapic/cli/generate_with_pandoc.py @@ -1,9 +1,14 @@ import os - -from gapic.cli import generate +import sys if __name__ == '__main__': os.environ['PYPANDOC_PANDOC'] = os.path.join( - os.path.abspath(__file__).rsplit("gapic", 1)[0], "pandoc") + os.path.abspath(__file__).rsplit("gapic", 1)[0], "pandoc") os.environ['LC_ALL'] = 'C.UTF-8' - generate.generate() + os.environ['PYTHONNOUSERSITE'] = 'True' + + entry_point_script = os.path.join( + os.path.dirname(os.path.abspath(__file__)), "generate.py") + args = [sys.executable, entry_point_script] + sys.argv[1:] + + os.execv(args[0], args)