1#!/usr/bin/env python
2
3##
4## You can download latest version of this file:
5##  $ wget https://gist.github.com/vaab/e0eae9607ae806b662d4/raw -O setup.py
6##  $ chmod +x setup.py
7##
8## This setup.py is meant to be run along with ``./autogen.sh`` that
9## you can also find here: https://gist.github.com/vaab/9118087/raw
10##
11
12try:
13    from setuptools import setup
14except ImportError:
15    from distribute_setup import use_setuptools
16    use_setuptools()
17    from setuptools import setup
18
19##
20## Ensure that ``./autogen.sh`` is run prior to using ``setup.py``
21##
22
23if "0.1.5".startswith("%%"):
24    import os.path
25    import sys
26    WIN32 = sys.platform == 'win32'
27    autogen = os.path.join(".", "autogen.sh")
28    if not os.path.exists(autogen):
29        sys.stderr.write(
30            "This source repository was not configured.\n"
31            "Please ensure ``./autogen.sh`` exists and that you are running "
32            "``setup.py`` from the project root directory.\n")
33        sys.exit(1)
34    if os.path.exists('.autogen.sh.output'):
35        sys.stderr.write(
36            "It seems that ``./autogen.sh`` couldn't do its job as expected.\n"
37            "Please try to launch ``./autogen.sh`` manualy, and send the "
38            "results to the\nmaintainer of this package.\n"
39            "Package will not be installed !\n")
40        sys.exit(1)
41    sys.stderr.write("Missing version information: "
42                     "running './autogen.sh'...\n")
43    import os
44    import subprocess
45    os.system('%s%s > .autogen.sh.output'
46              % ("bash " if WIN32 else "",
47                 autogen))
48    cmdline = sys.argv[:]
49    if cmdline[0] == "-c":
50        ## for some reason, this is needed when launched from pip
51        cmdline[0] = "setup.py"
52    errlvl = subprocess.call(["python", ] + cmdline)
53    os.unlink(".autogen.sh.output")
54    sys.exit(errlvl)
55
56
57##
58## Normal d2to1 setup
59##
60
61setup(
62    setup_requires=['d2to1'],
63    extras_require={'test': ['nose', ]},
64    d2to1=True
65)
66