Add support for building statically.
Using --gen-setup, one can create a Setup file which can then be included in Modules/Setup.local.
This commit is contained in:
parent
77c2478298
commit
59cc691a0d
14
setup.py
14
setup.py
@ -7,6 +7,7 @@ from distutils.core import setup, Extension
|
|||||||
# --with-zlib=<dir>: path to zlib if needed
|
# --with-zlib=<dir>: path to zlib if needed
|
||||||
# --with-libmemcached=<dir>: path to libmemcached package if needed
|
# --with-libmemcached=<dir>: path to libmemcached package if needed
|
||||||
|
|
||||||
|
cmd = None
|
||||||
use_zlib = True
|
use_zlib = True
|
||||||
pkgdirs = [] # incdirs and libdirs get these
|
pkgdirs = [] # incdirs and libdirs get these
|
||||||
libs = ["memcached"]
|
libs = ["memcached"]
|
||||||
@ -23,6 +24,8 @@ for arg in sys.argv[1:]:
|
|||||||
elif arg == "--without-zlib":
|
elif arg == "--without-zlib":
|
||||||
use_zlib = False
|
use_zlib = False
|
||||||
continue
|
continue
|
||||||
|
elif arg == "--gen-setup":
|
||||||
|
cmd = arg[2:]
|
||||||
elif "=" in arg:
|
elif "=" in arg:
|
||||||
if arg.startswith("--with-libmemcached=") or \
|
if arg.startswith("--with-libmemcached=") or \
|
||||||
arg.startswith("--with-zlib="):
|
arg.startswith("--with-zlib="):
|
||||||
@ -43,6 +46,17 @@ pylibmc_ext = Extension("_pylibmc", ["_pylibmcmodule.c"],
|
|||||||
libraries=libs, include_dirs=incdirs,
|
libraries=libs, include_dirs=incdirs,
|
||||||
library_dirs=libdirs, define_macros=defs)
|
library_dirs=libdirs, define_macros=defs)
|
||||||
|
|
||||||
|
# Hidden secret: if environment variable GEN_SETUP is set, generate Setup file.
|
||||||
|
if cmd == "gen-setup":
|
||||||
|
line = " ".join((
|
||||||
|
pylibmc_ext.name,
|
||||||
|
" ".join("-l" + lib for lib in pylibmc_ext.libraries),
|
||||||
|
" ".join("-I" + incdir for incdir in pylibmc_ext.include_dirs),
|
||||||
|
" ".join("-L" + libdir for libdir in pylibmc_ext.library_dirs),
|
||||||
|
" ".join("-D" + name + ("=" + str(value), "")[value is None] for (name, value) in pylibmc_ext.define_macros)))
|
||||||
|
open("Setup", "w").write(line + "\n")
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
readme_text = open("README.rst", "U").read()
|
readme_text = open("README.rst", "U").read()
|
||||||
version = open("pylibmc-version.h", "U").read().strip().split("\"")[1]
|
version = open("pylibmc-version.h", "U").read().strip().split("\"")[1]
|
||||||
|
|
||||||
|
5
tests.py
5
tests.py
@ -339,7 +339,10 @@ class TestProgram(unittest.TestProgram):
|
|||||||
return runner.run(self.test)
|
return runner.run(self.test)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
print "Starting tests with _pylibmc at", _pylibmc.__file__
|
if hasattr(_pylibmc, "__file__"):
|
||||||
|
print "Starting tests with _pylibmc at", _pylibmc.__file__
|
||||||
|
else:
|
||||||
|
print "Starting tests with static _pylibmc:", _pylibmc
|
||||||
print "Reported libmemcached version:", _pylibmc.libmemcached_version
|
print "Reported libmemcached version:", _pylibmc.libmemcached_version
|
||||||
print "Reported pylibmc version:", _pylibmc.__version__
|
print "Reported pylibmc version:", _pylibmc.__version__
|
||||||
print "Support compression:", _pylibmc.support_compression
|
print "Support compression:", _pylibmc.support_compression
|
||||||
|
Reference in New Issue
Block a user