From 07ae545fdad0a58f5c208f394e6da5d578a753f5 Mon Sep 17 00:00:00 2001 From: Hector Martin Date: Wed, 2 Dec 2015 22:34:41 +0900 Subject: [PATCH] pybind: Improvements to Cython build - Avoid a silly rebuild at install time by always using src/build explicitly as build dir - Tell Cython to put rbd.c in the build dir instead of in the source This should fix a race when librbd gets relinked at the same time as pybind is installed (since that install was causing a rebuild too). Signed-off-by: Hector Martin --- src/pybind/.gitignore | 1 - src/pybind/Makefile.am | 5 ++++- src/pybind/setup.py | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/pybind/.gitignore b/src/pybind/.gitignore index 3df399c80fe32..225fc6f665041 100644 --- a/src/pybind/.gitignore +++ b/src/pybind/.gitignore @@ -1,2 +1 @@ /__pycache__ -/rbd.c diff --git a/src/pybind/Makefile.am b/src/pybind/Makefile.am index dcd8d109dddd8..fd23fcb52f48a 100644 --- a/src/pybind/Makefile.am +++ b/src/pybind/Makefile.am @@ -9,6 +9,7 @@ PY_DISTUTILS = \ CPPFLAGS="-iquote \${abs_srcdir}/include ${AM_CPPFLAGS} ${CPPFLAGS}" \ CFLAGS="-iquote \${abs_srcdir}/include ${AM_CFLAGS} ${CFLAGS}" \ LDFLAGS="-L\${abs_builddir}/.libs $(subst -pie,,${AM_LDFLAGS}) ${LDFLAGS}" \ + CYTHON_BUILD_DIR="$(shell readlink -f $(builddir))/build" \ ${PYTHON} ./setup.py pybind-all: librbd.la ${srcdir}/ceph_ver.h @@ -32,7 +33,9 @@ pybind-install-exec: ${srcdir}/ceph_ver.h else \ options=--prefix=$(prefix) ; \ fi ; \ - cd $(srcdir)/pybind; $(PY_DISTUTILS) install \ + cd $(srcdir)/pybind; $(PY_DISTUTILS) build \ + --build-base $(shell readlink -f $(builddir))/build \ + install \ $$options $$root \ --single-version-externally-managed \ --record /dev/null \ diff --git a/src/pybind/setup.py b/src/pybind/setup.py index 8eb2e69986ced..1eda454c392cb 100755 --- a/src/pybind/setup.py +++ b/src/pybind/setup.py @@ -29,7 +29,8 @@ class EggInfoCommand(egg_info): if (len(sys.argv) >= 2 and any(i in sys.argv[1:] for i in ('--help', 'clean', 'egg_info', '--version') )): - cythonize = lambda x: x + def cythonize(x, **kwargs): + return x setup( name = 'rbd', @@ -43,7 +44,7 @@ setup( ["rbd.pyx"], libraries=["rbd"] ) - ]), + ], build_dir=os.environ.get("CYTHON_BUILD_DIR", None)), cmdclass={ "egg_info": EggInfoCommand, }, -- 2.39.5