script/lib/tweetstream/setup.py
author Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
Mon, 20 Feb 2012 01:35:15 +0100
changeset 527 80e5b9543cac
parent 244 d4b7d6e2633f
parent 14 10e7a0c7c64f
permissions -rw-r--r--
Merge with 9d7218514a08006f925f138df88d770b29fae4cc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
244
d4b7d6e2633f migrate twitter processor to use object buffer and add tests
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
     1
#@PydevCodeAnalysisIgnore
14
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
     2
import sys
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
     3
import os
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
     4
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
     5
extra = {}
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
     6
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
     7
    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
     8
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
     9
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    10
try:
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    11
    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
    12
except ImportError:
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    13
    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
    14
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    15
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    16
# -*- Distribution Meta -*-
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    17
import re
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    18
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
    19
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
    20
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
    21
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
    22
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    23
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    24
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
    25
    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
    26
    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
    27
12
4daf47fcf792 move lib and prepare tweetstream for modification
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    28
14
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    29
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
    30
    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
    31
    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
    32
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    33
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    34
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
    35
    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
    36
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    37
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
    38
        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
    39
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
    40
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
    41
try:
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    42
    meta = {}
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    43
    acc = []
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    44
    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
    45
        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
    46
            break
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    47
        acc.append(line)
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    48
        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
    49
            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
    50
            if m:
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    51
                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
    52
    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
    53
    if m:
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    54
        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
    55
finally:
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    56
    meta_fh.close()
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    57
12
4daf47fcf792 move lib and prepare tweetstream for modification
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    58
4daf47fcf792 move lib and prepare tweetstream for modification
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    59
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
    60
    version=meta["VERSION"],
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    61
    description=meta["doc"],
12
4daf47fcf792 move lib and prepare tweetstream for modification
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    62
    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
    63
    classifiers=[
4daf47fcf792 move lib and prepare tweetstream for modification
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    64
        '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
    65
        '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
    66
        '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
    67
        '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
    68
        '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
    69
        '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
    70
    ],
4daf47fcf792 move lib and prepare tweetstream for modification
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    71
    keywords='twitter',
14
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    72
    author=meta["author"],
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    73
    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
    74
    url=meta["homepage"],
12
4daf47fcf792 move lib and prepare tweetstream for modification
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    75
    license='BSD',
4daf47fcf792 move lib and prepare tweetstream for modification
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    76
    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
    77
    include_package_data=True,
4daf47fcf792 move lib and prepare tweetstream for modification
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    78
    zip_safe=False,
4daf47fcf792 move lib and prepare tweetstream for modification
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    79
    platforms=["any"],
14
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    80
    install_requires=['anyjson'],
10e7a0c7c64f upgrade tweet stream to 1.1.1
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents: 13
diff changeset
    81
    **extra
12
4daf47fcf792 move lib and prepare tweetstream for modification
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff changeset
    82
)