-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·110 lines (92 loc) · 3.34 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import re
try:
from setuptools import setup, find_packages
except:
sys.exit("Error: missing python-setuptools library")
# 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)
# The `manifest` dictionary now contains the package metadata
# Get the package name from the manifest
package_name = manifest["__pkg_name__"]
# Build list of all installable data files
# This will get:
# - all the files from the package `etc` subdir
# - all the files from the package `libexec` subdir
# and will define the appropriate target installation directory
print("\n====================================================")
print("Searching for data files...")
data_files = [
# ('.', ['LICENSE', 'README.rst', 'requirements.txt', 'version.py'])
]
for subdir, dirs, files in os.walk(package_name):
target = None
# Plugins directory
if subdir and 'libexec' in subdir:
target = os.path.join('var/libexec/alignak',
re.sub(r"^(%s\/|%s$)" % (
os.path.join(package_name, 'libexec'),
os.path.join(package_name, 'libexec')),
"", subdir))
# Configuration directory
elif subdir and 'etc' in subdir:
target = os.path.join('etc/alignak',
re.sub(r"^(%s\/|%s$)" % (
os.path.join(package_name, 'etc'),
os.path.join(package_name, 'etc')),
"", subdir))
if target is None:
print("Ignoring directory: %s" % (subdir))
continue
package_files = []
for file in files:
# Ignore files which name starts with __
if file.startswith('__'):
continue
package_files.append(os.path.join(subdir, file))
if package_files:
data_files.append((target, package_files))
for (target, origin) in data_files:
print("Target directory: %s:" % (target))
for file in origin:
print(" - %s" % (file))
print("====================================================\n")
setup(
# Package name and version
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["__git_url__"],
license=manifest["__license__"],
description=manifest["__description__"],
long_description=open('README.rst').read(),
classifiers = manifest["__classifiers__"],
# 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 distributed files
data_files = data_files,
# Dependencies (if some) ...
install_requires=[],
# Entry points (if some) ...
entry_points={
},
)