setup.py 3.76 KB
Newer Older
1 2 3 4
#!/usr/bin/env python

from setuptools import setup, find_packages
import os
5
import subprocess
6

7 8 9 10 11 12
try:
    import pypandoc
    README = pypandoc.convert('README.md', 'rst')
except(IOError, ImportError):
    README = open('README.md').read()

13 14 15 16 17 18 19 20 21 22
try:
    unicode
except NameError:
    # Required for Python 3.x
    class unicode(object):
        def __new__(cls, s):
            if isinstance(s, str):
                return s
            return s and s.decode('utf-8') or None

23 24 25 26
SCRIPTS = [os.path.join('bin', n) for n in [
    'debops', 'debops-init', 'debops-task',
    'debops-defaults', 'debops-padlock', 'debops-update']]

27 28 29 30 31 32
# Retrieve the project version from 'git describe' command and store it in the
# VERSION file, needed for correct installation of the Python package
try:
    with open(os.devnull, 'w') as devnull:
        RELEASE = subprocess.check_output(
                ['git describe'], shell=True, stderr=devnull
33
                ).strip(b'\n').lstrip(b'v')
34 35 36 37 38 39 40
    with open('VERSION', 'w') as version_file:
        version_file.write('{}\n'.format(RELEASE))
except subprocess.CalledProcessError:
    try:
        RELEASE = open('VERSION').read().strip()
    except Exception:
        RELEASE = '0.0.0'
41

42 43 44 45 46
try:
    # Symlink the 'ansible/' directory inside of the 'debops/' Python package
    # directory. The files will be included in the package using the
    # MANIFEST.in file. This requires 'python-setuptools' APT package from
    # 'jessie-backports' repository.
47 48
    if os.path.exists('.git') and os.path.isdir('.git'):
        os.symlink('../ansible', 'debops/ansible')
49 50
    setup(
        name="debops",
51
        version=unicode(RELEASE),
52
        install_requires=['netaddr', 'argparse', 'passlib', 'ansible'],
53

54 55 56
        scripts=SCRIPTS,
        packages=find_packages(exclude=['tests']),
        include_package_data=True,
57

58 59 60 61 62 63 64 65 66 67 68
        # metadata for upload to PyPI
        author="DebOps Developers",
        author_email="[email protected]",
        description="Your Debian-based data center in a box",
        long_description=README,
        license="GPL-3.0",
        keywords="ansible debian sysadmin",
        url="https://debops.org/",
        python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, '
                        '!=3.3.*, !=3.4.*, <4',
        download_url="https://github.com/debops/debops"
69
                    "/archive/v" + unicode(RELEASE) + ".tar.gz",
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
        classifiers=[
                    'Development Status :: 4 - Beta',
                    'Environment :: Console',
                    'Intended Audience :: Information Technology',
                    'Intended Audience :: System Administrators',
                    'License :: OSI Approved :: GNU General Public License v3 '
                    'or later (GPLv3+)',
                    'Natural Language :: English',
                    'Operating System :: POSIX',
                    'Programming Language :: Other Scripting Engines',
                    'Programming Language :: Python',
                    'Programming Language :: Python :: 2',
                    'Programming Language :: Python :: 2.7',
                    'Programming Language :: Python :: 3',
                    'Programming Language :: Python :: 3.5',
                    'Programming Language :: Python :: 3.6',
                    'Topic :: System :: Installation/Setup',
                    'Topic :: System :: Systems Administration',
                    'Topic :: Utilities'
        ],
90

91 92 93 94 95 96 97 98 99 100
        # these are for easy_install (used by bdist_*)
        zip_safe=True
        #    entry_points = {
        #        "console_scripts": [
        #            "debops = debops.cmds.main:run",
        #        ],
        #    },
    )
finally:
    # Unlink the symlinked 'ansible/' directory
101 102
    if os.path.islink('debops/ansible'):
        os.unlink('debops/ansible')