From b79fe6df7f6ce5c23fc82576f81622e8fe985043 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Wed, 2 Jan 2019 15:34:09 +0100 Subject: [PATCH] build python extension for python3 --- Makefile | 6 +++--- setns.c | 20 ++++++++++++++++---- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 2ae9071..44bc3fd 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ vsh: vsh.c gcc vsh.c -o vsh setns: setns.c - python setup.py build + python3 setup.py build ########## sync # for use with the test framework; push local stuff on a test node @@ -22,7 +22,7 @@ setns: setns.c # this will attempt to compile vsh from vsh.c # so you might have to yum install gcc -LOCAL_RSYNC_EXCLUDES := --exclude '*.pyc' +LOCAL_RSYNC_EXCLUDES := --exclude '*.pyc' RSYNC_EXCLUDES := --exclude .git --exclude .svn --exclude '*~' --exclude TAGS $(LOCAL_RSYNC_EXCLUDES) RSYNC_COND_DRY_RUN := $(if $(findstring n,$(MAKEFLAGS)),--dry-run,) RSYNC := rsync -e "ssh -i $(NODE).key.rsa" -a -v $(RSYNC_COND_DRY_RUN) $(RSYNC_EXCLUDES) @@ -79,4 +79,4 @@ install: setns vsh chmod u+s /usr/sbin/lxcsu chmod u+s /usr/sbin/slicesu chmod u+s /usr/sbin/vsh - cp build/lib*/setns.so /usr/sbin + cp build/lib*/setns.*.so /usr/sbin/setns.so diff --git a/setns.c b/setns.c index e8a4302..84116d9 100644 --- a/setns.c +++ b/setns.c @@ -101,9 +101,21 @@ static PyMethodDef SetnsMethods[] = {NULL, NULL, 0, NULL} }; -PyMODINIT_FUNC +static struct PyModuleDef moduledef = { + PyModuleDef_HEAD_INIT, + "setns", + "http://git.onelab.eu/?p=lxc-userspace.git;a=summary", + -1, + SetnsMethods, + NULL, + NULL, + NULL, + NULL +}; -initsetns(void) -{ - (void) Py_InitModule("setns", SetnsMethods); +PyObject *PyInit_setns(void){ + PyObject *module = PyModule_Create(&moduledef); + if (module == NULL) + return NULL; + return module; } -- 2.43.0