-
Notifications
You must be signed in to change notification settings - Fork 103
/
setup.py
executable file
·57 lines (50 loc) · 1.83 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python
from distutils.core import setup, Extension
from distutils.command import install_lib as _install_lib
import sys, imp, os, glob
# Make sure vendor/hiredis is checked out (for development)
if __name__ == "__main__":
# Initialize submodule when not present
submodule_status = os.popen("git submodule status", "r").read().strip()
if submodule_status[0] == '-':
# Submodule has not been updated (see git help submodule)
os.system("git submodule update --init")
elif submodule_status[0] == '+':
print "note: vendor/hiredis submodule revision doesn't match."
def version():
module = imp.load_source("hiredis.version", "hiredis/version.py")
return module.__version__
# Patch "install_lib" command to run build_clib before build_ext
# to properly work with easy_install.
# See: http://bugs.python.org/issue5243
class install_lib(_install_lib.install_lib):
def build(self):
if not self.skip_build:
if self.distribution.has_pure_modules():
self.run_command('build_py')
if self.distribution.has_c_libraries():
self.run_command('build_clib')
if self.distribution.has_ext_modules():
self.run_command('build_ext')
lib = ("hiredis", {
"sources": ["vendor/hiredis/%s.c" % src for src in ("hiredis", "net", "sds")],
"include_dirs": ["vendor/hiredis"]})
ext = Extension("hiredis.hiredis",
sources=glob.glob("src/*.c"),
include_dirs=["src", "vendor"],
libraries=["hiredis"])
setup(
name="hiredis",
version=version(),
description="Python extension that wraps hiredis",
url="https://github.com/pietern/hiredis-py",
author="Pieter Noordhuis",
author_email="pcnoordhuis@gmail.com",
keywords=["Redis"],
license="BSD",
packages=["hiredis"],
libraries=[lib],
ext_modules=[ext],
# Override "install_lib" command
cmdclass={ "install_lib": install_lib },
)