google / protorpc

Apache License 2.0
68 stars 37 forks source link

protorpc source distributions (.tar.gz) do not include subdirectories, e.g. "wsgi" #31

Open barrywhart opened 6 years ago

barrywhart commented 6 years ago

This results in errors like the following when using the App Engine "endpoints" library:

ERROR    2018-05-21 14:00:19,811 wsgi.py:263]
Traceback (most recent call last):
  File "/root/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "/root/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
    handler, path, err = LoadObject(self._handler)
  File "/root/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 85, in LoadObject
    obj = __import__(path[0])
  File "/opt/root/src/appengine-cloudsql-benchmark/main.py", line 27, in <module>
    import endpoints
  File "/opt/root/src/appengine-cloudsql-benchmark/lib/endpoints/__init__.py", line 27, in <module>
    from .apiserving import *
  File "/opt/root/src/appengine-cloudsql-benchmark/lib/endpoints/apiserving.py", line 81, in <module>
    from protorpc.wsgi import service as wsgi_service
ImportError: No module named wsgi

The solution is to do make the following change to setup.py:

diff --git a/setup.py b/setup.py
index 2c83901..0ff14c0 100644
--- a/setup.py
+++ b/setup.py
@@ -18,7 +18,7 @@

 import platform

-from setuptools import setup
+from setuptools import find_packages, setup

 # Configure the required packages and scripts to install, depending on
 # Python version and OS.
@@ -34,9 +34,6 @@ if py_version < '2.6':
   REQUIRED_PACKAGES.append('simplejson')

 _PROTORPC_VERSION = '0.12.0'
-packages = [
-    'protorpc',
-]

 setup(
     name='protorpc',
@@ -46,7 +43,7 @@ setup(
     author='Google Inc.',
     author_email='rafek@google.com',
     # Contained modules and scripts.
-    packages=packages,
+    packages=find_packages(),
     entry_points={
         'console_scripts': CONSOLE_SCRIPTS,
         },
dgaedcke commented 6 years ago

I'm using the exact same dependencies mentioned in the "official" GCP Python tutorial and I'm hitting this error as well.

import service_backend.main File "/Users/dgaedcke/dev/TouchstoneMicroservices/service_backend/main.py", line 7, in import endpoints as google_cloud_endpoints File "/Users/dgaedcke/dev/TouchstoneMicroservices/lib/endpoints/init.py", line 31, in from .apiserving import * File "/Users/dgaedcke/dev/TouchstoneMicroservices/lib/endpoints/apiserving.py", line 73, in from protorpc.wsgi import service as wsgi_service ImportError: No module named wsgi

All suggestions appreciated!