Skip to content

Commit f6b454c

Browse files
committed
Add detection for old apiclient versions in setup.py.
1 parent 0c18afc commit f6b454c

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

setup.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,30 @@
2727
sys.exit(1)
2828

2929
from setuptools import setup
30+
import pkg_resources
31+
32+
def _DetectBadness():
33+
import os
34+
if 'SKIP_GOOGLEAPICLIENT_COMPAT_CHECK' in os.environ:
35+
return
36+
o2c_pkg = None
37+
try:
38+
o2c_pkg = pkg_resources.get_distribution('oauth2client')
39+
except pkg_resources.DistributionNotFound:
40+
pass
41+
oauth2client = None
42+
try:
43+
import oauth2client
44+
except ImportError:
45+
pass
46+
if o2c_pkg is None and oauth2client is not None:
47+
raise RuntimeError(
48+
'Previous version of google-api-python-client detected; due to a '
49+
'packaging issue, we cannot perform an in-place upgrade. Please remove '
50+
'the old version and re-install this package.'
51+
)
52+
53+
_DetectBadness()
3054

3155
packages = [
3256
'apiclient',

0 commit comments

Comments
 (0)