setup.py 2.79 KB
Newer Older
Vincent Pelletier's avatar
Vincent Pelletier committed
1 2 3
from os.path import join, exists
from setuptools import setup, find_packages
import hashlib
4
import os
Vincent Pelletier's avatar
Vincent Pelletier committed
5
import sys
6 7 8 9 10 11
extra = {}
if sys.version_info >= (3, ):
  extra['use_2to3'] = True
  from urllib.request import urlretrieve
else:
  from urllib import urlretrieve
Vincent Pelletier's avatar
Vincent Pelletier committed
12 13 14 15

FLOT_SHA = 'aefe4e729b2d14efe6e8c0db359cb0e9aa6aae52'
FLOT_AXISLABELS_SHA = '80453cd7fb8a9cad084cf6b581034ada3339dbf8'
JQUERY_VERSION = '1.9.1'
16
JQUERY_UI_VERSION = '1.10.2'
Vincent Pelletier's avatar
Vincent Pelletier committed
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35

DEPS = {
  'jquery.flot.js': (
    'http://raw.github.com/flot/flot/%s/jquery.flot.js' % FLOT_SHA,
    '7b599c575f19c33bf0d93a6bbac3af02',
  ),
  'jquery.flot.time.js': (
    'http://raw.github.com/flot/flot/%s/jquery.flot.time.js' % FLOT_SHA,
    'c0aec1608bf2fbb79f24d1905673e2c3',
  ),
  'jquery.flot.axislabels.js': (
    'http://raw.github.com/markrcote/flot-axislabels/%s/'
      'jquery.flot.axislabels.js' % FLOT_AXISLABELS_SHA,
    'a8526e0c1ed3b5cbc1a6b3ebb22bf334',
  ),
  'jquery.js': (
    'http://code.jquery.com/jquery-%s.min.js' % JQUERY_VERSION,
    '397754ba49e9e0cf4e7c190da78dda05',
  ),
36 37 38 39
  'jquery-ui.js': (
    'http://code.jquery.com/ui/%s/jquery-ui.min.js' % JQUERY_UI_VERSION,
    '3e6acb1e6426ef90d2e786a006a4ea28',
  ),
Vincent Pelletier's avatar
Vincent Pelletier committed
40 41
}

42 43
_file_dirname = os.path.dirname(__file__)

Vincent Pelletier's avatar
Vincent Pelletier committed
44
def download(url, filename, hexdigest):
45
  filename = join(_file_dirname, 'apachedex', filename)
Vincent Pelletier's avatar
Vincent Pelletier committed
46
  if not exists(filename):
47 48
    urlretrieve(url, filename)
  if hashlib.md5(open(filename, 'rb').read()).hexdigest() != hexdigest:
Vincent Pelletier's avatar
Vincent Pelletier committed
49 50 51 52 53 54 55 56 57
    raise EnvironmentError('Checksum mismatch downloading %r' % filename)

for filename, (url, hexdigest) in DEPS.items():
  download(url, filename, hexdigest)

# XXX: turn this into a setuptool command ?
if sys.argv[1:] == ['deps']:
  sys.exit(0)

58
description = open(join(_file_dirname, 'README.rst')).read()
Vincent Pelletier's avatar
Vincent Pelletier committed
59 60 61

setup(
  name='APacheDEX',
Vincent Pelletier's avatar
Vincent Pelletier committed
62
  version='1.6',
63
  description=next(x for x in description.splitlines() if x.strip()),
Vincent Pelletier's avatar
Vincent Pelletier committed
64 65 66 67 68 69 70 71 72 73 74
  long_description=".. contents::\n\n" + description,
  author='Vincent Pelletier',
  author_email='vincent@nexedi.com',
  url='http://git.erp5.org/gitweb/apachedex.git',
  license='GPL 2+',
  platforms=['any'],
  classifiers=[
    'Intended Audience :: Developers',
    'License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)',
    'Operating System :: OS Independent',
    'Programming Language :: Python :: 2.7',
75
    'Programming Language :: Python :: 3',
Vincent Pelletier's avatar
Vincent Pelletier committed
76 77 78 79 80 81 82 83 84 85 86 87 88
    'Programming Language :: Python :: Implementation :: PyPy',
    'Programming Language :: Python :: Implementation :: CPython',
    'Topic :: System :: Logging',
    'Topic :: Text Processing :: Filters',
    'Topic :: Text Processing :: Markup :: HTML',
  ],
  packages=find_packages(),
  entry_points = {
    'console_scripts': [
      'apachedex=apachedex:main',
    ],
  },
  package_data={
89
    'apachedex': list(DEPS.keys()) + ['apachedex.js', 'apachedex.css'],
Vincent Pelletier's avatar
Vincent Pelletier committed
90 91
  },
  zip_safe=True,
92
  **extra
Vincent Pelletier's avatar
Vincent Pelletier committed
93
)