2014-06-02 23:10:19 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# vim:set expandtab tabstop=4 shiftwidth=4:
|
|
|
|
|
|
|
|
import os
|
|
|
|
import re
|
|
|
|
import sys
|
2015-07-19 23:43:36 +02:00
|
|
|
from distutils.core import setup, run_setup
|
2014-06-02 23:10:19 +02:00
|
|
|
|
2015-07-10 21:00:19 +02:00
|
|
|
# some install path variables
|
2014-06-02 23:10:19 +02:00
|
|
|
sysconfdir = os.getenv("SYSCONFDIR", "/etc")
|
2015-07-19 23:43:36 +02:00
|
|
|
datarootdir = os.getenv("DATAROOTDIR", os.path.join(sys.prefix, 'share'))
|
2014-06-02 23:10:19 +02:00
|
|
|
|
2015-07-19 23:43:36 +02:00
|
|
|
# path to install data
|
|
|
|
data_dir = os.path.join(datarootdir, 'ldapcherry')
|
|
|
|
# path to install configuration
|
|
|
|
config_dir = os.path.join(sysconfdir, 'ldapcherry')
|
2014-06-02 23:10:19 +02:00
|
|
|
small_description = 'A simple web application to manage Ldap entries'
|
|
|
|
|
2017-04-06 20:46:58 +02:00
|
|
|
sys.path.append('ldapcherry/')
|
|
|
|
from version import version
|
2017-04-06 20:21:31 +02:00
|
|
|
|
2014-06-02 23:10:19 +02:00
|
|
|
# change requirements according to python version
|
|
|
|
if sys.version_info[0] == 2:
|
|
|
|
install_requires = [
|
2019-02-09 12:12:24 +01:00
|
|
|
'CherryPy >= 3.0.0,< 18.0.0',
|
2014-06-02 23:10:19 +02:00
|
|
|
'python-ldap',
|
2015-05-12 11:31:58 +02:00
|
|
|
'PyYAML',
|
2014-06-02 23:10:19 +02:00
|
|
|
'Mako'
|
|
|
|
],
|
|
|
|
elif sys.version_info[0] == 3:
|
2019-02-07 20:34:49 +01:00
|
|
|
install_requires = [
|
|
|
|
'CherryPy >= 3.0.0',
|
|
|
|
'python-ldap',
|
|
|
|
'PyYAML',
|
|
|
|
'Mako'
|
|
|
|
],
|
2014-06-02 23:10:19 +02:00
|
|
|
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
|
2015-07-05 22:48:24 +02:00
|
|
|
|
2014-06-02 23:10:19 +02:00
|
|
|
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):
|
2015-07-10 21:00:19 +02:00
|
|
|
# import here, cause outside the eggs aren't loaded
|
2014-06-02 23:10:19 +02:00
|
|
|
import pytest
|
|
|
|
errno = pytest.main(self.test_args)
|
|
|
|
sys.exit(errno)
|
|
|
|
except ImportError:
|
|
|
|
from distutils.core import setup
|
2015-07-11 23:19:41 +02:00
|
|
|
|
|
|
|
def PyTest(x):
|
|
|
|
x
|
2014-06-02 23:10:19 +02:00
|
|
|
|
2015-07-10 21:00:19 +02:00
|
|
|
|
2015-07-19 23:43:36 +02:00
|
|
|
def as_option_root():
|
|
|
|
for arg in sys.argv:
|
|
|
|
if re.match(r'--root.*', arg):
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
2014-06-02 23:10:19 +02:00
|
|
|
# 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
|
|
|
|
|
2015-05-28 00:17:59 +02:00
|
|
|
# add static files and templates in the list of thing to deploy
|
2015-07-10 21:00:19 +02:00
|
|
|
resources_files = get_list_files(
|
|
|
|
'resources',
|
2015-07-19 23:43:36 +02:00
|
|
|
data_dir,
|
2015-07-10 21:00:19 +02:00
|
|
|
)
|
2014-06-02 23:10:19 +02:00
|
|
|
|
2015-05-28 00:17:59 +02:00
|
|
|
# add the configuration files if they don't exist
|
2015-07-19 23:43:36 +02:00
|
|
|
if as_option_root() or not os.path.exists(
|
|
|
|
config_dir):
|
2015-07-10 21:00:19 +02:00
|
|
|
resources_files.append(
|
|
|
|
(
|
2015-07-19 23:43:36 +02:00
|
|
|
config_dir,
|
2015-07-10 21:00:19 +02:00
|
|
|
[
|
|
|
|
'conf/ldapcherry.ini',
|
|
|
|
'conf/attributes.yml',
|
|
|
|
'conf/roles.yml'
|
|
|
|
]
|
|
|
|
)
|
|
|
|
)
|
2014-06-02 23:10:19 +02:00
|
|
|
|
2015-07-19 23:43:36 +02:00
|
|
|
|
2014-06-02 23:10:19 +02:00
|
|
|
setup(
|
2015-07-10 21:00:19 +02:00
|
|
|
name='ldapcherry',
|
|
|
|
zip_safe=False,
|
2017-04-06 20:21:31 +02:00
|
|
|
version=version,
|
2015-07-10 21:00:19 +02:00
|
|
|
author='Pierre-Francois Carpentier',
|
|
|
|
author_email='carpentier.pf@gmail.com',
|
|
|
|
packages=[
|
|
|
|
'ldapcherry',
|
|
|
|
'ldapcherry.backend',
|
|
|
|
'ldapcherry.ppolicy'
|
|
|
|
],
|
|
|
|
data_files=resources_files,
|
2019-02-07 20:34:49 +01:00
|
|
|
entry_points = {
|
|
|
|
'console_scripts': ['ldapcherryd = ldapcherry.cli:main']
|
|
|
|
},
|
2015-07-10 21:00:19 +02:00
|
|
|
url='https://github.com/kakwa/ldapcherry',
|
|
|
|
license=license,
|
|
|
|
description=small_description,
|
|
|
|
long_description=description,
|
|
|
|
install_requires=install_requires,
|
|
|
|
tests_require=['pytest', 'pep8'],
|
|
|
|
cmdclass={'test': PyTest},
|
|
|
|
classifiers=[
|
|
|
|
'Development Status :: 3 - Alpha',
|
|
|
|
'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',
|
2015-07-21 08:54:07 +02:00
|
|
|
"Topic :: System :: Systems Administration"
|
|
|
|
" :: Authentication/Directory :: LDAP",
|
|
|
|
"Topic :: System :: Systems Administration"
|
|
|
|
" :: Authentication/Directory",
|
2015-07-10 21:00:19 +02:00
|
|
|
],
|
2014-06-02 23:10:19 +02:00
|
|
|
)
|