1#!/usr/bin/env python3
2import os
3import shutil
4
5from setuptools import Command
6from setuptools import setup
7
8NAME = "tiamat"
9DESC = "Single binary builder for Python projects"
10
11# Version info -- read without importing
12_locals = {}
13with open(f"{NAME}/version.py") as fp:
14    exec(fp.read(), None, _locals)
15VERSION = _locals["version"]
16SETUP_DIRNAME = os.path.dirname(__file__)
17if not SETUP_DIRNAME:
18    SETUP_DIRNAME = os.getcwd()
19
20with open("README.rst", encoding="utf-8") as f:
21    LONG_DESC = f.read()
22
23with open("requirements/base.txt") as f:
24    REQUIREMENTS = f.read().splitlines()
25
26
27class Clean(Command):
28    user_options = []
29
30    def initialize_options(self):
31        pass
32
33    def finalize_options(self):
34        pass
35
36    def run(self):
37        for subdir in (NAME, "tests"):
38            for root, dirs, files in os.walk(
39                os.path.join(os.path.dirname(__file__), subdir)
40            ):
41                for dir_ in dirs:
42                    if dir_ == "__pycache__":
43                        shutil.rmtree(os.path.join(root, dir_))
44
45
46def discover_packages():
47    modules = []
48    for package in (NAME,):
49        for root, _, files in os.walk(os.path.join(SETUP_DIRNAME, package)):
50            pdir = os.path.relpath(root, SETUP_DIRNAME)
51            modname = pdir.replace(os.sep, ".")
52            modules.append(modname)
53    return modules
54
55
56setup(
57    name=NAME,
58    author="",
59    author_email="",
60    url="https://gitlab.com/saltstack/pop/tiamat",
61    version=VERSION,
62    install_requires=REQUIREMENTS,
63    description=DESC,
64    long_description=LONG_DESC,
65    long_description_content_type="text/x-rst",
66    python_requires=">=3.6",
67    classifiers=[
68        "Operating System :: OS Independent",
69        "Programming Language :: Python",
70        "Programming Language :: Python :: 3.6",
71        "Programming Language :: Python :: 3.7",
72        "Programming Language :: Python :: 3.8",
73        "Development Status :: 5 - Production/Stable",
74    ],
75    packages=discover_packages(),
76    entry_points={
77        "console_scripts": [
78            "tiamat = tiamat.scripts:start",
79        ],
80    },
81    cmdclass={"clean": Clean},
82)
83