setup.py 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. """
  2. setup.py - Setup package with the help Python's DistUtils
  3. See http://www.python-ldap.org/ for details.
  4. $Id: setup.py,v 1.71 2011/10/26 19:42:25 stroeder Exp $
  5. """
  6. has_setuptools = False
  7. try:
  8. from setuptools import setup, Extension
  9. has_setuptools = True
  10. except ImportError:
  11. from distutils.core import setup, Extension
  12. from ConfigParser import ConfigParser
  13. import sys,os,string,time
  14. ##################################################################
  15. # Weird Hack to grab release version of python-ldap from local dir
  16. ##################################################################
  17. exec_startdir = os.path.dirname(os.path.abspath(sys.argv[0]))
  18. package_init_file_name = reduce(os.path.join,[exec_startdir,'Lib','ldap','__init__.py'])
  19. f = open(package_init_file_name,'r')
  20. s = f.readline()
  21. while s:
  22. s = string.strip(s)
  23. if s[0:11]=='__version__':
  24. version = eval(string.split(s,'=')[1])
  25. break
  26. s = f.readline()
  27. f.close()
  28. #-- A class describing the features and requirements of OpenLDAP 2.0
  29. class OpenLDAP2:
  30. library_dirs = []
  31. include_dirs = []
  32. extra_compile_args = []
  33. extra_link_args = []
  34. extra_objects = []
  35. libs = ['ldap', 'lber']
  36. defines = [ ]
  37. extra_files = []
  38. LDAP_CLASS = OpenLDAP2
  39. #-- Read the [_ldap] section of setup.cfg
  40. cfg = ConfigParser()
  41. cfg.read('setup.cfg')
  42. if cfg.has_section('_ldap'):
  43. for name in dir(LDAP_CLASS):
  44. if cfg.has_option('_ldap', name):
  45. print name + ': ' + cfg.get('_ldap', name)
  46. setattr(LDAP_CLASS, name, string.split(cfg.get('_ldap', name)))
  47. for i in range(len(LDAP_CLASS.defines)):
  48. LDAP_CLASS.defines[i]=((LDAP_CLASS.defines[i],None))
  49. for i in range(len(LDAP_CLASS.extra_files)):
  50. destdir, origfiles = string.split(LDAP_CLASS.extra_files[i], ':')
  51. origfileslist = string.split(origfiles, ',')
  52. LDAP_CLASS.extra_files[i]=(destdir, origfileslist)
  53. #-- Let distutils/setuptools do the rest
  54. name = 'python-ldap'
  55. # Python 2.3.6+ and setuptools are needed to build eggs, so
  56. # let's handle setuptools' additional keyword arguments to
  57. # setup() in a fashion that doesn't break compatibility to
  58. # distutils. This still allows 'normal' builds where either
  59. # Python > 2.3.5 or setuptools (or both ;o) are not available.
  60. kwargs = dict()
  61. if has_setuptools:
  62. kwargs = dict(
  63. include_package_data = True,
  64. install_requires = ['setuptools'],
  65. zip_safe = False
  66. )
  67. setup(
  68. #-- Package description
  69. name = name,
  70. version = version,
  71. description = 'Python modules for implementing LDAP clients',
  72. long_description = """python-ldap:
  73. python-ldap provides an object-oriented API to access LDAP directory servers
  74. from Python programs. Mainly it wraps the OpenLDAP 2.x libs for that purpose.
  75. Additionally the package contains modules for other LDAP-related stuff
  76. (e.g. processing LDIF, LDAPURLs, LDAPv3 schema, LDAPv3 extended operations
  77. and controls, etc.).
  78. """,
  79. author = 'python-ldap project',
  80. author_email = 'python-ldap@python.org',
  81. url = 'http://www.python-ldap.org/',
  82. download_url = 'http://pypi.python.org/pypi/python-ldap/',
  83. classifiers = [
  84. 'Development Status :: 5 - Production/Stable',
  85. 'Intended Audience :: Developers',
  86. 'Intended Audience :: System Administrators',
  87. 'Operating System :: OS Independent',
  88. 'Operating System :: MacOS :: MacOS X',
  89. 'Operating System :: Microsoft :: Windows',
  90. 'Operating System :: POSIX',
  91. 'Programming Language :: C',
  92. 'Programming Language :: Python',
  93. 'Topic :: Database',
  94. 'Topic :: Internet',
  95. 'Topic :: Software Development :: Libraries :: Python Modules',
  96. 'Topic :: System :: Systems Administration :: Authentication/Directory :: LDAP',
  97. 'License :: OSI Approved :: Python Software Foundation License',
  98. ],
  99. license = 'Python style',
  100. #-- C extension modules
  101. ext_modules = [
  102. Extension(
  103. '_ldap',
  104. [
  105. 'Modules/LDAPObject.c',
  106. 'Modules/ldapcontrol.c',
  107. 'Modules/common.c',
  108. 'Modules/constants.c',
  109. 'Modules/errors.c',
  110. 'Modules/functions.c',
  111. 'Modules/schema.c',
  112. 'Modules/ldapmodule.c',
  113. 'Modules/message.c',
  114. 'Modules/version.c',
  115. 'Modules/options.c',
  116. 'Modules/berval.c',
  117. ],
  118. libraries = LDAP_CLASS.libs,
  119. include_dirs = ['Modules'] + LDAP_CLASS.include_dirs,
  120. library_dirs = LDAP_CLASS.library_dirs,
  121. extra_compile_args = LDAP_CLASS.extra_compile_args,
  122. extra_link_args = LDAP_CLASS.extra_link_args,
  123. extra_objects = LDAP_CLASS.extra_objects,
  124. runtime_library_dirs = (not sys.platform.startswith("win"))*LDAP_CLASS.library_dirs,
  125. define_macros = LDAP_CLASS.defines + \
  126. ('ldap_r' in LDAP_CLASS.libs or 'oldap_r' in LDAP_CLASS.libs)*[('HAVE_LIBLDAP_R',None)] + \
  127. ('sasl' in LDAP_CLASS.libs or 'sasl2' in LDAP_CLASS.libs or 'libsasl' in LDAP_CLASS.libs)*[('HAVE_SASL',None)] + \
  128. ('ssl' in LDAP_CLASS.libs and 'crypto' in LDAP_CLASS.libs)*[('HAVE_TLS',None)] + \
  129. [('LDAPMODULE_VERSION', version)]
  130. ),
  131. ],
  132. #-- Python "stand alone" modules
  133. py_modules = [
  134. 'ldapurl',
  135. 'ldif',
  136. 'dsml',
  137. 'ldap',
  138. 'ldap.async',
  139. 'ldap.controls',
  140. 'ldap.controls.libldap',
  141. 'ldap.controls.ppolicy',
  142. 'ldap.controls.psearch',
  143. 'ldap.controls.readentry',
  144. 'ldap.controls.sessiontrack',
  145. 'ldap.controls.simple',
  146. 'ldap.cidict',
  147. 'ldap.dn',
  148. 'ldap.extop',
  149. 'ldap.extop.dds',
  150. 'ldap.filter',
  151. 'ldap.functions',
  152. 'ldap.ldapobject',
  153. 'ldap.logger',
  154. 'ldap.modlist',
  155. 'ldap.resiter',
  156. 'ldap.sasl',
  157. 'ldap.schema',
  158. 'ldap.schema.models',
  159. 'ldap.schema.subentry',
  160. 'ldap.schema.tokenizer',
  161. 'ldap.syncrepl',
  162. ],
  163. package_dir = {'': 'Lib',},
  164. data_files = LDAP_CLASS.extra_files,
  165. **kwargs
  166. )