Modified README and setup.py to install apiclient and included third party libraries.
Added setup_utils.py to test for installed modules.
This commit is contained in:
29
README
29
README
@@ -4,12 +4,27 @@ for discovery based APIs.
|
|||||||
Installation
|
Installation
|
||||||
============
|
============
|
||||||
|
|
||||||
None.
|
To install, simply say
|
||||||
|
|
||||||
|
$ python setup.py install --record=files.txt
|
||||||
|
|
||||||
|
to install the files and record what files are installed in files.txt.
|
||||||
|
|
||||||
|
If you want to do a "mock install" and simply extend your PYTHONPATH
|
||||||
|
for the current shell to include this folder and the packages in it, do
|
||||||
|
|
||||||
|
$ source setpath.sh
|
||||||
|
|
||||||
|
from the root of the project directory.
|
||||||
|
|
||||||
|
|
||||||
|
Uninstall
|
||||||
|
=========
|
||||||
|
|
||||||
|
$ cat files.txt | xargs rm -rf
|
||||||
|
|
||||||
|
You may need root privileges to do this.
|
||||||
|
|
||||||
For the time being the required libraries
|
|
||||||
are checked into this directory to make
|
|
||||||
developement easier, so you can just run
|
|
||||||
this directly after checking out.
|
|
||||||
|
|
||||||
Running
|
Running
|
||||||
=======
|
=======
|
||||||
@@ -26,6 +41,9 @@ recent entry in Buzz and post a test message.
|
|||||||
|
|
||||||
$ python samples/cmdline/buzz.py
|
$ python samples/cmdline/buzz.py
|
||||||
|
|
||||||
|
After following the install directions (using setup.py or setpath.sh) you
|
||||||
|
should be able to cd to samples/cmdline and run the code from there.
|
||||||
|
|
||||||
|
|
||||||
Third Party Libraries
|
Third Party Libraries
|
||||||
====================
|
====================
|
||||||
@@ -33,4 +51,3 @@ Third Party Libraries
|
|||||||
http://code.google.com/p/httplib2
|
http://code.google.com/p/httplib2
|
||||||
http://code.google.com/p/uri-templates
|
http://code.google.com/p/uri-templates
|
||||||
http://github.com/simplegeo/python-oauth2
|
http://github.com/simplegeo/python-oauth2
|
||||||
|
|
||||||
|
|||||||
64
setup.py
64
setup.py
@@ -1,16 +1,62 @@
|
|||||||
#!/usr/bin/env python
|
# Copyright (C) 2010 Google Inc.
|
||||||
from distutils.core import setup
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
"""Setup script for Google API Python client.
|
||||||
|
|
||||||
|
Also installs included versions of third party libraries, if those libraries
|
||||||
|
are not already installed.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import setup_utils
|
||||||
|
|
||||||
|
packages = ['apiclient', 'uritemplate']
|
||||||
|
|
||||||
|
# Don't clobber installed versions of third party libraries
|
||||||
|
# with what we include.
|
||||||
|
packages.extend(setup_utils.get_missing_requirements())
|
||||||
|
print 'Installing the following packages: '
|
||||||
|
print str(packages)[1:-1]
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Some people prefer setuptools, and may have that installed
|
||||||
|
from setuptools import setup
|
||||||
|
except ImportError:
|
||||||
|
from distutils.core import setup
|
||||||
|
print 'Loaded distutils.core'
|
||||||
|
else:
|
||||||
|
print 'Loaded setuptools'
|
||||||
|
|
||||||
|
long_desc = """The Google API Client for Python is a client library for
|
||||||
|
accessing the Buzz, Moderator, and Latitude APIs."""
|
||||||
|
|
||||||
# First pass at a setup.py, in the long run we will
|
|
||||||
# need two, one for a version of the library that just
|
|
||||||
# includes apiclient, and another that also includes
|
|
||||||
# all of the dependencies.
|
|
||||||
setup(name="google-api-python-client",
|
setup(name="google-api-python-client",
|
||||||
version="0.1",
|
version="0.1",
|
||||||
description="Google API Client Library for Python",
|
description="Google API Client Library for Python",
|
||||||
|
long_description=long_desc,
|
||||||
author="Joe Gregorio",
|
author="Joe Gregorio",
|
||||||
author_email="jcgregorio@google.com",
|
author_email="jcgregorio@google.com",
|
||||||
url="http://code.google.com/p/google-api-python-client/",
|
url="http://code.google.com/p/google-api-python-client/",
|
||||||
py_modules = ['apiclient', 'oauth2', 'simplejson', 'uritemplate'],
|
packages=packages,
|
||||||
license = "Apache 2.0",
|
package_data={'apiclient':['contrib/buzz/future.json',
|
||||||
keywords="google api client")
|
'contrib/latitude/future.json',
|
||||||
|
'contrib/moderator/future.json']},
|
||||||
|
license="Apache 2.0",
|
||||||
|
keywords="google api client",
|
||||||
|
classifiers=['Development Status :: 3 - Alpha',
|
||||||
|
'Intended Audience :: Developers',
|
||||||
|
'License :: OSI Approved :: Apache Software License',
|
||||||
|
'Operating System :: POSIX',
|
||||||
|
'Topic :: Internet :: WWW/HTTP'])
|
||||||
|
|
||||||
|
print 'Setup complete!'
|
||||||
|
|||||||
86
setup_utils.py
Normal file
86
setup_utils.py
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
# Copyright (C) 2010 Google Inc.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
"""Utility functions for setup.py file(s)."""
|
||||||
|
|
||||||
|
|
||||||
|
__author__ = 'tom.h.miller@gmail.com (Tom Miller)'
|
||||||
|
|
||||||
|
|
||||||
|
def get_missing_requirements():
|
||||||
|
"""Return a list of missing third party packages."""
|
||||||
|
import sys
|
||||||
|
|
||||||
|
sys_path_original = sys.path[:]
|
||||||
|
# Remove the current directory from the list of paths to check when
|
||||||
|
# importing modules.
|
||||||
|
try:
|
||||||
|
# Sometimes it's represented by an empty string?
|
||||||
|
sys.path.remove('')
|
||||||
|
except ValueError:
|
||||||
|
import os.path
|
||||||
|
sys.path.remove(os.path.abspath(os.path.curdir))
|
||||||
|
missing_pkgs = []
|
||||||
|
third_party_reqs = ['oauth2', 'httplib2']
|
||||||
|
for pkg in third_party_reqs:
|
||||||
|
try:
|
||||||
|
__import__(pkg)
|
||||||
|
except ImportError:
|
||||||
|
missing_pkgs.append(pkg)
|
||||||
|
# JSON support gets its own special logic
|
||||||
|
try:
|
||||||
|
import_json(sys.path)
|
||||||
|
except ImportError:
|
||||||
|
missing_pkgs.append('simplejson')
|
||||||
|
|
||||||
|
sys.path = sys_path_original
|
||||||
|
return missing_pkgs
|
||||||
|
|
||||||
|
|
||||||
|
def import_json(import_path=None):
|
||||||
|
"""Return a package that will provide JSON support.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
import_path: list Value to assing to sys.path before checking for packages.
|
||||||
|
Default None for default sys.path.
|
||||||
|
Return:
|
||||||
|
A package, one of 'json' (if running python 2.6),
|
||||||
|
'django.utils.simplejson' (if django is installed)
|
||||||
|
'simplejson' (if third party library simplejson is found)
|
||||||
|
Raises:
|
||||||
|
ImportError if none of those packages are found.
|
||||||
|
"""
|
||||||
|
import sys
|
||||||
|
sys_path_orig = sys.path[:]
|
||||||
|
if import_path is not None:
|
||||||
|
sys.path = import_path
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Should work for Python 2.6.
|
||||||
|
pkg = __import__('json')
|
||||||
|
except ImportError:
|
||||||
|
try:
|
||||||
|
pkg = __import__('django.utils').simplejson
|
||||||
|
except ImportError:
|
||||||
|
try:
|
||||||
|
pkg = __import__('simplejson')
|
||||||
|
except ImportError:
|
||||||
|
pkg = None
|
||||||
|
|
||||||
|
if import_path is not None:
|
||||||
|
sys.path = sys_path_orig
|
||||||
|
if pkg:
|
||||||
|
return pkg
|
||||||
|
else:
|
||||||
|
raise ImportError('Cannot find json support')
|
||||||
Reference in New Issue
Block a user