From: Mark Huang Date: Fri, 26 Aug 2005 04:00:44 +0000 (+0000) Subject: - can't link directly against libvserver anymore X-Git-Tag: after-util-vserver-0_30_208-revert~123 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;ds=sidebyside;h=c24dd57aa9dba282b9f4517f5a2967fc345c1ece;p=util-vserver.git - can't link directly against libvserver anymore - replace pybuild with autoconf/libtool/custom Makefile hack --- diff --git a/python/Makefile b/python/Makefile index 35b5f43..dc4d593 100644 --- a/python/Makefile +++ b/python/Makefile @@ -1,15 +1,46 @@ -INCLUDES := -I.. -I../lib -LIBS = -L../lib -lvserver +# +# GNUMakefile for util-vserver Python bindings +# +# It's too hard to integrate distutils into the autoconf/libtool +# framework, so run this Makefile separately from and after the normal +# util-vserver build. +# +# Steve Muir +# Mark Huang +# Copyright (C) 2005 The Trustees of Princeton University +# +# $Id$ +# -PY_MODS := vserver.py cpulimit.py bwlimit.py -PY_EXT_MODS := vduimpl.so vserverimpl.so +ALL := vserverimpl.so vduimpl.so util_vserver_vars.py -all: py-build +pythonlibdir := @libdir@/python@PYTHON_VERSION@/site-packages -install: py-install - ln -s /usr/lib/util-vserver/util-vserver-vars \ - $(INSTALL_ROOT)/usr/lib/python2.3/site-packages/util_vserver_vars.py +all: $(ALL) --include pybuild.mk +%.o: %.c + # builds object and incompletely linked library + python setup.py build_ext + # copy to current directory + cp -a build/temp.*/*.o . -.PHONY: all install +vserverimpl.so vduimpl.so: %.so: %.o + # relink the object against libvserver with libtool + ../libtool --tag=CC --mode=link $(CC) -shared -o $@ $< ../lib/libvserver.la + +util_vserver_vars.py: ../scripts/util-vserver-vars + install -m 644 $< $@ + +install: $(ALL) + # install relinked libraries and byte-compiled scripts + python setup.py install --root="$(DESTDIR)" + # reinstall libraries with libtool so that the final path + # to libvserver is resolved + for so in $(filter %.so, $(ALL)) ; do \ + ../libtool --tag=CC --mode=install install "$$so" `find "$(DESTDIR)" -name "$$so"` ; \ + done + +clean: + rm -rf $(ALL) *.o build + +.PHONY: all install clean diff --git a/python/pybuild.mk b/python/pybuild.mk deleted file mode 100644 index 140cc14..0000000 --- a/python/pybuild.mk +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright 2005 Princeton University -# -# PY_MODS variable should be list of Python source modules -# PY_EXT_MODS should be list of Python extension modules (.so) that need -# to be built -# - -_PY_TMPDIR := .pybuild - -# use strip to remove extra whitespace -_PY_SETUP = $(strip python setup.py \ - $(foreach i,DEFS INCLUDES LIBS PY_MODS PY_EXT_MODS,\ - $(if $(subst undefined,,$(origin $i)),$i="$($i)"))) - -_PY_BUILD_ARGS := -t $(_PY_TMPDIR) -b $(_PY_TMPDIR)/build - -py-build: .pybuild/.prep-done $(PY_MODS) $(PY_EXT_MODS) - -.pybuild/.prep-done: - mkdir build .pybuild - ln -s ../build .pybuild - touch $@ - -$(PY_EXT_MODS): PY_EXT_MODS = $@ - -$(PY_EXT_MODS): %.so: %.c - $(_PY_SETUP) build_ext -f $(_PY_BUILD_ARGS) - -py-install: - $(_PY_SETUP) install --root=$(INSTALL_ROOT) - -.PHONY: py-build py-install py-clean diff --git a/python/setup.py b/python/setup.py index 507a5c2..8491c58 100644 --- a/python/setup.py +++ b/python/setup.py @@ -1,40 +1,26 @@ #!/usr/bin/python - -import re -import sys +# +# Python distutils script for util-vserver Python bindings +# +# Steve Muir +# Mark Huang +# +# Copyright (C) 2005 The Trustees of Princeton University +# +# $Id$ +# from distutils.core import setup, Extension -MODULE_NAME_RE = "[A-Za-z_]+" - -if __name__ == "__main__": - - build_arg_re = re.compile(r"^([A-Z_]+)= *(.*)") - def split_args((build_args, argv), arg): - m = build_arg_re.match(arg) - if m: - (k, v) = m.groups() - build_args[k] = v - else: - argv += [arg] - return (build_args, argv) +extension_args = {} +extension_args['extra_compile_args'] = ['-Wall'] +extension_args['include_dirs'] = ['..', '../lib'] +# Link against libvserver with libtool later +#extension_args['library_dirs'] = ['../lib'] +#extension_args['libraries'] = ['vserver'] - (build_args, argv) = reduce(split_args, sys.argv[1:], ({}, [])) - sys.argv[1:] = argv - extension_args = { "extra_compile_args": ["-Wall"] } - if "INCLUDES" in build_args: - extension_args["include_dirs"] = re.findall(r"-I([^ ]+)", - build_args["INCLUDES"]) - lib_args = build_args.get("LIBS", "") - if lib_args: - extension_args["library_dirs"] = re.findall(r"-L([^ ]+)", lib_args) - extension_args["libraries"] = re.findall(r"-l([^ ]+)", lib_args) - modules = re.findall("(%s).py" % MODULE_NAME_RE, - build_args.get("PY_MODS", "")) - extensions = map(lambda modname: Extension(modname, - [modname + ".c"], - **extension_args), - re.findall("(%s).so" % MODULE_NAME_RE, - build_args.get("PY_EXT_MODS", ""))) +modules = ['util_vserver_vars', 'vserver', 'cpulimit', 'bwlimit'] +extensions = [Extension('vduimpl', ['vduimpl.c'], **extension_args), + Extension('vserverimpl', ['vserverimpl.c'], **extension_args)] - setup(py_modules = modules, ext_modules = extensions) +setup(py_modules = modules, ext_modules = extensions)