diff --git a/docs/conf.py b/docs/conf.py index 2531003..3104484 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -41,7 +41,7 @@ source_suffix = '.rst' master_doc = 'index' # General information about the project. -project = u'LdapCherry - Performance Test Framework' +project = u'LdapCherry - Directory Management Interface' copyright = u'2014, Pierre-Francois Carpentier' # The version info for the project you're documenting, acts as replacement for @@ -165,3 +165,17 @@ html_file_suffix = ".html" # Output file base name for HTML help builder. htmlhelp_basename = 'LdapCherry-docs' +try: + from unittest.mock import MagicMock + + class Mock(MagicMock): + @classmethod + def __getattr__(cls, name): + return Mock() + + MOCK_MODULES = ['cherrypy'] + sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES) +except Exception as e: + print("No Mock of cherrypy") + print(str(e)) + pass diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..a9dabc8 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +CherryPy>=3.0.0 +PyYAML +Mako +python-ldap diff --git a/setup.py b/setup.py index 483a858..4b6b317 100755 --- a/setup.py +++ b/setup.py @@ -5,13 +5,16 @@ import os import re import sys -from distutils.core import setup +from distutils.core import setup, run_setup # some install path variables sysconfdir = os.getenv("SYSCONFDIR", "/etc") -datarootdir = os.getenv("DATAROOTDIR", sys.prefix) +datarootdir = os.getenv("DATAROOTDIR", os.path.join(sys.prefix, 'share')) -data_dir = os.path.join(sys.prefix, 'share', 'ldapcherry') +# 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' # change requirements according to python version @@ -63,6 +66,13 @@ except ImportError: 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 = [] @@ -77,15 +87,16 @@ def get_list_files(basedir, targetdir): # add static files and templates in the list of thing to deploy resources_files = get_list_files( 'resources', - os.path.join(datarootdir, 'share', 'ldapcherry') + data_dir, ) +as_option_root # add the configuration files if they don't exist -if not os.path.exists( - os.path.join(sysconfdir, 'ldapcherry')): +if as_option_root() or not os.path.exists( + config_dir): resources_files.append( ( - os.path.join(sysconfdir, 'ldapcherry'), + config_dir, [ 'conf/ldapcherry.ini', 'conf/attributes.yml', @@ -94,6 +105,7 @@ if not os.path.exists( ) ) + setup( name='ldapcherry', zip_safe=False,