forked from linkedin/kafka-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·159 lines (132 loc) · 4.58 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
import os
import subprocess
import sys
from codecs import open
from setuptools import setup, find_packages, Command
entry_points = {
'console_scripts': [
'kafka-assigner = kafka.tools.assigner.__main__:main',
'kafka-protocol = kafka.tools.protocol.__main__:main',
],
}
install_requires = [
'JPype1',
'kazoo',
'pex',
]
class Pex(Command):
user_options = []
def initialize_options(self):
"""Abstract method that is required to be overwritten"""
def finalize_options(self):
"""Abstract method that is required to be overwritten"""
def run(self):
if not os.path.exists('dist/wheel-cache'):
print('Creating dist/wheel-cache')
os.makedirs('dist/wheel-cache')
print('Building wheels')
subprocess.check_call(['pip', 'wheel', '-w', 'dist/wheel-cache', '.'])
for entry in entry_points['console_scripts']:
name, call = tuple([_.strip() for _ in entry.split('=')])
print('Creating {0} as {1}'.format(name, call))
pex_cmd = [
'pex',
'--no-pypi',
'--disable-cache',
'--repo=dist/wheel-cache',
'-o', 'build/bin/{0}'.format(name),
'-e', call,
'.',
]
pex_cmd.extend(install_requires)
print('Running {0}'.format(' '.join(pex_cmd)))
subprocess.check_call(pex_cmd)
class VirtualEnv(Command):
user_options = [
('python-interpreter=', 'p', 'The interpreter to build your venv with')
]
def initialize_options(self):
if os.environ.get('VIRTUAL_ENV'):
raise RuntimeError(
"Please deacivate your current virtual environment before running this subcommand!"
)
self.python_interpreter = 'python'
def finalize_options(self):
print("Using interpreter: {0}".format(self.python_interpreter))
def run(self):
venv_path = os.path.join(here, 'venv', 'kafka-tools')
venv_cmd = [
'virtualenv',
'-p', self.python_interpreter,
venv_path
]
print('Creating virtual environment in ', venv_path)
subprocess.check_call(venv_cmd)
print(
'Linking `activate` to top level of project.\n'
'To activate, simply run `source activate`.'
)
try:
os.symlink(
os.path.join(venv_path, 'bin', 'activate'),
os.path.join(os.path.dirname(os.path.abspath(__file__)), 'activate')
)
except OSError:
print(
'Unable to create symlink, you may have a stale symlink from a previous invocation, '
'or you may have already set up your virtual environment.'
)
here = os.path.abspath(os.path.dirname(__file__))
# Get the long description from the README file
with open(os.path.join(here, 'README.rst'), encoding='utf-8') as f:
long_description = f.read()
setup(
name='kafka-tools',
# Versions should comply with PEP440. For a discussion on single-sourcing
# the version across setup.py and the project code, see
# https://packaging.python.org/en/latest/single_source_version.html
version='0.1.9',
author='Todd Palino',
author_email='[email protected]',
description='A collection of tools and scripts for working with Apache Kafka',
long_description=long_description,
# The project's main homepage.
url='https://github.com/linkedin/kafka-tools',
# Choose your license
license='Apache 2.0',
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: System Administrators',
'Topic :: Utilities',
'License :: OSI Approved :: Apache Software License',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
],
keywords='kafka tools admin',
packages=find_packages(exclude=['contrib', 'docs', 'tests']),
install_requires=install_requires,
tests_require=[
'coverage',
'mock',
'pytest-cov',
'pytest',
'testfixtures',
'timeout-decorator',
],
setup_requires=[
'pytest-runner',
'flake8',
],
extras_require={
'dev': ['check-manifest'],
'test': ['coverage'],
},
entry_points=entry_points,
cmdclass={
'virtualenv': VirtualEnv,
'pexify': Pex
},
)