script/lib/tweetstream/setup.py
author Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
Mon, 20 Feb 2012 00:12:16 +0100
changeset 14 10e7a0c7c64f
parent 13 79b6e132e3d7
child 527 80e5b9543cac
permissions -rw-r--r--
upgrade tweet stream to 1.1.1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
     1
import sys
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
     2
import os
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
     3
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
     4
extra = {}
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
     5
if sys.version_info >= (3, 0):
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
     6
    extra.update(use_2to3=True)
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
     7
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
     8
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
     9
try:
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    10
    from setuptools import setup, find_packages
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    11
except ImportError:
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    12
    from distutils.core import setup, find_packages
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    13
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    14
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    15
# -*- Distribution Meta -*-
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    16
import re
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    17
re_meta = re.compile(r'__(\w+?)__\s*=\s*(.*)')
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    18
re_vers = re.compile(r'VERSION\s*=\s*\((.*?)\)')
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    19
re_doc = re.compile(r'^"""(.+?)"""', re.M|re.S)
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    20
rq = lambda s: s.strip("\"'")
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    21
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    22
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    23
def add_default(m):
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    24
    attr_name, attr_value = m.groups()
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    25
    return ((attr_name, rq(attr_value)), )
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    26
12
4daf47fcf792 move lib and prepare tweetstream for modification
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    27
14
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    28
def add_version(m):
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    29
    v = list(map(rq, m.groups()[0].split(", ")))
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    30
    return (("VERSION", ".".join(v[0:3]) + "".join(v[3:])), )
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    31
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    32
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    33
def add_doc(m):
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    34
    return (("doc", m.groups()[0].replace("\n", " ")), )
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    35
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    36
pats = {re_meta: add_default,
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    37
        re_vers: add_version}
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    38
here = os.path.abspath(os.path.dirname(__file__))
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    39
meta_fh = open(os.path.join(here, "tweetstream/__init__.py"))
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    40
try:
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    41
    meta = {}
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    42
    acc = []
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    43
    for line in meta_fh:
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    44
        if line.strip() == '# -eof meta-':
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    45
            break
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    46
        acc.append(line)
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    47
        for pattern, handler in pats.items():
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    48
            m = pattern.match(line.strip())
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    49
            if m:
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    50
                meta.update(handler(m))
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    51
    m = re_doc.match("".join(acc).strip())
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    52
    if m:
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    53
        meta.update(add_doc(m))
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    54
finally:
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    55
    meta_fh.close()
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    56
12
4daf47fcf792 move lib and prepare tweetstream for modification
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    57
4daf47fcf792 move lib and prepare tweetstream for modification
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    58
setup(name='tweetstream',
14
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    59
    version=meta["VERSION"],
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    60
    description=meta["doc"],
12
4daf47fcf792 move lib and prepare tweetstream for modification
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    61
    long_description=open("README").read(),
4daf47fcf792 move lib and prepare tweetstream for modification
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    62
    classifiers=[
4daf47fcf792 move lib and prepare tweetstream for modification
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    63
        'License :: OSI Approved :: BSD License',
4daf47fcf792 move lib and prepare tweetstream for modification
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    64
        'Intended Audience :: Developers',
14
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    65
        'Programming Language :: Python :: 2.6',
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    66
        'Programming Language :: Python :: 2.7',
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    67
        'Programming Language :: Python :: 3',
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    68
        'Programming Language :: Python :: 3.1',
12
4daf47fcf792 move lib and prepare tweetstream for modification
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    69
    ],
4daf47fcf792 move lib and prepare tweetstream for modification
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    70
    keywords='twitter',
14
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    71
    author=meta["author"],
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    72
    author_email=meta["contact"],
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    73
    url=meta["homepage"],
12
4daf47fcf792 move lib and prepare tweetstream for modification
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    74
    license='BSD',
4daf47fcf792 move lib and prepare tweetstream for modification
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    75
    packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
4daf47fcf792 move lib and prepare tweetstream for modification
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    76
    include_package_data=True,
4daf47fcf792 move lib and prepare tweetstream for modification
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    77
    zip_safe=False,
4daf47fcf792 move lib and prepare tweetstream for modification
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    78
    platforms=["any"],
14
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    79
    install_requires=['anyjson'],
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    80
    **extra
12
4daf47fcf792 move lib and prepare tweetstream for modification
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    81
)