Renamed google.protobuf to protobuf26

R=pgervais@chromium.org

Review URL: https://codereview.chromium.org/1162993005

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@295512 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/commit_queue.py b/commit_queue.py
index 6f08b2e..91cb28e 100755
--- a/commit_queue.py
+++ b/commit_queue.py
@@ -26,7 +26,7 @@
 sys.path.insert(0, THIRD_PARTY_DIR)
 
 from cq_client import cq_pb2
-from google.protobuf import text_format
+from protobuf26 import text_format
 
 def usage(more):
   def hook(fn):
diff --git a/third_party/cq_client/cq_pb2.py b/third_party/cq_client/cq_pb2.py
index 68c7e8c..ecfe9cf 100644
--- a/third_party/cq_client/cq_pb2.py
+++ b/third_party/cq_client/cq_pb2.py
@@ -1,13 +1,22 @@
+# This file was originally generated by the protocol buffer compiler 2.6.1, but
+# was subsequently manually edited to import protobuf26 instead of
+# google.protobuf. If you need to re-generate this file, please make similar
+# changes again and add this comment back. More details on why we chose to
+# rename the package can be found in the file
+#   depot_tools/third_party/protobuf26/README.chromium
+# Example CL updating the references:
+#   https://codereview.chromium.org/1162993005/
+
 # Generated by the protocol buffer compiler.  DO NOT EDIT!
 # source: cq.proto
 
 import sys
 _b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
-from google.protobuf import descriptor as _descriptor
-from google.protobuf import message as _message
-from google.protobuf import reflection as _reflection
-from google.protobuf import symbol_database as _symbol_database
-from google.protobuf import descriptor_pb2
+from protobuf26 import descriptor as _descriptor
+from protobuf26 import message as _message
+from protobuf26 import reflection as _reflection
+from protobuf26 import symbol_database as _symbol_database
+from protobuf26 import descriptor_pb2
 # @@protoc_insertion_point(imports)
 
 _sym_db = _symbol_database.Default()
diff --git a/third_party/google/__init__.py b/third_party/google/__init__.py
deleted file mode 100644
index de40ea7..0000000
--- a/third_party/google/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-__import__('pkg_resources').declare_namespace(__name__)
diff --git a/third_party/google/protobuf/README.chromium b/third_party/google/protobuf/README.chromium
deleted file mode 100644
index 12b8af2..0000000
--- a/third_party/google/protobuf/README.chromium
+++ /dev/null
@@ -1 +0,0 @@
-This directory contains google.protobuf module version 2.6.0 build 0.
diff --git a/third_party/protobuf26/README.chromium b/third_party/protobuf26/README.chromium
new file mode 100644
index 0000000..35df332
--- /dev/null
+++ b/third_party/protobuf26/README.chromium
@@ -0,0 +1,20 @@
+This directory contains google.protobuf module version 2.6.0 build 0.
+
+sergiyb@: It has been manually renamed to protobuf26. This is needed to avoid
+conflicts with a built-in google.protobuf module found on many developer
+machines. The long-term solution to this problem, however, should be virtualenv.
+Unfortunately due to limited time and lack of experience, it was not a
+reasonable short-term solution.
+
+If you need to update this package, please make sure that you replace all
+the references to google.protobuf in the package itself with protobuf26, e.g.
+
+  from google.protobuf import text_format
+  import google.protobuf
+
+becomes
+
+  from protobuf26 import text_format
+  import protobuf26
+
+Bug tracking setting up virtualenv for depot_tools is https://crbug.com/496241.
diff --git a/third_party/google/protobuf/__init__.py b/third_party/protobuf26/__init__.py
similarity index 100%
rename from third_party/google/protobuf/__init__.py
rename to third_party/protobuf26/__init__.py
diff --git a/third_party/google/protobuf/compiler/__init__.py b/third_party/protobuf26/compiler/__init__.py
similarity index 100%
rename from third_party/google/protobuf/compiler/__init__.py
rename to third_party/protobuf26/compiler/__init__.py
diff --git a/third_party/google/protobuf/compiler/plugin_pb2.py b/third_party/protobuf26/compiler/plugin_pb2.py
similarity index 95%
rename from third_party/google/protobuf/compiler/plugin_pb2.py
rename to third_party/protobuf26/compiler/plugin_pb2.py
index 20ab06d..806241d 100644
--- a/third_party/google/protobuf/compiler/plugin_pb2.py
+++ b/third_party/protobuf26/compiler/plugin_pb2.py
@@ -3,17 +3,17 @@
 
 import sys
 _b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
-from google.protobuf import descriptor as _descriptor
-from google.protobuf import message as _message
-from google.protobuf import reflection as _reflection
-from google.protobuf import symbol_database as _symbol_database
-from google.protobuf import descriptor_pb2
+from protobuf26 import descriptor as _descriptor
+from protobuf26 import message as _message
+from protobuf26 import reflection as _reflection
+from protobuf26 import symbol_database as _symbol_database
+from protobuf26 import descriptor_pb2
 # @@protoc_insertion_point(imports)
 
 _sym_db = _symbol_database.Default()
 
 
-import google.protobuf.descriptor_pb2
+import protobuf26.descriptor_pb2
 
 
 DESCRIPTOR = _descriptor.FileDescriptor(
diff --git a/third_party/google/protobuf/descriptor.py b/third_party/protobuf26/descriptor.py
similarity index 98%
rename from third_party/google/protobuf/descriptor.py
rename to third_party/protobuf26/descriptor.py
index 555498d..109a09d 100644
--- a/third_party/google/protobuf/descriptor.py
+++ b/third_party/protobuf26/descriptor.py
@@ -38,7 +38,7 @@
 
 __author__ = 'robinson@google.com (Will Robinson)'
 
-from google.protobuf.internal import api_implementation
+from protobuf26.internal import api_implementation
 
 
 if api_implementation.Type() == 'cpp':
@@ -47,9 +47,9 @@
   import uuid
 
   if api_implementation.Version() == 2:
-    from google.protobuf.pyext import _message
+    from protobuf26.pyext import _message
   else:
-    from google.protobuf.internal import cpp_message
+    from protobuf26.internal import cpp_message
 
 
 class Error(Exception):
@@ -106,7 +106,7 @@
     """
     if self._options:
       return self._options
-    from google.protobuf import descriptor_pb2
+    from protobuf26 import descriptor_pb2
     try:
       options_class = getattr(descriptor_pb2, self._options_class_name)
     except AttributeError:
@@ -774,7 +774,7 @@
     # definition in the C++ descriptor pool. To do this, we build a
     # FileDescriptorProto with the same definition as this descriptor and build
     # it into the pool.
-    from google.protobuf import descriptor_pb2
+    from protobuf26 import descriptor_pb2
     file_descriptor_proto = descriptor_pb2.FileDescriptorProto()
     file_descriptor_proto.message_type.add().MergeFrom(desc_proto)
 
diff --git a/third_party/google/protobuf/descriptor_database.py b/third_party/protobuf26/descriptor_database.py
similarity index 100%
rename from third_party/google/protobuf/descriptor_database.py
rename to third_party/protobuf26/descriptor_database.py
diff --git a/third_party/google/protobuf/descriptor_pb2.py b/third_party/protobuf26/descriptor_pb2.py
similarity index 99%
rename from third_party/google/protobuf/descriptor_pb2.py
rename to third_party/protobuf26/descriptor_pb2.py
index 808fd17..ae81b36 100644
--- a/third_party/google/protobuf/descriptor_pb2.py
+++ b/third_party/protobuf26/descriptor_pb2.py
@@ -3,10 +3,10 @@
 
 import sys
 _b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
-from google.protobuf import descriptor as _descriptor
-from google.protobuf import message as _message
-from google.protobuf import reflection as _reflection
-from google.protobuf import symbol_database as _symbol_database
+from protobuf26 import descriptor as _descriptor
+from protobuf26 import message as _message
+from protobuf26 import reflection as _reflection
+from protobuf26 import symbol_database as _symbol_database
 # @@protoc_insertion_point(imports)
 
 _sym_db = _symbol_database.Default()
diff --git a/third_party/google/protobuf/descriptor_pool.py b/third_party/protobuf26/descriptor_pool.py
similarity index 99%
rename from third_party/google/protobuf/descriptor_pool.py
rename to third_party/protobuf26/descriptor_pool.py
index 372f458..882fd9f 100644
--- a/third_party/google/protobuf/descriptor_pool.py
+++ b/third_party/protobuf26/descriptor_pool.py
@@ -59,9 +59,9 @@
 
 import sys
 
-from google.protobuf import descriptor
-from google.protobuf import descriptor_database
-from google.protobuf import text_encoding
+from protobuf26 import descriptor
+from protobuf26 import descriptor_database
+from protobuf26 import text_encoding
 
 
 def _NormalizeFullyQualifiedName(name):
diff --git a/third_party/google/protobuf/internal/__init__.py b/third_party/protobuf26/internal/__init__.py
similarity index 100%
rename from third_party/google/protobuf/internal/__init__.py
rename to third_party/protobuf26/internal/__init__.py
diff --git a/third_party/google/protobuf/internal/api_implementation.py b/third_party/protobuf26/internal/api_implementation.py
similarity index 98%
rename from third_party/google/protobuf/internal/api_implementation.py
rename to third_party/protobuf26/internal/api_implementation.py
index cbb8574..b5615d1 100644
--- a/third_party/google/protobuf/internal/api_implementation.py
+++ b/third_party/protobuf26/internal/api_implementation.py
@@ -36,7 +36,7 @@
 
 try:
   # pylint: disable=g-import-not-at-top
-  from google.protobuf.internal import _api_implementation
+  from protobuf26.internal import _api_implementation
   # The compile-time constants in the _api_implementation module can be used to
   # switch to a certain implementation of the Python API at build time.
   _api_version = _api_implementation.api_version
diff --git a/third_party/google/protobuf/internal/containers.py b/third_party/protobuf26/internal/containers.py
similarity index 100%
rename from third_party/google/protobuf/internal/containers.py
rename to third_party/protobuf26/internal/containers.py
diff --git a/third_party/google/protobuf/internal/cpp_message.py b/third_party/protobuf26/internal/cpp_message.py
similarity index 98%
rename from third_party/google/protobuf/internal/cpp_message.py
rename to third_party/protobuf26/internal/cpp_message.py
index 8eb38ca..1904a04 100644
--- a/third_party/google/protobuf/internal/cpp_message.py
+++ b/third_party/protobuf26/internal/cpp_message.py
@@ -36,9 +36,9 @@
 
 import copy_reg
 import operator
-from google.protobuf.internal import _net_proto2___python
-from google.protobuf.internal import enum_type_wrapper
-from google.protobuf import message
+from protobuf26.internal import _net_proto2___python
+from protobuf26.internal import enum_type_wrapper
+from protobuf26 import message
 
 
 _LABEL_REPEATED = _net_proto2___python.LABEL_REPEATED
@@ -299,7 +299,7 @@
     self._values = {}
 
   def __setitem__(self, extension, value):
-    from google.protobuf import descriptor
+    from protobuf26 import descriptor
     if not isinstance(extension, descriptor.FieldDescriptor):
       raise KeyError('Bad extension %r.' % (extension,))
     cdescriptor = extension._cdescriptor
@@ -311,7 +311,7 @@
     self._values[extension] = value
 
   def __getitem__(self, extension):
-    from google.protobuf import descriptor
+    from protobuf26 import descriptor
     if not isinstance(extension, descriptor.FieldDescriptor):
       raise KeyError('Bad extension %r.' % (extension,))
 
@@ -329,7 +329,7 @@
     return ext
 
   def ClearExtension(self, extension):
-    from google.protobuf import descriptor
+    from protobuf26 import descriptor
     if not isinstance(extension, descriptor.FieldDescriptor):
       raise KeyError('Bad extension %r.' % (extension,))
     self._cmsg.ClearFieldByDescriptor(extension._cdescriptor)
@@ -337,7 +337,7 @@
       del self._values[extension]
 
   def HasExtension(self, extension):
-    from google.protobuf import descriptor
+    from protobuf26 import descriptor
     if not isinstance(extension, descriptor.FieldDescriptor):
       raise KeyError('Bad extension %r.' % (extension,))
     return self._cmsg.HasFieldByDescriptor(extension._cdescriptor)
@@ -627,7 +627,7 @@
 
   def __unicode__(self):
     # Lazy import to prevent circular import when text_format imports this file.
-    from google.protobuf import text_format
+    from protobuf26 import text_format
     return text_format.MessageToString(self, as_utf8=True).decode('utf-8')
 
   # Attach the local methods to the message class.
diff --git a/third_party/google/protobuf/internal/decoder.py b/third_party/protobuf26/internal/decoder.py
similarity index 99%
rename from third_party/google/protobuf/internal/decoder.py
rename to third_party/protobuf26/internal/decoder.py
index 651ee0d..800f04b 100644
--- a/third_party/google/protobuf/internal/decoder.py
+++ b/third_party/protobuf26/internal/decoder.py
@@ -87,9 +87,9 @@
 import struct
 import sys  ##PY25
 _PY2 = sys.version_info[0] < 3  ##PY25
-from google.protobuf.internal import encoder
-from google.protobuf.internal import wire_format
-from google.protobuf import message
+from protobuf26.internal import encoder
+from protobuf26.internal import wire_format
+from protobuf26 import message
 
 
 # This will overflow and thus become IEEE-754 "infinity".  We would use
diff --git a/third_party/google/protobuf/internal/encoder.py b/third_party/protobuf26/internal/encoder.py
similarity index 99%
rename from third_party/google/protobuf/internal/encoder.py
rename to third_party/protobuf26/internal/encoder.py
index 0a7c041..22b1841 100644
--- a/third_party/google/protobuf/internal/encoder.py
+++ b/third_party/protobuf26/internal/encoder.py
@@ -73,7 +73,7 @@
 import struct
 import sys  ##PY25
 _PY2 = sys.version_info[0] < 3  ##PY25
-from google.protobuf.internal import wire_format
+from protobuf26.internal import wire_format
 
 
 # This will overflow and thus become IEEE-754 "infinity".  We would use
diff --git a/third_party/google/protobuf/internal/enum_type_wrapper.py b/third_party/protobuf26/internal/enum_type_wrapper.py
similarity index 100%
rename from third_party/google/protobuf/internal/enum_type_wrapper.py
rename to third_party/protobuf26/internal/enum_type_wrapper.py
diff --git a/third_party/google/protobuf/internal/message_listener.py b/third_party/protobuf26/internal/message_listener.py
similarity index 100%
rename from third_party/google/protobuf/internal/message_listener.py
rename to third_party/protobuf26/internal/message_listener.py
diff --git a/third_party/google/protobuf/internal/python_message.py b/third_party/protobuf26/internal/python_message.py
similarity index 98%
rename from third_party/google/protobuf/internal/python_message.py
rename to third_party/protobuf26/internal/python_message.py
index 9ee352d..bbd0ea5 100644
--- a/third_party/google/protobuf/internal/python_message.py
+++ b/third_party/protobuf26/internal/python_message.py
@@ -68,16 +68,16 @@
 import weakref
 
 # We use "as" to avoid name collisions with variables.
-from google.protobuf.internal import containers
-from google.protobuf.internal import decoder
-from google.protobuf.internal import encoder
-from google.protobuf.internal import enum_type_wrapper
-from google.protobuf.internal import message_listener as message_listener_mod
-from google.protobuf.internal import type_checkers
-from google.protobuf.internal import wire_format
-from google.protobuf import descriptor as descriptor_mod
-from google.protobuf import message as message_mod
-from google.protobuf import text_format
+from protobuf26.internal import containers
+from protobuf26.internal import decoder
+from protobuf26.internal import encoder
+from protobuf26.internal import enum_type_wrapper
+from protobuf26.internal import message_listener as message_listener_mod
+from protobuf26.internal import type_checkers
+from protobuf26.internal import wire_format
+from protobuf26 import descriptor as descriptor_mod
+from protobuf26 import message as message_mod
+from protobuf26 import text_format
 
 _FieldDescriptor = descriptor_mod.FieldDescriptor
 
diff --git a/third_party/google/protobuf/internal/type_checkers.py b/third_party/protobuf26/internal/type_checkers.py
similarity index 97%
rename from third_party/google/protobuf/internal/type_checkers.py
rename to third_party/protobuf26/internal/type_checkers.py
index 8e1b3cc..779c09c 100644
--- a/third_party/google/protobuf/internal/type_checkers.py
+++ b/third_party/protobuf26/internal/type_checkers.py
@@ -51,11 +51,11 @@
 
 import sys  ##PY25
 if sys.version < '2.6': bytes = str  ##PY25
-from google.protobuf.internal import api_implementation
-from google.protobuf.internal import decoder
-from google.protobuf.internal import encoder
-from google.protobuf.internal import wire_format
-from google.protobuf import descriptor
+from protobuf26.internal import api_implementation
+from protobuf26.internal import decoder
+from protobuf26.internal import encoder
+from protobuf26.internal import wire_format
+from protobuf26 import descriptor
 
 _FieldDescriptor = descriptor.FieldDescriptor
 
diff --git a/third_party/google/protobuf/internal/wire_format.py b/third_party/protobuf26/internal/wire_format.py
similarity index 98%
rename from third_party/google/protobuf/internal/wire_format.py
rename to third_party/protobuf26/internal/wire_format.py
index c941fe1..29961fd 100644
--- a/third_party/google/protobuf/internal/wire_format.py
+++ b/third_party/protobuf26/internal/wire_format.py
@@ -33,8 +33,8 @@
 __author__ = 'robinson@google.com (Will Robinson)'
 
 import struct
-from google.protobuf import descriptor
-from google.protobuf import message
+from protobuf26 import descriptor
+from protobuf26 import message
 
 
 TAG_TYPE_BITS = 3  # Number of bits used to hold type info in a proto tag.
diff --git a/third_party/google/protobuf/message.py b/third_party/protobuf26/message.py
similarity index 100%
rename from third_party/google/protobuf/message.py
rename to third_party/protobuf26/message.py
diff --git a/third_party/google/protobuf/message_factory.py b/third_party/protobuf26/message_factory.py
similarity index 96%
rename from third_party/google/protobuf/message_factory.py
rename to third_party/protobuf26/message_factory.py
index 9004ffd..a8d63f7 100644
--- a/third_party/google/protobuf/message_factory.py
+++ b/third_party/protobuf26/message_factory.py
@@ -44,10 +44,10 @@
 __author__ = 'matthewtoia@google.com (Matt Toia)'
 
 import sys  ##PY25
-from google.protobuf import descriptor_database
-from google.protobuf import descriptor_pool
-from google.protobuf import message
-from google.protobuf import reflection
+from protobuf26 import descriptor_database
+from protobuf26 import descriptor_pool
+from protobuf26 import message
+from protobuf26 import reflection
 
 
 class MessageFactory(object):
diff --git a/third_party/google/protobuf/reflection.py b/third_party/protobuf26/reflection.py
similarity index 95%
rename from third_party/google/protobuf/reflection.py
rename to third_party/protobuf26/reflection.py
index 7aac623..673348c 100644
--- a/third_party/google/protobuf/reflection.py
+++ b/third_party/protobuf26/reflection.py
@@ -48,24 +48,24 @@
 __author__ = 'robinson@google.com (Will Robinson)'
 
 
-from google.protobuf.internal import api_implementation
-from google.protobuf import descriptor as descriptor_mod
-from google.protobuf import message
+from protobuf26.internal import api_implementation
+from protobuf26 import descriptor as descriptor_mod
+from protobuf26 import message
 
 _FieldDescriptor = descriptor_mod.FieldDescriptor
 
 
 if api_implementation.Type() == 'cpp':
   if api_implementation.Version() == 2:
-    from google.protobuf.pyext import cpp_message
+    from protobuf26.pyext import cpp_message
     _NewMessage = cpp_message.NewMessage
     _InitMessage = cpp_message.InitMessage
   else:
-    from google.protobuf.internal import cpp_message
+    from protobuf26.internal import cpp_message
     _NewMessage = cpp_message.NewMessage
     _InitMessage = cpp_message.InitMessage
 else:
-  from google.protobuf.internal import python_message
+  from protobuf26.internal import python_message
   _NewMessage = python_message.NewMessage
   _InitMessage = python_message.InitMessage
 
diff --git a/third_party/google/protobuf/service.py b/third_party/protobuf26/service.py
similarity index 100%
rename from third_party/google/protobuf/service.py
rename to third_party/protobuf26/service.py
diff --git a/third_party/google/protobuf/service_reflection.py b/third_party/protobuf26/service_reflection.py
similarity index 100%
rename from third_party/google/protobuf/service_reflection.py
rename to third_party/protobuf26/service_reflection.py
diff --git a/third_party/google/protobuf/symbol_database.py b/third_party/protobuf26/symbol_database.py
similarity index 98%
rename from third_party/google/protobuf/symbol_database.py
rename to third_party/protobuf26/symbol_database.py
index 7466fec..bb586bd 100644
--- a/third_party/google/protobuf/symbol_database.py
+++ b/third_party/protobuf26/symbol_database.py
@@ -60,7 +60,7 @@
 """
 
 
-from google.protobuf import descriptor_pool
+from protobuf26 import descriptor_pool
 
 
 class SymbolDatabase(object):
diff --git a/third_party/google/protobuf/text_encoding.py b/third_party/protobuf26/text_encoding.py
similarity index 100%
rename from third_party/google/protobuf/text_encoding.py
rename to third_party/protobuf26/text_encoding.py
diff --git a/third_party/google/protobuf/text_format.py b/third_party/protobuf26/text_format.py
similarity index 99%
rename from third_party/google/protobuf/text_format.py
rename to third_party/protobuf26/text_format.py
index 50f76f2..6ef7cb9 100644
--- a/third_party/google/protobuf/text_format.py
+++ b/third_party/protobuf26/text_format.py
@@ -39,9 +39,9 @@
 import cStringIO
 import re
 
-from google.protobuf.internal import type_checkers
-from google.protobuf import descriptor
-from google.protobuf import text_encoding
+from protobuf26.internal import type_checkers
+from protobuf26 import descriptor
+from protobuf26 import text_encoding
 
 __all__ = ['MessageToString', 'PrintMessage', 'PrintField',
            'PrintFieldValue', 'Merge']