Skip to content

Commit c936b72

Browse files
committed
more setuptools packaging
* move webutil to oauth_dropins.webutil. it's a bit presumptuous to put it at the top level when it's named so broadly. * switch gdata-python-client from submodule to pip dependency. (i've submitted my two bug fix patches as google/gdata-python-client#27.) * move appengine_config.py to oauth_dropins, except for vender/virtualenv setup * update README
1 parent d13f9f6 commit c936b72

File tree

9 files changed

+127
-133
lines changed

9 files changed

+127
-133
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/build/
12
/dist/
23
/.eggs/
34
/*.egg-info

.gitmodules

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
[submodule "gdata-python-client"]
2-
path = gdata-python-client
3-
url = [email protected]:snarfed/gdata-python-client.git
41
[submodule "webutil"]
5-
path = webutil
2+
path = oauth_dropins/webutil
63
url = [email protected]:snarfed/webutil.git

README.md

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,39 +11,42 @@ Tumblr, Twitter, and WordPress.com.
1111
This repo also provides an example demo app, deployed at
1212
http://oauth-dropins.appspot.com/.
1313

14-
Some dependencies are included as git submodules; others are installed with
15-
`pip` in a
14+
Depends on the
15+
[App Engine Python SDK](https://developers.google.com/appengine/downloads). All
16+
other dependencies are handled by pip and enumerated in
17+
[requirements.txt](https://github.com/snarfed/oauth-dropins/blob/master/requirements.txt).
18+
We recommend that you install with pip in a
1619
[`virtualenv`](http://docs.python-guide.org/en/latest/dev/virtualenvs/).
1720
([App Engine details.](https://cloud.google.com/appengine/docs/python/tools/libraries27#vendoring))
18-
To get set up:
1921

20-
```shell
21-
git submodule init
22-
git submodule update
23-
virtualenv local
24-
source local/bin/activate
25-
pip install -r requirements.txt
26-
```
27-
28-
Then add this line to the `appengine_config.py` file in your project's root
29-
directory:
30-
31-
```py
32-
from oauth_dropins.appengine_config import *
33-
```
22+
If you clone the repo directly or want to contribute, see
23+
[Development](#development) for setup instructions.
3424

3525
This software is released into the public domain. See LICENSE for details.
3626

37-
Related work:
38-
39-
* [Python Social Auth](http://psa.matiasaguirre.net/)
40-
4127

4228
Quick start
4329
---
4430

4531
Here's a full example of using the Facebook drop-in.
4632

33+
1. Install oauth-dropins into a virtualenv somewhere your App Engine project's
34+
directory, e.g. `local/`:
35+
36+
```shell
37+
source local/bin/activate
38+
pip install oauth-dropins
39+
```
40+
41+
1. Add this to the `appengine_config.py` file in your project's root directory
42+
([background](https://cloud.google.com/appengine/docs/python/tools/libraries27#vendoring)):
43+
44+
```py
45+
from google.appengine.ext import vendor
46+
vendor.add('local')
47+
from oauth_dropins.appengine_config import *
48+
```
49+
4750
1. Put your [Facebook application](https://developers.facebook.com/apps)'s ID
4851
and secret in two plain text files in your app's root directory,
4952
`facebook_app_id` and `facebook_app_secret`. (If you use git, you'll probably
@@ -211,7 +214,16 @@ least one of them, but not all.
211214

212215
Development
213216
---
214-
Run the unit tests with `python setup.py test`.
217+
To get started:
218+
219+
```shell
220+
git submodule init
221+
git submodule update
222+
virtualenv local
223+
source local/bin/activate
224+
pip install -r requirements.txt
225+
python setup.py test
226+
```
215227

216228
Most dependencies are clean, but we've made patches to some that we haven't
217229
(yet) tried to push upstream. If we ever switch submodule repos for those
@@ -224,6 +236,10 @@ To convert README.md to README.rst:
224236

225237
`pandoc --from=markdown --to=rst --output=README.rst README.md`
226238

239+
Related work:
240+
241+
* [Python Social Auth](http://psa.matiasaguirre.net/)
242+
227243
TODO:
228244

229245
* Google+ and Blogger need some love:

appengine_config.py

Lines changed: 3 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,7 @@
1-
"""App Engine settings.
1+
from oauth_dropins.appengine_config import *
22

3-
Reads app keys and secrets into constants from these files:
4-
5-
disqus_client_id
6-
disqus_client_secret
7-
dropbox_app_key
8-
dropbox_app_secret
9-
facebook_app_id
10-
facebook_app_secret
11-
facebook_app_id_local
12-
facebook_app_secret_local
13-
flickr_app_key
14-
flickr_app_secret
15-
google_client_id
16-
google_client_secret
17-
instagram_client_id
18-
instagram_client_secret
19-
instagram_client_id_local
20-
instagram_client_secret_local
21-
twitter_app_key
22-
twitter_app_secret
23-
tumblr_app_key
24-
tumblr_app_secret
25-
wordpress_client_id
26-
wordpress_client_secret
27-
wordpress_client_id_local
28-
wordpress_client_secret_local
29-
"""
30-
31-
import os
32-
import sys
33-
34-
# Load packages in lib/
3+
# Load packages from virtualenv
4+
# https://cloud.google.com/appengine/docs/python/tools/libraries27#vendoring
355
from google.appengine.ext import vendor
366
vendor.add('local')
377

38-
from webutil.appengine_config import *
39-
40-
# default timeout. the G+ and Instagram APIs use httplib2, which honors this.
41-
import socket
42-
socket.setdefaulttimeout(HTTP_TIMEOUT)
43-
# monkey-patch socket.getdefaulttimeout() because it often gets reset, e.g. by
44-
# socket.setblocking() and maybe other operations.
45-
# http://stackoverflow.com/a/8465202/186123
46-
socket.getdefaulttimeout = lambda: HTTP_TIMEOUT
47-
48-
# Add submodule directories to sys.path so they can be imported.
49-
#
50-
# I used to use symlinks and munge sys.modules, but both of those ended up in
51-
# duplicate instances of modules, which caused problems. Background in
52-
# https://github.com/snarfed/bridgy/issues/31
53-
for path in (
54-
'gdata-python-client/src',
55-
):
56-
path = os.path.join(os.path.dirname(__file__), path)
57-
if path not in sys.path:
58-
sys.path.append(path)
59-
60-
61-
def read(filename):
62-
"""Returns the contents of filename, or None if it doesn't exist."""
63-
if os.path.exists(filename):
64-
with open(filename) as f:
65-
return f.read().strip()
66-
67-
MOCKFACEBOOK = False
68-
69-
if DEBUG:
70-
FACEBOOK_APP_ID = read('facebook_app_id_local')
71-
FACEBOOK_APP_SECRET = read('facebook_app_secret_local')
72-
INSTAGRAM_CLIENT_ID = read('instagram_client_id_local')
73-
INSTAGRAM_CLIENT_SECRET = read('instagram_client_secret_local')
74-
WORDPRESS_CLIENT_ID = read('wordpress.com_client_id_local')
75-
WORDPRESS_CLIENT_SECRET = read('wordpress.com_client_secret_local')
76-
DISQUS_CLIENT_ID = read('disqus_client_id_local')
77-
DISQUS_CLIENT_SECRET = read('disqus_client_secret_local')
78-
else:
79-
FACEBOOK_APP_ID = read('facebook_app_id')
80-
FACEBOOK_APP_SECRET = read('facebook_app_secret')
81-
INSTAGRAM_CLIENT_ID = read('instagram_client_id')
82-
INSTAGRAM_CLIENT_SECRET = read('instagram_client_secret')
83-
WORDPRESS_CLIENT_ID = read('wordpress.com_client_id')
84-
WORDPRESS_CLIENT_SECRET = read('wordpress.com_client_secret')
85-
DISQUS_CLIENT_ID = read('disqus_client_id')
86-
DISQUS_CLIENT_SECRET = read('disqus_client_secret')
87-
88-
DROPBOX_APP_KEY = read('dropbox_app_key')
89-
DROPBOX_APP_SECRET = read('dropbox_app_secret')
90-
FLICKR_APP_KEY = read('flickr_app_key')
91-
FLICKR_APP_SECRET = read('flickr_app_secret')
92-
GOOGLE_CLIENT_ID = read('google_client_id')
93-
GOOGLE_CLIENT_SECRET = read('google_client_secret')
94-
TUMBLR_APP_KEY = read('tumblr_app_key')
95-
TUMBLR_APP_SECRET = read('tumblr_app_secret')
96-
TWITTER_APP_KEY = read('twitter_app_key')
97-
TWITTER_APP_SECRET = read('twitter_app_secret')

gdata-python-client

Lines changed: 0 additions & 1 deletion
This file was deleted.

oauth_dropins/appengine_config.py

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
"""App Engine settings.
2+
3+
Reads app keys and secrets into constants from these files:
4+
5+
disqus_client_id
6+
disqus_client_secret
7+
dropbox_app_key
8+
dropbox_app_secret
9+
facebook_app_id
10+
facebook_app_secret
11+
facebook_app_id_local
12+
facebook_app_secret_local
13+
flickr_app_key
14+
flickr_app_secret
15+
google_client_id
16+
google_client_secret
17+
instagram_client_id
18+
instagram_client_secret
19+
instagram_client_id_local
20+
instagram_client_secret_local
21+
twitter_app_key
22+
twitter_app_secret
23+
tumblr_app_key
24+
tumblr_app_secret
25+
wordpress_client_id
26+
wordpress_client_secret
27+
wordpress_client_id_local
28+
wordpress_client_secret_local
29+
"""
30+
31+
import os
32+
33+
from webutil.appengine_config import *
34+
35+
# default timeout. the G+ and Instagram APIs use httplib2, which honors this.
36+
import socket
37+
socket.setdefaulttimeout(HTTP_TIMEOUT)
38+
# monkey-patch socket.getdefaulttimeout() because it often gets reset, e.g. by
39+
# socket.setblocking() and maybe other operations.
40+
# http://stackoverflow.com/a/8465202/186123
41+
socket.getdefaulttimeout = lambda: HTTP_TIMEOUT
42+
43+
44+
def read(filename):
45+
"""Returns the contents of filename, or None if it doesn't exist."""
46+
if os.path.exists(filename):
47+
with open(filename) as f:
48+
return f.read().strip()
49+
50+
if DEBUG:
51+
FACEBOOK_APP_ID = read('facebook_app_id_local')
52+
FACEBOOK_APP_SECRET = read('facebook_app_secret_local')
53+
INSTAGRAM_CLIENT_ID = read('instagram_client_id_local')
54+
INSTAGRAM_CLIENT_SECRET = read('instagram_client_secret_local')
55+
WORDPRESS_CLIENT_ID = read('wordpress.com_client_id_local')
56+
WORDPRESS_CLIENT_SECRET = read('wordpress.com_client_secret_local')
57+
DISQUS_CLIENT_ID = read('disqus_client_id_local')
58+
DISQUS_CLIENT_SECRET = read('disqus_client_secret_local')
59+
else:
60+
FACEBOOK_APP_ID = read('facebook_app_id')
61+
FACEBOOK_APP_SECRET = read('facebook_app_secret')
62+
INSTAGRAM_CLIENT_ID = read('instagram_client_id')
63+
INSTAGRAM_CLIENT_SECRET = read('instagram_client_secret')
64+
WORDPRESS_CLIENT_ID = read('wordpress.com_client_id')
65+
WORDPRESS_CLIENT_SECRET = read('wordpress.com_client_secret')
66+
DISQUS_CLIENT_ID = read('disqus_client_id')
67+
DISQUS_CLIENT_SECRET = read('disqus_client_secret')
68+
69+
DROPBOX_APP_KEY = read('dropbox_app_key')
70+
DROPBOX_APP_SECRET = read('dropbox_app_secret')
71+
FLICKR_APP_KEY = read('flickr_app_key')
72+
FLICKR_APP_SECRET = read('flickr_app_secret')
73+
GOOGLE_CLIENT_ID = read('google_client_id')
74+
GOOGLE_CLIENT_SECRET = read('google_client_secret')
75+
TUMBLR_APP_KEY = read('tumblr_app_key')
76+
TUMBLR_APP_SECRET = read('tumblr_app_secret')
77+
TWITTER_APP_KEY = read('twitter_app_key')
78+
TWITTER_APP_SECRET = read('twitter_app_secret')

oauth_dropins/test/test_handlers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
from webob import exc
1717

1818
from oauth_dropins import handlers
19-
from webutil import util
20-
from webutil import testutil
19+
from oauth_dropins.webutil import util
20+
from oauth_dropins.webutil import testutil
2121

2222

2323
class HandlersTest(testutil.HandlerTest):

setup.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,15 @@
66
77
Based on https://github.com/pypa/sampleproject/blob/master/setup.py
88
"""
9-
import unittest
10-
11-
from setuptools import setup
12-
13-
14-
class TestLoader(unittest.TestLoader):
15-
def loadTestsFromNames(self, names, _=None):
16-
return self.discover(names[0])
9+
from setuptools import setup, find_packages
1710

1811

1912
setup(name='oauth-dropins',
2013
version='1.0',
2114
description='Drop-in App Engine OAuth client handlers for many popular sites.',
2215
long_description=open('README.rst').read(),
2316
url='https://github.com/snarfed/oauth-dropins',
24-
packages=['oauth_dropins', 'webutil'],
17+
packages=find_packages(),
2518
author='Ryan Barrett',
2619
author_email='[email protected]',
2720
license='Public domain',
@@ -36,6 +29,7 @@ def loadTestsFromNames(self, names, _=None):
3629
],
3730
keywords='oauth appengine',
3831
install_requires=[
32+
'gdata',
3933
'google-api-python-client',
4034
'httplib2',
4135
'oauthlib',
@@ -44,6 +38,5 @@ def loadTestsFromNames(self, names, _=None):
4438
'requests-oauthlib',
4539
'tweepy',
4640
],
47-
test_loader='setup:TestLoader',
48-
test_suite='.',
41+
test_suite='oauth_dropins',
4942
)

0 commit comments

Comments
 (0)