-
Notifications
You must be signed in to change notification settings - Fork 70
/
setup.py
executable file
·152 lines (133 loc) · 4.12 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# vim:set expandtab tabstop=4 shiftwidth=4:
import os
import re
import sys
from distutils.core import setup, run_setup
# some install path variables
sysconfdir = os.getenv("SYSCONFDIR", "/etc")
datarootdir = os.getenv("DATAROOTDIR", os.path.join(sys.prefix, 'share'))
# path to install data
data_dir = os.path.join(datarootdir, 'ldapcherry')
# path to install configuration
config_dir = os.path.join(sysconfdir, 'ldapcherry')
small_description = 'A simple web application to manage Ldap entries'
sys.path.append('ldapcherry/')
from version import version
# change requirements according to python version
if sys.version_info[0] == 2:
install_requires = [
'CherryPy >= 3.0.0,< 18.0.0',
'python-ldap',
'PyYAML',
'Mako'
],
elif sys.version_info[0] == 3:
install_requires = [
'CherryPy >= 3.0.0',
'python-ldap',
'PyYAML',
'Mako'
],
else:
print('unsupported version')
exit(1)
try:
f = open(os.path.join(os.path.dirname(__file__), 'README.rst'))
description = f.read()
f.close()
except IOError:
description = small_description
try:
license = open('LICENSE').read()
except IOError:
license = 'MIT'
try:
from setuptools import setup
from setuptools.command.test import test as TestCommand
class PyTest(TestCommand):
def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = []
self.test_suite = True
def run_tests(self):
# import here, cause outside the eggs aren't loaded
import pytest
errno = pytest.main(self.test_args)
sys.exit(errno)
except ImportError:
from distutils.core import setup
def PyTest(x):
x
def as_option_root():
for arg in sys.argv:
if re.match(r'--root.*', arg):
return True
return False
# just a small function to easily install a complete directory
def get_list_files(basedir, targetdir):
return_list = []
for root, dirs, files in os.walk(basedir):
subpath = re.sub(r'' + basedir + '[\/]*', '', root)
files_list = []
for f in files:
files_list.append(os.path.join(root, f))
return_list.append((os.path.join(targetdir, subpath), files_list))
return return_list
# add static files and templates in the list of thing to deploy
resources_files = get_list_files(
'resources',
data_dir,
)
# add the configuration files if they don't exist
if as_option_root() or not os.path.exists(
config_dir):
resources_files.append(
(
config_dir,
[
'conf/ldapcherry.ini',
'conf/attributes.yml',
'conf/roles.yml'
]
)
)
setup(
name='ldapcherry',
zip_safe=False,
version=version,
author='Pierre-Francois Carpentier',
author_email='[email protected]',
packages=[
'ldapcherry',
'ldapcherry.backend',
'ldapcherry.ppolicy'
],
data_files=resources_files,
entry_points = {
'console_scripts': ['ldapcherryd = ldapcherry.cli:main']
},
url='https://github.com/kakwa/ldapcherry',
license=license,
description=small_description,
long_description=description,
install_requires=install_requires,
tests_require=['pytest', 'pep8', 'pytidylib'],
cmdclass={'test': PyTest},
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
'Framework :: CherryPy',
'Intended Audience :: System Administrators',
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Operating System :: POSIX',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
"Topic :: System :: Systems Administration"
" :: Authentication/Directory :: LDAP",
"Topic :: System :: Systems Administration"
" :: Authentication/Directory",
],
)