Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions 21 setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,29 @@ def is_debug():


if is_debug():
macroses.append(("PYXMLSEC_ENABLE_DEBUG", 1))
macroses.append(("PYXMLSEC_ENABLE_DEBUG", "1"))
cflags.extend(["-Wall", "-O0"])
else:
cflags.extend(["-Os"])


def add_to_list(target, up):
# values which requires escaping
require_escape = {"XMLSEC_CRYPTO"}


def add_to_list(target, up, need_to_escape=None):
if up is None:
return target

value = set(target)
value.update(up)
if need_to_escape:
for x in up:
if x[0] in need_to_escape:
value.add((x[0], '"{0}"'.format(x[1])))
else:
value.add(x)
else:
value.update(up)
target[:] = list(value)


Expand Down Expand Up @@ -61,10 +72,12 @@ def patch_xmlsec(self):

ext = self.ext_map[__name__]
config = pkgconfig.parse("xmlsec1")
# need to escape XMLSEC_CRYPTO
# added build flags from pkg-config
for item in ('define_macros', 'libraries', 'library_dirs', 'include_dirs'):
for item in ('libraries', 'library_dirs', 'include_dirs'):
add_to_list(getattr(ext, item), config.get(item))

add_to_list(ext.define_macros, config.get('define_macros'), {"XMLSEC_CRYPTO"})
add_to_list(ext.include_dirs, lxml.get_include())


Expand Down
10 changes: 8 additions & 2 deletions 10 src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,14 @@ static int PyXmlSec_Init(void) {
}

#ifndef XMLSEC_NO_CRYPTO_DYNAMIC_LOADING
if (xmlSecCryptoDLLoadLibrary((const xmlChar*) STRINGIFY(XMLSEC_CRYPTO)) < 0) {
#if XMLSEC_VERSION_HEX > 308
// xmlSecGetDefaultCrypto was introduced in version 1.2.21
const xmlChar* cryptoLib = xmlSecGetDefaultCrypto();
#else
const xmlChar* cryptoLib = (const xmlChar*) XMLSEC_CRYPTO;
#endif
PYXMLSEC_DEBUGF("dynamic crypto library: %s", cryptoLib);
if (xmlSecCryptoDLLoadLibrary(cryptoLib) < 0) {
PyXmlSec_SetLastError("cannot load crypto library for xmlsec.");
PyXmlSec_Free(_FREE_XMLSEC);
return -1;
Expand Down Expand Up @@ -240,6 +247,5 @@ PYENTRY_FUNC_NAME(void)

PY_MOD_RETURN(module);
ON_FAIL:
Py_DECREF(module);
PY_MOD_RETURN(NULL);
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.