pyapi build BUGFIX reflect enabled SSH/TLS and correct includes
diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt
index e048c3a..14b1e74 100644
--- a/python/CMakeLists.txt
+++ b/python/CMakeLists.txt
@@ -10,6 +10,14 @@
set(DEBUG "--debug")
endif()
+ if(ENABLE_SSH)
+ set(SSH_DEFINE ",\"-DNC_ENABLED_SSH\"")
+ endif()
+
+ if(ENABLE_TLS)
+ set(TLS_DEFINE ",\"-DNC_ENABLED_TLS\"")
+ endif()
+
configure_file(${SETUP_PY_IN} ${SETUP_PY})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/docs/Makefile.in ${CMAKE_CURRENT_SOURCE_DIR}/docs/Makefile)
add_custom_target(pyapi ALL COMMAND ${PYTHON} ${SETUP_PY} build -b ${PYAPI_BUILD_DIR} ${DEBUG})
diff --git a/python/err.c b/python/err.c
index 461086f..35328c0 100644
--- a/python/err.c
+++ b/python/err.c
@@ -20,7 +20,7 @@
#include <string.h>
#include "netconf.h"
-#include "messages_p.h"
+#include "../src/messages_p.h"
static void
ncErrFree(ncErrObject *self)
diff --git a/python/netconf.c b/python/netconf.c
index 741a1ea..e51e532 100644
--- a/python/netconf.c
+++ b/python/netconf.c
@@ -16,7 +16,6 @@
#include <Python.h>
/* standard headers */
-#include <nc_client.h>
#include <syslog.h>
#include "netconf.h"
diff --git a/python/netconf.h b/python/netconf.h
index bc2c5f3..e7bba10 100644
--- a/python/netconf.h
+++ b/python/netconf.h
@@ -19,13 +19,6 @@
extern "C" {
#endif
-#ifndef NC_ENABLED_SSH
-#define NC_ENABLED_SSH
-#endif
-#ifndef NC_ENABLED_TLS
-#define NC_ENABLED_TLS
-#endif
-
#include "../src/netconf.h"
#include "../src/log.h"
#include "../src/messages_client.h"
diff --git a/python/rpc.c b/python/rpc.c
index 33e3501..ec7bd69 100644
--- a/python/rpc.c
+++ b/python/rpc.c
@@ -21,9 +21,9 @@
#include <libyang/libyang.h>
#include <libyang/swigpyrun.h>
+#include "../src/messages_p.h"
#include "netconf.h"
#include "session.h"
-#include "messages_p.h"
#define TIMEOUT_SEND 1000 /* 1 second */
#define TIMEOUT_RECV 10000 /* 10 second */
diff --git a/python/session.c b/python/session.c
index bd6e7df..af70f07 100644
--- a/python/session.c
+++ b/python/session.c
@@ -146,7 +146,7 @@
const char *host = NULL;
PyObject *transport = NULL;
unsigned short port = 0;
- struct nc_session *session;
+ struct nc_session *session = NULL;
char *kwlist[] = {"host", "port", "transport", NULL};
@@ -156,9 +156,14 @@
}
/* connect */
+#ifdef NC_ENABLED_TLS
if (transport && PyObject_TypeCheck(transport, &ncTLSType)) {
session = nc_connect_tls(host, port, NULL);
} else {
+#else /* !NC_ENABLED_TLS */
+ {
+#endif
+#ifdef NC_ENABLED_SSH
if (transport) {
/* set SSH parameters */
if (((ncSSHObject*)transport)->username) {
@@ -194,6 +199,7 @@
nc_client_ssh_set_auth_privkey_passphrase_clb(NULL, NULL);
}
}
+#endif /* NC_ENABLED_SSH */
}
/* check the result */
@@ -211,6 +217,8 @@
return 0;
}
+#ifdef NC_ENABLED_SSH
+
static PyObject *
newChannel(PyObject *self)
{
@@ -238,6 +246,8 @@
return (PyObject*)new;
}
+#endif /* NC_ENABLED_SSH */
+
static PyObject *
ncSessionStr(ncSessionObject *self)
{
@@ -298,10 +308,14 @@
{
NC_TRANSPORT_IMPL ti = nc_session_get_ti(self->session);
switch (ti) {
+#ifdef NC_ENABLED_SSH
case NC_TI_LIBSSH:
return PyUnicode_FromString("SSH");
+#endif /* NC_ENABLED_SSH */
+#ifdef NC_ENABLEd_TLS
case NC_TI_OPENSSL:
return PyUnicode_FromString("TLS");
+#endif /* NC_ENABLED_TLS */
default:
return PyUnicode_FromString("unknown");
}
@@ -357,10 +371,12 @@
};
static PyMethodDef ncSessionMethods[] = {
+#ifdef NC_ENABLED_SSH
{"newChannel", (PyCFunction)newChannel, METH_NOARGS,
"newChannel()\n--\n\n"
"Create another NETCONF session on existing SSH session using separated SSH channel\n\n"
":returns: New netconf2.Session instance.\n"},
+#endif /* NC_ENABLED_SSH */
/* RPCs */
{"rpcGet", (PyCFunction)ncRPCGet, METH_VARARGS | METH_KEYWORDS,
"Send NETCONF <get> operation on the Session.\n\n"
diff --git a/python/setup.py.in b/python/setup.py.in
index f537a8f..1db4191 100644
--- a/python/setup.py.in
+++ b/python/setup.py.in
@@ -13,7 +13,7 @@
"${CMAKE_CURRENT_COURCE_DIR}/rpc.h"
],
libraries=["netconf2"],
- extra_compile_args=["-Wall", "-I${CMAKE_CURRENT_SOURCE_DIR}/../src/", ],
+ extra_compile_args=["-Wall", "-I${PROJECT_BINARY_DIR}" @SSH_DEFINE@ @TLS_DEFINE@],
extra_link_args=["-L${CMAKE_CURRENT_BINARY_DIR}/.."],
)