|
11 | 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | 12 | # See the License for the specific language governing permissions and |
13 | 13 | # limitations under the License. |
14 | | -# |
| 14 | + |
| 15 | +import os |
| 16 | + |
15 | 17 | from setuptools import find_packages |
16 | 18 | from setuptools import setup |
17 | 19 |
|
| 20 | + |
| 21 | +NAMESPACE_DECLARATION = """ |
| 22 | +try: |
| 23 | + __import__('pkg_resources').declare_namespace(__name__) |
| 24 | +except ImportError: |
| 25 | + __path__ = __import__('pkgutil').extend_path(__path__, __name__) |
| 26 | +""" |
| 27 | + |
| 28 | + |
| 29 | +def patch_namespace_package(file): |
| 30 | + with open(file, 'r') as f: |
| 31 | + contents = f.read() |
| 32 | + |
| 33 | + if NAMESPACE_DECLARATION in contents: |
| 34 | + return |
| 35 | + |
| 36 | + with open(file, 'a') as f: |
| 37 | + f.write(NAMESPACE_DECLARATION) |
| 38 | + |
| 39 | +# WARNING: GIANT FLAMING LAVA PIT HACK. |
| 40 | +# Patch the App Engine SDK's google/__init__.py to force it to be a namespace |
| 41 | +# package. Without this, none of the other google namespace packages will work |
| 42 | +# (e.g. protobuf). |
| 43 | +# To be removed with github issue #91. |
| 44 | +patch_namespace_package(os.path.join( |
| 45 | + os.path.dirname(__file__), |
| 46 | + 'exported_appengine_sdk', |
| 47 | + 'google', |
| 48 | + '__init__.py')) |
| 49 | + |
| 50 | + |
18 | 51 | setup( |
19 | 52 | name='appengine-compat', |
20 | 53 | version='0.64', |
|
32 | 65 | package_dir={'': 'exported_appengine_sdk'}, |
33 | 66 | include_package_data=True, |
34 | 67 | packages=find_packages('exported_appengine_sdk', exclude=['lib.*']), |
35 | | - # namespace_packages=['google'], # This skips google/__init__.py |
| 68 | + namespace_packages=['google'], |
36 | 69 | install_requires=[ |
37 | 70 | 'requests>=2.5.0', |
38 | 71 | 'webapp2>=2.5.2', |
|
0 commit comments