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