1 message in com.mysql.lists.ndb-connectorsRev 416: Stupid distutils. Added more...| From | Sent On | Attachments |
|---|---|---|
| Monty Taylor | 22 Jan 2008 16:22 |
| Subject: | Rev 416: Stupid distutils. Added more methods and I still can't get make distcheck to work. 86ing distutils, but I thought I'd check this in in case we wanted to go backand look at it later. in http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/devel![]() |
|---|---|
| From: | Monty Taylor (mtay...@mysql.com) |
| Date: | 01/22/2008 04:22:44 PM |
| List: | com.mysql.lists.ndb-connectors |
At http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/devel
------------------------------------------------------------
revno: 416
revision-id:mtay...@mysql.com-20080123002242-5ettmhc1kr76x5gl
parent: mtay...@mysql.com-20080123002205-8sk00z3p3u7tc9sl
committer: Monty Taylor <mtay...@mysql.com>
branch nick: devel
timestamp: Tue 2008-01-22 19:22:42 -0500
message:
Stupid distutils. Added more methods and I still can't get make distcheck to
work. 86ing distutils, but I thought I'd check this in in case we wanted to go
backand look at it later.
modified:
python/Makefile.am makefile.am-20070925115907-x2wrdte5kicyfrrw-1
python/setup.py setup.py-20071027082659-u3uu8u83f54jtbn4-1
=== modified file 'python/Makefile.am'
--- a/python/Makefile.am 2007-12-10 07:39:46 +0000
+++ b/python/Makefile.am 2008-01-23 00:22:42 +0000
@@ -28,7 +28,7 @@
$(SWIG) -c++ -python $(SWIG_OPTS) -o $@ $<
$(builddir)/mysql/cluster/_ndbapi.so $(builddir)/mysql/cluster/_mgmapi.so
$(builddir)/mysql/cluster/_events.so $(builddir)/mysql/cluster/_listeners.so:
$(builddir)/ndbapi.cpp $(builddir)/mgmapi.cpp $(builddir)/events.cpp
$(builddir)/listeners.cpp
- CC="${CXX}" CFLAGS="${CFLAGS}" CPPFLAGS="${CPPFLAGS}" LDFLAGS="${LDFLAGS}"
SRCDIR="${srcdir}" TOP_SRCDIR="${top_srcdir}" BUILDDIR="${builddir}"
TOP_BUILDDIR="${top_builddir}" ${PYTHON} $(srcdir)/setup.py build
--build-base="${top_builddir}/python/build"
+ CC="${CXX}" CFLAGS="${CFLAGS}" CPPFLAGS="${CPPFLAGS}" LDFLAGS="${LDFLAGS}"
SRCDIR="${srcdir}" TOP_SRCDIR="${top_srcdir}" BUILDDIR="${builddir}"
TOP_BUILDDIR="${top_builddir}" ${PYTHON} $(srcdir)/setup.py build
--build-base="${top_builddir}/python/build" --src-dir="${srcdir}"
clean-local: ${PYTHON} ${srcdir}/setup.py clean
=== modified file 'python/setup.py' --- a/python/setup.py 2007-12-07 10:40:58 +0000 +++ b/python/setup.py 2008-01-23 00:22:42 +0000 @@ -22,10 +22,127 @@
from distutils.command.clean import clean from distutils.command.build import build +from distutils.command.build_ext import build_ext +from distutils.command.build_py import build_py from setuptools import setup,Extension -import os.path, os + +from types import ListType, TupleType + +import os.path, os, string import sys
+# distutils doesn't support a src_dir option for out-of-tree builds, +# so we're adding one here. + +class ndb_build(build): + + user_options = build.user_options + user_options.append( ('src-dir=', None, + "directory holding the source [default: %s]" % + os.curdir ) ) + + def initialize_options(self): + self.src_dir=None + return build.initialize_options(self) + + +class ndb_build_py(build_py): + + user_options = build_py.user_options + user_options.append( ('src-dir=', None, + "directory holding the source [default: %s]" % + os.curdir ) ) + + def initialize_options(self): + self.src_dir=None + return build_py.initialize_options(self) + + def finalize_options(self): + self.set_undefined_options('build', ('src_dir', 'src_dir')) + if self.src_dir is None: + self.src_dir = os.curdir + return build_py.finalize_options(self) + + # As opposed to all of the other methods, there's no good way to wrap this one + def get_package_dir (self, package): + """Return the directory, relative to the top of the source + distribution, where package 'package' should be found + (at least according to the 'package_dir' option, if any).""" + + path = string.split(package, '.') + + if not self.package_dir: + if path: + return os.path.join(self.src_dir,apply(os.path.join, path)) + else: + return self.src_dir + else: + tail = [] + while path: + try: + pdir = self.package_dir[string.join(path, '.')] + except KeyError: + tail.insert(0, path[-1]) + del path[-1] + else: + tail.insert(0, pdir) + return os.path.join(self.src_dir,apply(os.path.join, tail)) + else: + # Oops, got all the way through 'path' without finding a + # match in package_dir. If package_dir defines a directory + # for the root (nameless) package, then fallback on it; + # otherwise, we might as well have not consulted + # package_dir at all, as we just use the directory implied + # by 'tail' (which should be the same as the original value + # of 'path' at this point). + pdir = self.package_dir.get('') + if pdir is not None: + tail.insert(0, pdir) + + if tail: + return os.path.join(self.src_dir,apply(os.path.join, tail)) + else: + return self.src_dir + + def check_package (self, package, package_dir): + + if package_dir != "" and not os.path.exists(package_dir): + os.makedirs(package_dir) + return build_py.check_package(self, package, package_dir) + + +class ndb_build_ext(build_ext): + + user_options = build_ext.user_options + user_options.append( ('src-dir=', None, + "directory holding the source [default: %s]" % + os.curdir ) ) + + def initialize_options(self): + self.src_dir=None + return build_ext.initialize_options(self) + + def finalize_options(self): + self.set_undefined_options('build', ('src_dir', 'src_dir')) + if self.src_dir is None: + self.src_dir = os.curdir + return build_ext.finalize_options(self) + + def build_extension(self, ext): + + sources = ext.sources + if sources is None or type(sources) not in (ListType, TupleType): + raise DistutilsSetupError, \ + ("in 'ext_modules' option (extension '%s'), " + + "'sources' must be present and must be " + + "a list of source filenames") % ext.name + + new_sources = [] + for source in sources: + new_sources.append(os.path.join(self.src_dir,source)) + ext.sources = new_sources + return build_ext.build_extension(self, ext) + srcdir=os.environ.get("SRCDIR",".") top_srcdir=os.environ.get("TOP_SRCDIR","..") builddir=os.environ.get("BUILDDIR",".") @@ -54,7 +171,11 @@ platforms="linux", license="GPL", classifiers=filter(None, classifiers.splitlines()), - + cmdclass = { + 'build': ndb_build, + 'build_ext': ndb_build_ext, + 'build_py': ndb_build_py, + }, ext_modules=[ Extension("mysql.cluster._mgmapi", sources=["mgmapi.cpp"],




