This repository has been archived by the owner on Jul 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
setup.py
101 lines (83 loc) · 2.94 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
version = '3.4.4-1'
import distutils.command.build_ext
import distutils.core
import os
import shutil
import time
def do_system(cmd):
print cmd
if os.system(cmd):
raise SystemError("Failed: %s" % cmd)
class build_ext(distutils.command.build_ext.build_ext):
def run(self):
# Hack to build C sources first
if os.path.exists('c'):
print "Removing old c directory"
shutil.rmtree('c')
do_system("tar xzf c.tgz")
os.utime("c/config.h.in", (time.time(), time.time()))
do_system("cd c; ./configure; make")
distutils.command.build_ext.build_ext.run(self)
cmdclass = dict(build_ext=build_ext)
try:
import setuptools
except ImportError:
from distutils.core import setup
else:
from setuptools import setup
import setuptools.command.test
class Test(setuptools.command.test.test):
def run(self):
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(1.0)
ruok = None
try:
s.connect(('localhost', 22182))
s.send('ruok')
ruok = s.recv(4)
except socket.error:
pass
if ruok != 'imok':
raise SystemError(
'You must be running a testing ZooKeeper server '
'on port 22182')
os.environ["ZKPY_LOG_DIR"] = '.'
setuptools.command.test.test.run(self)
import sys
sys.path.append('src')
cmdclass.update(test=Test)
setup(
author='Henry Robinson',
author_email='[email protected]',
license='Apache',
name='zc-zookeeper-static',
version=version,
long_description=open('README.rst').read(),
description='ZooKeeper Python bindings',
url='http://pypi.python.org/pypi/zc-zookeeper-static',
cmdclass=cmdclass,
test_suite='zookeepertests',
ext_modules=[
distutils.core.Extension(
"zookeeper",
sources=["zookeeper.c"],
include_dirs=["c/include",
"c/generated"],
extra_objects=["c/.libs/libzookeeper_mt.a"],
)
],
)