Skip to content

Commit

Permalink
C module _ldap now also gets __author__ and __license__ set from ldap…
Browse files Browse the repository at this point in the history
….pkginfo same like __version__
  • Loading branch information
stroeder authored and Petr Viktorin committed Nov 22, 2017
1 parent 707744c commit 5b35eef
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Modules/
* moved code from version.c to ldapmodule.c
* removed obsolete back-ward compability constants from common.h
* build checks whether LDAP_API_VERSION is OpenLDAP 2.4.x
* _ldap.__author__ and _ldap.__license__ also set from ldap.pkginfo

Lib/
* new global constant ldap.LIBLDAP_API_INFO
Expand Down
6 changes: 0 additions & 6 deletions Modules/constants.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,12 +280,6 @@ LDAPinit_constants( PyObject* d )
add_int(d,URL_ERR_BADSCOPE);
add_int(d,URL_ERR_MEM);

/* author */

author = PyString_FromString("python-ldap Project");
PyDict_SetItemString(d, "__author__", author);
Py_DECREF(author);

/* add_int(d,LIBLDAP_R); */
#ifdef HAVE_LIBLDAP_R
obj = PyInt_FromLong(1);
Expand Down
25 changes: 19 additions & 6 deletions Modules/ldapmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,28 @@
#define STR(x) _STR(x)

static char version_str[] = STR(LDAPMODULE_VERSION);
static char author_str[] = STR(LDAPMODULE_AUTHOR);
static char license_str[] = STR(LDAPMODULE_LICENSE);

void
LDAPinit_version( PyObject* d )
init_pkginfo( PyObject* d )
{
PyObject *version;
PyObject *version;
PyObject *author;
PyObject *license;

version = PyString_FromString(version_str);
PyDict_SetItemString( d, "__version__", version );
Py_DECREF(version);

author = PyString_FromString(author_str);
PyDict_SetItemString(d, "__author__", author);
Py_DECREF(author);

license = PyString_FromString(license_str);
PyDict_SetItemString(d, "__license__", license);
Py_DECREF(license);

version = PyString_FromString(version_str);
PyDict_SetItemString( d, "__version__", version );
Py_DECREF(version);
}

DL_EXPORT(void) init_ldap(void);
Expand Down Expand Up @@ -48,7 +61,7 @@ init_ldap()
/* Add some symbolic constants to the module */
d = PyModule_GetDict(m);

LDAPinit_version(d);
init_pkginfo(d);
LDAPinit_constants(d);
LDAPinit_errors(d);
LDAPinit_functions(d);
Expand Down
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ class OpenLDAP2:
('ldap_r' in LDAP_CLASS.libs or 'oldap_r' in LDAP_CLASS.libs)*[('HAVE_LIBLDAP_R',None)] + \
('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_VERSION', pkginfo.__version__),
('LDAPMODULE_AUTHOR', pkginfo.__author__),
('LDAPMODULE_LICENSE', pkginfo.__license__),
]
),
],
#-- Python "stand alone" modules
Expand Down

0 comments on commit 5b35eef

Please sign in to comment.