PageRenderTime 726ms CodeModel.GetById 634ms app.highlight 6ms RepoModel.GetById 85ms app.codeStats 0ms

/setup.py

http://googlecl.googlecode.com/
Python | 90 lines | 65 code | 5 blank | 20 comment | 4 complexity | 945d5d409c855369c12808eae9c27e5a MD5 | raw file
 1# Copyright (C) 2010 Google Inc.
 2#
 3# Licensed under the Apache License, Version 2.0 (the "License");
 4# you may not use this file except in compliance with the License.
 5# You may obtain a copy of the License at
 6#
 7#      http://www.apache.org/licenses/LICENSE-2.0
 8#
 9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15from __future__ import with_statement
16
17try:
18  from setuptools import setup
19except ImportError:
20  from distutils.core import setup
21import os
22import shutil
23packages =['googlecl',
24           'googlecl.blogger',
25           'googlecl.calendar',
26           'googlecl.config',
27           'googlecl.contacts',
28           'googlecl.docs',
29           'googlecl.picasa',
30           'googlecl.youtube',
31           'googlecl.finance',
32           'googlecl.sites',
33           'googlecl.discovery']
34
35SCRIPT_TO_INSTALL = 'src/google'
36SCRIPT_TO_RENAME = 'src/google.py'
37
38# Safely move src/google.py to src/google
39if os.path.exists(SCRIPT_TO_INSTALL):
40  # Read size is 128*20 for no good reason.
41  # Just want to avoid reading in the whole file, and read in a multiple of 128.
42  # Shamelessly stole this function from googlecl/docs/base.py
43  def _md5_hash_file(path, read_size=2560):
44    """Return a binary md5 checksum of file at path."""
45    import hashlib
46    hash_function = hashlib.md5()
47    with open(path, 'r') as my_file:
48      data = my_file.read(read_size)
49      while data:
50        hash_function.update(data)
51        data = my_file.read(read_size)
52    return hash_function.digest()
53  # If running from trunk, SCRIPT_TO_RENAME should exist.
54  # For the distributed tarball, they should not.
55  if os.path.exists(SCRIPT_TO_RENAME) and\
56     not _md5_hash_file(SCRIPT_TO_INSTALL) == _md5_hash_file(SCRIPT_TO_RENAME):
57    print SCRIPT_TO_INSTALL + ' exists and is not the same as ' +\
58          SCRIPT_TO_RENAME
59    print 'Not trusting ' + SCRIPT_TO_INSTALL
60    print 'Please update it or remove it.'
61    exit(-1)
62else:
63  shutil.copy(SCRIPT_TO_RENAME, SCRIPT_TO_INSTALL)
64
65long_desc = """The Google Data APIs allow programmatic access to
66various Google services.  This package wraps a subset of those APIs into a
67command-line tool that makes it easy to do things like posting to a Blogger
68blog, uploading files to Picasa, or editing a Google Docs file."""
69
70setup(name="googlecl",
71      version="0.9.14",
72      description="Use (some) Google services from the command line",
73      author="Tom H. Miller",
74      author_email="tom.h.miller@gmail.com",
75      url="http://code.google.com/p/googlecl",
76      license="Apache Software License",
77      packages=packages,
78      package_dir={'googlecl':'src/googlecl'},
79      scripts=[SCRIPT_TO_INSTALL],
80      install_requires=['gdata >=1.2.4'],
81      long_description=long_desc,
82      classifiers=[
83          'Topic :: Internet :: WWW/HTTP',
84          'Environment :: Console',
85          'Development Status :: 4 - Beta',
86          'Operating System :: POSIX',
87          'Intended Audience :: Developers',
88          'Intended Audience :: End Users/Desktop'
89      ]
90     )