setup.py 2.77 KB
Newer Older
Nico Schottelius's avatar
Nico Schottelius committed
1
from distutils.core import setup
2
from distutils.errors import DistutilsError
Nico Schottelius's avatar
Nico Schottelius committed
3
import os
4
import re
5 6 7
import subprocess


8 9 10 11 12 13 14 15 16 17 18 19 20 21
# We have it only if it is a git cloned repo.
build_helper = os.path.join('bin', 'build-helper')
# Version file path.
version_file = os.path.join('cdist', 'version.py')
# If we have build-helper we could be a git repo.
if os.path.exists(build_helper):
    # Try to generate version.py.
    rv = subprocess.run([build_helper, 'version', ])
    if rv.returncode != 0:
        raise DistutilsError("Failed to generate {}".format(version_file))
else:
    # Otherwise, version.py should be present.
    if not os.path.exists(version_file):
        raise DistutilsError("Missing version file {}".format(version_file))
22 23


Darko Poljak's avatar
Darko Poljak committed
24
import cdist  # noqa
Nico Schottelius's avatar
Nico Schottelius committed
25

26

Nico Schottelius's avatar
Nico Schottelius committed
27 28 29
def data_finder(data_dir):
    entries = []
    for name in os.listdir(data_dir):
30 31 32 33 34

        # Skip .gitignore files
        if name == ".gitignore":
            continue

35 36 37 38 39
        # Skip vim swp files
        swpfile = re.search(r'^\..*\.swp$', name)
        if swpfile:
            continue

Nico Schottelius's avatar
Nico Schottelius committed
40 41 42 43 44 45 46 47
        entry = os.path.join(data_dir, name)
        if os.path.isdir(entry):
            entries.extend(data_finder(entry))
        else:
            entries.append(entry)

    return entries

Darko Poljak's avatar
Darko Poljak committed
48

Nico Schottelius's avatar
Nico Schottelius committed
49 50
cur = os.getcwd()
os.chdir("cdist")
Nico Schottelius's avatar
Nico Schottelius committed
51
package_data = data_finder("conf")
Nico Schottelius's avatar
Nico Schottelius committed
52
os.chdir(cur)
Nico Schottelius's avatar
Nico Schottelius committed
53

54

Nico Schottelius's avatar
Nico Schottelius committed
55
setup(
56 57
    name="cdist",
    packages=["cdist", "cdist.core", "cdist.exec", "cdist.util", ],
Nico Schottelius's avatar
Nico Schottelius committed
58
    package_data={'cdist': package_data},
59
    scripts=["scripts/cdist", "scripts/cdist-dump", "scripts/cdist-new-type"],
60 61 62 63
    version=cdist.version.VERSION,
    description="A Usable Configuration Management System",
    author="Nico Schottelius",
    author_email="nico-cdist-pypi@schottelius.org",
Darko Poljak's avatar
Darko Poljak committed
64
    url="https://www.cdi.st/",
65
    classifiers=[
Nico Schottelius's avatar
Nico Schottelius committed
66 67 68
        "Development Status :: 6 - Mature",
        "Environment :: Console",
        "Intended Audience :: System Administrators",
Darko Poljak's avatar
Darko Poljak committed
69
        "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",  # noqa
Nico Schottelius's avatar
Nico Schottelius committed
70 71 72 73 74 75 76 77 78 79 80 81 82
        "Operating System :: MacOS :: MacOS X",
        "Operating System :: POSIX",
        "Operating System :: POSIX :: BSD",
        "Operating System :: POSIX :: Linux",
        "Operating System :: Unix",
        "Programming Language :: Python",
        "Programming Language :: Python :: 3",
        "Topic :: System :: Boot",
        "Topic :: System :: Installation/Setup",
        "Topic :: System :: Operating System",
        "Topic :: System :: Software Distribution",
        "Topic :: Utilities"
    ],
83
    long_description='''
Nico Schottelius's avatar
Nico Schottelius committed
84
        cdist is a usable configuration management system.
85 86 87
        It adheres to the KISS principle and is being used in small up to
        enterprise grade environments.
        cdist is an alternative to other configuration management systems like
Nico Schottelius's avatar
Nico Schottelius committed
88
        cfengine, bcfg2, chef and puppet.
Nico Schottelius's avatar
Nico Schottelius committed
89 90
    '''
)