Visitar URL original
Importing top-level `webapp2` breaks encapsulation · Issue #302 · googleapis/oauth2client · GitHub
Skip to content
This repository was archived by the owner on Jan 18, 2025. It is now read-only.
This repository was archived by the owner on Jan 18, 2025. It is now read-only.

Importing top-level webapp2 breaks encapsulation #302

Closed

Description

@tseaver

f3f8b4f replaces an import of webapp from google.appengine.ext with a top-level import of webapp2 (aliased as webapp). The commit comment says:

This choice is apparently more robust in situations / runtimes where the import mechanism in google/appengine/ext/webapp/init.py does not appear to do the right thing.

This change breaks the GAE import mocking done in gcloud.

Activity

  1. dhermes commented on Sep 8, 2015

    @dhermes
    Contributor

    @tseaver How do you mean it breaks encapsulation? The oauth2client.appengine module isn't imported in the package, so a user needs to explicitly say "import me some appengine, I'm on the appengine".

  2. tseaver commented on Sep 8, 2015

    @tseaver
    Author

    The gcloud tests covering the "appengine detection" machinery mock out the necessary google.appengine bits to allow oauth2client.appengine to import without breaking. f3f8b4f breaks that, switching to import webapp as an alias for an entirely new top-level webapp2 package (newly-imported here, at least).

    I don't know what the motivation for f3f8b4f was, but it caused the gcloud tests to break today due to the ues of newly-released oauth2client 1.5.0.

  3. dhermes commented on Sep 8, 2015

    @dhermes
    Contributor

    Motivation: webapp2 replaced webapp in either 2011 or 2010, so the code was very old.

    I realize it hurt our test mocks in a library elsewhere, but that isn't an issue with oauth2client.

    I'm closing out, let me know if you think there is something left in oauth2client that needs to be resolved.

  4. tseaver commented on Sep 8, 2015

    @tseaver
    Author

    FTR, the commit was a fix for #217. That change added an import dependency on webapp2, without also adding as an install_requires dependency in setup.py: AFAICT, it should be there (d2c15e6 patched it into tox.ini for the docs). Perhaps it should be in an 'extras_require`, e.g.:

    setup(
    #...
        extras_require={'appengine': ['webapp2', 'appengine']},
    )
  5. dhermes commented on Sep 8, 2015

    @dhermes
    Contributor

    App Engine is a nasty beast. Users deploy code there and all of these dependencies are just there. (webapp2 is luckily open source and available on PyPI)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions