Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making enum34 dependency conditional on Python version. #3402

Merged
merged 1 commit into from
May 11, 2017

Conversation

dhermes
Copy link
Contributor

@dhermes dhermes commented May 11, 2017

Fixes #3398.


After using this and running the unit tests, the dependency is indeed only present in Python 2.7:

$ .nox/unit_tests-python_version-2-7/bin/pip freeze > 27.txt
$ .nox/unit_tests-python_version-3-4/bin/pip freeze > 34.txt
$ .nox/unit_tests-python_version-3-5/bin/pip freeze > 35.txt
$ .nox/unit_tests-python_version-3-6/bin/pip freeze > 36.txt
$
$ diff -s 34.txt 35.txt
Files 34.txt and 35.txt are identical
$ diff -s 34.txt 36.txt
Files 34.txt and 36.txt are identical
$
$ diff -s 27.txt 34.txt
--- 27.txt      2017-05-11 10:28:41.369890164 -0700
+++ 34.txt      2017-05-11 10:28:36.081426963 -0700
@@ -2,10 +2,7 @@
 cachetools==2.0.0
 coverage==4.4
 dill==0.2.6
-enum34==1.1.6
-funcsigs==1.0.2
 future==0.16.0
-futures==3.1.1
 gapic-google-cloud-vision-v1==0.90.3
 google-auth==1.0.1
 google-auth-httplib2==0.0.2

@dhermes dhermes added api: vision Issues related to the Cloud Vision API. packaging labels May 11, 2017
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label May 11, 2017
Copy link
Contributor

@tseaver tseaver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't mind the change, but I'd really like to know how our code appears to work on Python 3.6 without this change.

@theacodes
Copy link
Contributor

So it seems package metadata (and therefore wheels) do not store the platform qualifiers, so installing from wheel in python 3 will cause enum34 to be installed. I had a fear that this would be the case:

pip install google_cloud_vision-0.24.0-py2.py3-none-any.whl
Processing ./google_cloud_vision-0.24.0-py2.py3-none-any.whl
Collecting gapic-google-cloud-vision-v1<0.91dev,>=0.90.3 (from google-cloud-vision==0.24.0)
  Using cached gapic-google-cloud-vision-v1-0.90.3.tar.gz
Collecting enum34 (from google-cloud-vision==0.24.0)
  Using cached enum34-1.1.6-py3-none-any.whl
Collecting google-cloud-core<0.25dev,>=0.24.0 (from google-cloud-vision==0.24.0)
  Using cached google_cloud_core-0.24.1-py2.py3-none-any.whl
Collecting google-gax<0.16dev,>=0.15.7 (from gapic-google-cloud-vision-v1<0.91dev,>=0.90.3->google-cloud-vision==0.24.0)
Collecting oauth2client<4.0dev,>=2.0.0 (from gapic-google-cloud-vision-v1<0.91dev,>=0.90.3->google-cloud-vision==0.24.0)
Collecting proto-google-cloud-vision-v1[grpc]<0.91dev,>=0.90.3 (from gapic-google-cloud-vision-v1<0.91dev,>=0.90.3->google-cloud-vision==0.24.0)
  Using cached proto-google-cloud-vision-v1-0.90.3.tar.gz
Collecting googleapis-common-protos[grpc]<2.0dev,>=1.5.2 (from gapic-google-cloud-vision-v1<0.91dev,>=0.90.3->google-cloud-vision==0.24.0)
Collecting httplib2>=0.9.1 (from google-cloud-core<0.25dev,>=0.24.0->google-cloud-vision==0.24.0)
Collecting protobuf>=3.0.0 (from google-cloud-core<0.25dev,>=0.24.0->google-cloud-vision==0.24.0)
Collecting google-auth<2.0.0dev,>=0.4.0 (from google-cloud-core<0.25dev,>=0.24.0->google-cloud-vision==0.24.0)
  Using cached google_auth-1.0.1-py2.py3-none-any.whl
Collecting google-auth-httplib2 (from google-cloud-core<0.25dev,>=0.24.0->google-cloud-vision==0.24.0)
  Using cached google_auth_httplib2-0.0.2-py2.py3-none-any.whl
Requirement already satisfied: six in /private/tmp/env/lib/python3.6/site-packages (from google-cloud-core<0.25dev,>=0.24.0->google-cloud-vision==0.24.0)
Collecting requests<3.0dev,>=2.13.0 (from google-gax<0.16dev,>=0.15.7->gapic-google-cloud-vision-v1<0.91dev,>=0.90.3->google-cloud-vision==0.24.0)
  Using cached requests-2.14.2-py2.py3-none-any.whl
Collecting future<0.17dev,>=0.16.0 (from google-gax<0.16dev,>=0.15.7->gapic-google-cloud-vision-v1<0.91dev,>=0.90.3->google-cloud-vision==0.24.0)
Collecting dill<0.3dev,>=0.2.5 (from google-gax<0.16dev,>=0.15.7->gapic-google-cloud-vision-v1<0.91dev,>=0.90.3->google-cloud-vision==0.24.0)
Collecting ply==3.8 (from google-gax<0.16dev,>=0.15.7->gapic-google-cloud-vision-v1<0.91dev,>=0.90.3->google-cloud-vision==0.24.0)
Collecting grpcio<2.0dev,>=1.0.2 (from google-gax<0.16dev,>=0.15.7->gapic-google-cloud-vision-v1<0.91dev,>=0.90.3->google-cloud-vision==0.24.0)
  Using cached grpcio-1.3.0-cp36-cp36m-macosx_10_7_intel.whl
Collecting pyasn1-modules>=0.0.5 (from oauth2client<4.0dev,>=2.0.0->gapic-google-cloud-vision-v1<0.91dev,>=0.90.3->google-cloud-vision==0.24.0)
  Using cached pyasn1_modules-0.0.8-py2.py3-none-any.whl
Collecting pyasn1>=0.1.7 (from oauth2client<4.0dev,>=2.0.0->gapic-google-cloud-vision-v1<0.91dev,>=0.90.3->google-cloud-vision==0.24.0)
  Using cached pyasn1-0.2.3-py2.py3-none-any.whl
Collecting rsa>=3.1.4 (from oauth2client<4.0dev,>=2.0.0->gapic-google-cloud-vision-v1<0.91dev,>=0.90.3->google-cloud-vision==0.24.0)
  Using cached rsa-3.4.2-py2.py3-none-any.whl
Requirement already satisfied: setuptools in /private/tmp/env/lib/python3.6/site-packages (from protobuf>=3.0.0->google-cloud-core<0.25dev,>=0.24.0->google-cloud-vision==0.24.0)
Collecting cachetools>=2.0.0 (from google-auth<2.0.0dev,>=0.4.0->google-cloud-core<0.25dev,>=0.24.0->google-cloud-vision==0.24.0)
  Using cached cachetools-2.0.0-py2.py3-none-any.whl
Requirement already satisfied: appdirs>=1.4.0 in /private/tmp/env/lib/python3.6/site-packages (from setuptools->protobuf>=3.0.0->google-cloud-core<0.25dev,>=0.24.0->google-cloud-vision==0.24.0)
Requirement already satisfied: packaging>=16.8 in /private/tmp/env/lib/python3.6/site-packages (from setuptools->protobuf>=3.0.0->google-cloud-core<0.25dev,>=0.24.0->google-cloud-vision==0.24.0)
Requirement already satisfied: pyparsing in /private/tmp/env/lib/python3.6/site-packages (from packaging>=16.8->setuptools->protobuf>=3.0.0->google-cloud-core<0.25dev,>=0.24.0->google-cloud-vision==0.24.0)
Building wheels for collected packages: gapic-google-cloud-vision-v1, proto-google-cloud-vision-v1
  Running setup.py bdist_wheel for gapic-google-cloud-vision-v1 ... done
  Stored in directory: /Users/jonwayne/Library/Caches/pip/wheels/ce/0f/77/6ac253c303b8a0b4b985796f618f62ffaf0c1bb82e86b7b27f
  Running setup.py bdist_wheel for proto-google-cloud-vision-v1 ... done
  Stored in directory: /Users/jonwayne/Library/Caches/pip/wheels/cc/39/4f/ba1cc41634e5a468627c7194093313e268f69432c8f9ae7fa2
Successfully built gapic-google-cloud-vision-v1 proto-google-cloud-vision-v1
Installing collected packages: requests, protobuf, future, grpcio, googleapis-common-protos, pyasn1, pyasn1-modules, cachetools, rsa, google-auth, dill, ply, google-gax, httplib2, oauth2client, proto-google-cloud-vision-v1, gapic-google-cloud-vision-v1, enum34, google-auth-httplib2, google-cloud-core, google-cloud-vision
Successfully installed cachetools-2.0.0 dill-0.2.6 enum34-1.1.6 future-0.16.0 gapic-google-cloud-vision-v1-0.90.3 google-auth-1.0.1 google-auth-httplib2-0.0.2 google-cloud-core-0.24.1 google-cloud-vision-0.24.0 google-gax-0.15.12 googleapis-common-protos-1.5.2 grpcio-1.3.0 httplib2-0.10.3 oauth2client-3.0.0 ply-3.8 proto-google-cloud-vision-v1-0.90.3 protobuf-3.3.0 pyasn1-0.2.3 pyasn1-modules-0.0.8 requests-2.14.2 rsa-3.4.2

@dhermes
Copy link
Contributor Author

dhermes commented May 11, 2017

@jonparrott Shucks / thanks for bringing your packaging magic to bear here. What can we do?

@dhermes
Copy link
Contributor Author

dhermes commented May 11, 2017

@tseaver Regarding "how our code appears to work", see my response on the bug report.

@theacodes
Copy link
Contributor

theacodes commented May 11, 2017

We can do it via extras_require as noted in the wheel docs:

extras_require={
    ':python_version<"3.4"': ['enum34'],
}

This explodes with setuptools<18 (ref), but that was released in 2015, so I think we're safe.

@dhermes
Copy link
Contributor Author

dhermes commented May 11, 2017

PR updated. Thanks a lot @jonparrott! I did the same pip freeze verification with this new setup and the diffs were exactly as before.

@theacodes
Copy link
Contributor

Confirmed wheel installation skips enum34 on Python 3.6:

Processing ./google_cloud_vision-0.24.0-py2.py3-none-any.whl
Collecting google-cloud-core<0.25dev,>=0.24.0 (from google-cloud-vision==0.24.0)
  Using cached google_cloud_core-0.24.1-py2.py3-none-any.whl
Collecting gapic-google-cloud-vision-v1<0.91dev,>=0.90.3 (from google-cloud-vision==0.24.0)
Collecting googleapis-common-protos>=1.3.4 (from google-cloud-core<0.25dev,>=0.24.0->google-cloud-vision==0.24.0)
Collecting httplib2>=0.9.1 (from google-cloud-core<0.25dev,>=0.24.0->google-cloud-vision==0.24.0)
Collecting google-auth-httplib2 (from google-cloud-core<0.25dev,>=0.24.0->google-cloud-vision==0.24.0)
  Using cached google_auth_httplib2-0.0.2-py2.py3-none-any.whl
Requirement already satisfied: six in /private/tmp/env/lib/python3.6/site-packages (from google-cloud-core<0.25dev,>=0.24.0->google-cloud-vision==0.24.0)
Collecting google-auth<2.0.0dev,>=0.4.0 (from google-cloud-core<0.25dev,>=0.24.0->google-cloud-vision==0.24.0)
  Using cached google_auth-1.0.1-py2.py3-none-any.whl
Collecting protobuf>=3.0.0 (from google-cloud-core<0.25dev,>=0.24.0->google-cloud-vision==0.24.0)
Collecting proto-google-cloud-vision-v1[grpc]<0.91dev,>=0.90.3 (from gapic-google-cloud-vision-v1<0.91dev,>=0.90.3->google-cloud-vision==0.24.0)
Collecting google-gax<0.16dev,>=0.15.7 (from gapic-google-cloud-vision-v1<0.91dev,>=0.90.3->google-cloud-vision==0.24.0)
Collecting oauth2client<4.0dev,>=2.0.0 (from gapic-google-cloud-vision-v1<0.91dev,>=0.90.3->google-cloud-vision==0.24.0)
Collecting pyasn1>=0.1.7 (from google-auth-httplib2->google-cloud-core<0.25dev,>=0.24.0->google-cloud-vision==0.24.0)
  Using cached pyasn1-0.2.3-py2.py3-none-any.whl
Collecting pyasn1-modules>=0.0.5 (from google-auth-httplib2->google-cloud-core<0.25dev,>=0.24.0->google-cloud-vision==0.24.0)
  Using cached pyasn1_modules-0.0.8-py2.py3-none-any.whl
Collecting rsa>=3.1.4 (from google-auth-httplib2->google-cloud-core<0.25dev,>=0.24.0->google-cloud-vision==0.24.0)
  Using cached rsa-3.4.2-py2.py3-none-any.whl
Collecting cachetools>=2.0.0 (from google-auth<2.0.0dev,>=0.4.0->google-cloud-core<0.25dev,>=0.24.0->google-cloud-vision==0.24.0)
  Using cached cachetools-2.0.0-py2.py3-none-any.whl
Requirement already satisfied: setuptools in /private/tmp/env/lib/python3.6/site-packages (from protobuf>=3.0.0->google-cloud-core<0.25dev,>=0.24.0->google-cloud-vision==0.24.0)
Collecting grpcio<2.0dev,>=1.0.2; extra == "grpc" (from proto-google-cloud-vision-v1[grpc]<0.91dev,>=0.90.3->gapic-google-cloud-vision-v1<0.91dev,>=0.90.3->google-cloud-vision==0.24.0)
  Using cached grpcio-1.3.0-cp36-cp36m-macosx_10_7_intel.whl
Collecting dill<0.3dev,>=0.2.5 (from google-gax<0.16dev,>=0.15.7->gapic-google-cloud-vision-v1<0.91dev,>=0.90.3->google-cloud-vision==0.24.0)
Collecting requests<3.0dev,>=2.13.0 (from google-gax<0.16dev,>=0.15.7->gapic-google-cloud-vision-v1<0.91dev,>=0.90.3->google-cloud-vision==0.24.0)
  Using cached requests-2.14.2-py2.py3-none-any.whl
Collecting ply==3.8 (from google-gax<0.16dev,>=0.15.7->gapic-google-cloud-vision-v1<0.91dev,>=0.90.3->google-cloud-vision==0.24.0)
Collecting future<0.17dev,>=0.16.0 (from google-gax<0.16dev,>=0.15.7->gapic-google-cloud-vision-v1<0.91dev,>=0.90.3->google-cloud-vision==0.24.0)
Requirement already satisfied: appdirs>=1.4.0 in /private/tmp/env/lib/python3.6/site-packages (from setuptools->protobuf>=3.0.0->google-cloud-core<0.25dev,>=0.24.0->google-cloud-vision==0.24.0)
Requirement already satisfied: packaging>=16.8 in /private/tmp/env/lib/python3.6/site-packages (from setuptools->protobuf>=3.0.0->google-cloud-core<0.25dev,>=0.24.0->google-cloud-vision==0.24.0)
Requirement already satisfied: pyparsing in /private/tmp/env/lib/python3.6/site-packages (from packaging>=16.8->setuptools->protobuf>=3.0.0->google-cloud-core<0.25dev,>=0.24.0->google-cloud-vision==0.24.0)
Installing collected packages: protobuf, googleapis-common-protos, httplib2, pyasn1, cachetools, pyasn1-modules, rsa, google-auth, google-auth-httplib2, google-cloud-core, oauth2client, grpcio, proto-google-cloud-vision-v1, dill, requests, ply, future, google-gax, gapic-google-cloud-vision-v1, google-cloud-vision
Successfully installed cachetools-2.0.0 dill-0.2.6 future-0.16.0 gapic-google-cloud-vision-v1-0.90.3 google-auth-1.0.1 google-auth-httplib2-0.0.2 google-cloud-core-0.24.1 google-cloud-vision-0.24.0 google-gax-0.15.12 googleapis-common-protos-1.5.2 grpcio-1.3.0 httplib2-0.10.3 oauth2client-3.0.0 ply-3.8 proto-google-cloud-vision-v1-0.90.3 protobuf-3.3.0 pyasn1-0.2.3 pyasn1-modules-0.0.8 requests-2.14.2 rsa-3.4.2

And that enum34 is installed on Python 2.7

Processing ./google_cloud_vision-0.24.0-py2.py3-none-any.whl
Collecting enum34; python_version < "3.4" (from google-cloud-vision==0.24.0)
  Using cached enum34-1.1.6-py2-none-any.whl
Collecting google-cloud-core<0.25dev,>=0.24.0 (from google-cloud-vision==0.24.0)
  Using cached google_cloud_core-0.24.1-py2.py3-none-any.whl
Collecting gapic-google-cloud-vision-v1<0.91dev,>=0.90.3 (from google-cloud-vision==0.24.0)
Collecting protobuf>=3.0.0 (from google-cloud-core<0.25dev,>=0.24.0->google-cloud-vision==0.24.0)
Requirement already satisfied: six in /private/tmp/env/lib/python2.7/site-packages (from google-cloud-core<0.25dev,>=0.24.0->google-cloud-vision==0.24.0)
Collecting google-auth-httplib2 (from google-cloud-core<0.25dev,>=0.24.0->google-cloud-vision==0.24.0)
  Using cached google_auth_httplib2-0.0.2-py2.py3-none-any.whl
Collecting googleapis-common-protos>=1.3.4 (from google-cloud-core<0.25dev,>=0.24.0->google-cloud-vision==0.24.0)
Collecting google-auth<2.0.0dev,>=0.4.0 (from google-cloud-core<0.25dev,>=0.24.0->google-cloud-vision==0.24.0)
  Using cached google_auth-1.0.1-py2.py3-none-any.whl
Collecting httplib2>=0.9.1 (from google-cloud-core<0.25dev,>=0.24.0->google-cloud-vision==0.24.0)
Collecting proto-google-cloud-vision-v1[grpc]<0.91dev,>=0.90.3 (from gapic-google-cloud-vision-v1<0.91dev,>=0.90.3->google-cloud-vision==0.24.0)
Collecting google-gax<0.16dev,>=0.15.7 (from gapic-google-cloud-vision-v1<0.91dev,>=0.90.3->google-cloud-vision==0.24.0)
Collecting oauth2client<4.0dev,>=2.0.0 (from gapic-google-cloud-vision-v1<0.91dev,>=0.90.3->google-cloud-vision==0.24.0)
Requirement already satisfied: setuptools in /private/tmp/env/lib/python2.7/site-packages (from protobuf>=3.0.0->google-cloud-core<0.25dev,>=0.24.0->google-cloud-vision==0.24.0)
Collecting pyasn1>=0.1.7 (from google-auth-httplib2->google-cloud-core<0.25dev,>=0.24.0->google-cloud-vision==0.24.0)
  Using cached pyasn1-0.2.3-py2.py3-none-any.whl
Collecting rsa>=3.1.4 (from google-auth-httplib2->google-cloud-core<0.25dev,>=0.24.0->google-cloud-vision==0.24.0)
  Using cached rsa-3.4.2-py2.py3-none-any.whl
Collecting pyasn1-modules>=0.0.5 (from google-auth-httplib2->google-cloud-core<0.25dev,>=0.24.0->google-cloud-vision==0.24.0)
  Using cached pyasn1_modules-0.0.8-py2.py3-none-any.whl
Collecting cachetools>=2.0.0 (from google-auth<2.0.0dev,>=0.4.0->google-cloud-core<0.25dev,>=0.24.0->google-cloud-vision==0.24.0)
  Using cached cachetools-2.0.0-py2.py3-none-any.whl
Collecting grpcio<2.0dev,>=1.0.2; extra == "grpc" (from proto-google-cloud-vision-v1[grpc]<0.91dev,>=0.90.3->gapic-google-cloud-vision-v1<0.91dev,>=0.90.3->google-cloud-vision==0.24.0)
  Using cached grpcio-1.3.0-cp27-cp27m-macosx_10_10_intel.whl
Collecting ply==3.8 (from google-gax<0.16dev,>=0.15.7->gapic-google-cloud-vision-v1<0.91dev,>=0.90.3->google-cloud-vision==0.24.0)
Collecting future<0.17dev,>=0.16.0 (from google-gax<0.16dev,>=0.15.7->gapic-google-cloud-vision-v1<0.91dev,>=0.90.3->google-cloud-vision==0.24.0)
Collecting requests<3.0dev,>=2.13.0 (from google-gax<0.16dev,>=0.15.7->gapic-google-cloud-vision-v1<0.91dev,>=0.90.3->google-cloud-vision==0.24.0)
  Using cached requests-2.14.2-py2.py3-none-any.whl
Collecting dill<0.3dev,>=0.2.5 (from google-gax<0.16dev,>=0.15.7->gapic-google-cloud-vision-v1<0.91dev,>=0.90.3->google-cloud-vision==0.24.0)
Requirement already satisfied: packaging>=16.8 in /private/tmp/env/lib/python2.7/site-packages (from setuptools->protobuf>=3.0.0->google-cloud-core<0.25dev,>=0.24.0->google-cloud-vision==0.24.0)
Requirement already satisfied: appdirs>=1.4.0 in /private/tmp/env/lib/python2.7/site-packages (from setuptools->protobuf>=3.0.0->google-cloud-core<0.25dev,>=0.24.0->google-cloud-vision==0.24.0)
Collecting futures>=2.2.0 (from grpcio<2.0dev,>=1.0.2; extra == "grpc"->proto-google-cloud-vision-v1[grpc]<0.91dev,>=0.90.3->gapic-google-cloud-vision-v1<0.91dev,>=0.90.3->google-cloud-vision==0.24.0)
  Using cached futures-3.1.1-py2-none-any.whl
Requirement already satisfied: pyparsing in /private/tmp/env/lib/python2.7/site-packages (from packaging>=16.8->setuptools->protobuf>=3.0.0->google-cloud-core<0.25dev,>=0.24.0->google-cloud-vision==0.24.0)
Installing collected packages: enum34, protobuf, pyasn1, pyasn1-modules, rsa, cachetools, google-auth, google-auth-httplib2, googleapis-common-protos, httplib2, google-cloud-core, oauth2client, futures, grpcio, proto-google-cloud-vision-v1, ply, future, requests, dill, google-gax, gapic-google-cloud-vision-v1, google-cloud-vision
Successfully installed cachetools-2.0.0 dill-0.2.6 enum34-1.1.6 future-0.16.0 futures-3.1.1 gapic-google-cloud-vision-v1-0.90.3 google-auth-1.0.1 google-auth-httplib2-0.0.2 google-cloud-core-0.24.1 google-cloud-vision-0.24.0 google-gax-0.15.12 googleapis-common-protos-1.5.2 grpcio-1.3.0 httplib2-0.10.3 oauth2client-3.0.0 ply-3.8 proto-google-cloud-vision-v1-0.90.3 protobuf-3.3.0 pyasn1-0.2.3 pyasn1-modules-0.0.8 requests-2.14.2 rsa-3.4.2

@dhermes dhermes merged commit bda4dc0 into googleapis:master May 11, 2017
@dhermes dhermes deleted the fix-3398 branch May 11, 2017 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: vision Issues related to the Cloud Vision API. cla: yes This human has signed the Contributor License Agreement. packaging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants