/setup.py

http://googlecl.googlecode.com/ · Python · 90 lines · 64 code · 6 blank · 20 comment · 7 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. from __future__ import with_statement
  15. try:
  16. from setuptools import setup
  17. except ImportError:
  18. from distutils.core import setup
  19. import os
  20. import shutil
  21. packages =['googlecl',
  22. 'googlecl.blogger',
  23. 'googlecl.calendar',
  24. 'googlecl.config',
  25. 'googlecl.contacts',
  26. 'googlecl.docs',
  27. 'googlecl.picasa',
  28. 'googlecl.youtube',
  29. 'googlecl.finance',
  30. 'googlecl.sites',
  31. 'googlecl.discovery']
  32. SCRIPT_TO_INSTALL = 'src/google'
  33. SCRIPT_TO_RENAME = 'src/google.py'
  34. # Safely move src/google.py to src/google
  35. if os.path.exists(SCRIPT_TO_INSTALL):
  36. # Read size is 128*20 for no good reason.
  37. # Just want to avoid reading in the whole file, and read in a multiple of 128.
  38. # Shamelessly stole this function from googlecl/docs/base.py
  39. def _md5_hash_file(path, read_size=2560):
  40. """Return a binary md5 checksum of file at path."""
  41. import hashlib
  42. hash_function = hashlib.md5()
  43. with open(path, 'r') as my_file:
  44. data = my_file.read(read_size)
  45. while data:
  46. hash_function.update(data)
  47. data = my_file.read(read_size)
  48. return hash_function.digest()
  49. # If running from trunk, SCRIPT_TO_RENAME should exist.
  50. # For the distributed tarball, they should not.
  51. if os.path.exists(SCRIPT_TO_RENAME) and\
  52. not _md5_hash_file(SCRIPT_TO_INSTALL) == _md5_hash_file(SCRIPT_TO_RENAME):
  53. print SCRIPT_TO_INSTALL + ' exists and is not the same as ' +\
  54. SCRIPT_TO_RENAME
  55. print 'Not trusting ' + SCRIPT_TO_INSTALL
  56. print 'Please update it or remove it.'
  57. exit(-1)
  58. else:
  59. shutil.copy(SCRIPT_TO_RENAME, SCRIPT_TO_INSTALL)
  60. long_desc = """The Google Data APIs allow programmatic access to
  61. various Google services. This package wraps a subset of those APIs into a
  62. command-line tool that makes it easy to do things like posting to a Blogger
  63. blog, uploading files to Picasa, or editing a Google Docs file."""
  64. setup(name="googlecl",
  65. version="0.9.14",
  66. description="Use (some) Google services from the command line",
  67. author="Tom H. Miller",
  68. author_email="tom.h.miller@gmail.com",
  69. url="http://code.google.com/p/googlecl",
  70. license="Apache Software License",
  71. packages=packages,
  72. package_dir={'googlecl':'src/googlecl'},
  73. scripts=[SCRIPT_TO_INSTALL],
  74. install_requires=['gdata >=1.2.4'],
  75. long_description=long_desc,
  76. classifiers=[
  77. 'Topic :: Internet :: WWW/HTTP',
  78. 'Environment :: Console',
  79. 'Development Status :: 4 - Beta',
  80. 'Operating System :: POSIX',
  81. 'Intended Audience :: Developers',
  82. 'Intended Audience :: End Users/Desktop'
  83. ]
  84. )