Generator: default to PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (#787)

This works around compatibility problems between protoc vs. python-protobuf versions.
diff --git a/generator/nanopb_generator.py b/generator/nanopb_generator.py
index fc4f93d..f6025e9 100755
--- a/generator/nanopb_generator.py
+++ b/generator/nanopb_generator.py
@@ -16,6 +16,13 @@
 import os
 from functools import reduce
 
+# Python-protobuf breaks easily with protoc version differences if
+# using the cpp or upb implementation. Force it to use pure Python
+# implementation. Performance is not very important in the generator.
+if not os.getenv("PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"):
+    os.putenv("PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION", "python")
+    os.environ["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"] = "python"
+
 try:
     # Add some dummy imports to keep packaging tools happy.
     import google # bbfreeze seems to need these