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
|
"""
setup.py - C extension module configuration for python-ldap
See https://www.python-ldap.org/ for details.
This file handles only the C extension modules (_ldap) configuration,
while pyproject.toml handles all project metadata, dependencies, and other settings.
"""
import sys,os
from setuptools import setup, Extension
if sys.version_info < (3, 6):
raise RuntimeError(
'The C API from Python 3.6+ is required, found %s' % sys.version_info
)
from configparser import ConfigParser
sys.path.insert(0, os.path.join(os.getcwd(), 'Lib/ldap'))
import pkginfo
#-- A class describing the features and requirements of OpenLDAP 2.0
class OpenLDAP2:
library_dirs = []
include_dirs = []
extra_compile_args = []
extra_link_args = []
extra_objects = []
libs = ['ldap', 'lber']
defines = []
extra_files = []
LDAP_CLASS = OpenLDAP2
#-- Read the [_ldap] section of setup.cfg
cfg = ConfigParser()
cfg.read('setup.cfg')
if cfg.has_section('_ldap'):
for name in dir(LDAP_CLASS):
if cfg.has_option('_ldap', name):
setattr(LDAP_CLASS, name, cfg.get('_ldap', name).split())
for i in range(len(LDAP_CLASS.defines)):
LDAP_CLASS.defines[i]=((LDAP_CLASS.defines[i],None))
for i in range(len(LDAP_CLASS.extra_files)):
destdir, origfiles = LDAP_CLASS.extra_files[i].split(':')
origfileslist = origfiles.split(',')
LDAP_CLASS.extra_files[i]=(destdir, origfileslist)
if os.environ.get('WITH_GCOV'):
# Instrumentation for measuring code coverage
LDAP_CLASS.extra_compile_args.extend(
['-O0', '-pg', '-fprofile-arcs', '-ftest-coverage']
)
LDAP_CLASS.extra_link_args.append('-pg')
LDAP_CLASS.libs.append('gcov')
#-- C extension modules configuration only
setup(
ext_modules = [
Extension(
'_ldap',
[
'Modules/LDAPObject.c',
'Modules/ldapcontrol.c',
'Modules/common.c',
'Modules/constants.c',
'Modules/functions.c',
'Modules/ldapmodule.c',
'Modules/message.c',
'Modules/options.c',
'Modules/berval.c',
],
depends = [
'Modules/LDAPObject.h',
'Modules/berval.h',
'Modules/common.h',
'Modules/constants_generated.h',
'Modules/constants.h',
'Modules/functions.h',
'Modules/ldapcontrol.h',
'Modules/message.h',
'Modules/options.h',
],
libraries = LDAP_CLASS.libs,
include_dirs = ['Modules'] + LDAP_CLASS.include_dirs,
library_dirs = LDAP_CLASS.library_dirs,
extra_compile_args = LDAP_CLASS.extra_compile_args,
extra_link_args = LDAP_CLASS.extra_link_args,
extra_objects = LDAP_CLASS.extra_objects,
runtime_library_dirs = (not sys.platform.startswith("win"))*LDAP_CLASS.library_dirs,
define_macros = LDAP_CLASS.defines + \
('sasl' in LDAP_CLASS.libs or 'sasl2' in LDAP_CLASS.libs or 'libsasl' in LDAP_CLASS.libs)*[('HAVE_SASL',None)] + \
('ssl' in LDAP_CLASS.libs and 'crypto' in LDAP_CLASS.libs)*[('HAVE_TLS',None)] + \
[
('LDAPMODULE_VERSION', pkginfo.__version__),
('LDAPMODULE_AUTHOR', pkginfo.__author__),
('LDAPMODULE_LICENSE', pkginfo.__license__),
]
),
],
)
|