-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
executable file
·119 lines (97 loc) · 3.47 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
del os.link
from alignak_setup.tools import get_alignak_cfg, get_files, get_to_be_installed_files, parse_files
try:
import distutils.core
from distutils.command.install_data import install_data as _install_data
from setuptools import setup, find_packages
from setuptools.command.install import install as _install
from setuptools.command.develop import develop as _develop
except:
sys.exit("Error: missing python-setuptools library")
try:
python_version = sys.version_info
except:
python_version = (1, 5)
if python_version < (2, 6):
sys.exit("This application requires a minimum Python 2.6.x, sorry!")
elif python_version >= (3,):
sys.exit("This application is not yet compatible with Python 3.x, sorry!")
# Better to use exec to load the package information from a version.py file
# so to not have to import the package. as of it, the setup.py do not need to be modified
# for each package that is built from this one...
with open(os.path.join('version.py')) as fh:
manifest = {}
exec(fh.read(), manifest)
# Overloading setup.py install_data
class my_install_data(_install_data):
"""
Overload the default copy of files
"""
def run(self):
"""
Overload the default copy of files:
"""
self.data_files = get_to_be_installed_files(self.data_files)
# Setuptools install_data ...
_install_data.run(self)
# After data files installation ...
# ... parse configuration files to update installation dir
if self.data_files:
parse_files(to_be_parsed_files, alignak_cfg)
# Get default Alignak paths ...
alignak_cfg = get_alignak_cfg()
if not alignak_cfg:
sys.exit("Alignak default paths not found!")
# Build list of all installable package files
(data_files, to_be_parsed_files, to_be_installed_files) = get_files(
alignak_cfg, manifest["__pkg_name__"], manifest["__module_types__"], module=True
)
setup(
name=manifest["__pkg_name__"],
version=manifest["__version__"],
# Metadata for PyPI
author=manifest["__author__"],
author_email=manifest["__author_email__"],
keywords="alignak monitoring module " + manifest["__module_types__"],
url=manifest["__url__"],
license=manifest["__license__"],
description=manifest["__description__"],
long_description=open('README.rst').read(),
classifiers = [
'Development Status :: 5 - Production/Stable',
'Environment :: Console',
'Intended Audience :: Developers',
'Intended Audience :: System Administrators',
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Natural Language :: English',
'Programming Language :: Python',
'Topic :: System :: Monitoring',
'Topic :: System :: Systems Administration'
],
# Unzip Egg
zip_safe=False,
# Package data
packages=find_packages(),
include_package_data=True,
package_data={
'': 'README.rst',
'': 'AUTHORS',
'': 'LICENSE',
'': [os.path.join(manifest["__pkg_name__"], '*')],
},
# Where to install which file ...
# All pack files are installed at the same place.
data_files = data_files,
# Dependencies (if some) ...
install_requires=['alignak_setup'],
# Entry points (if some) ...
entry_points={
},
cmdclass={
'install_data': my_install_data, # override install_data to set a post install hook
}
)