forked from cloudfoundry-community/cf-python-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
79 lines (65 loc) · 2.57 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
import os
import shutil
import subprocess
import sys
from setuptools import setup, find_packages, Command
src_dir = 'main'
package_directory = 'cloudfoundry_client'
package_name = 'cloudfoundry-client'
loggregator_dir = 'loggregator'
sys.path.insert(0, os.path.realpath(src_dir))
version_file = '%s/%s/__init__.py' % (src_dir, package_directory)
with open(version_file, 'r') as f:
for line in f.readlines():
if line.find('__version__') >= 0:
exec(line)
break
else:
raise AssertionError('Failed to load version from %s' % version_file)
def purge_sub_dir(path):
shutil.rmtree(os.path.join(os.path.dirname(__file__), path))
if 'test' in sys.argv[1:]:
print('%s added' % os.path.join(os.getcwd(), 'test'))
sys.path.append(os.path.join(os.getcwd(), 'test'))
class GenerateCommand(Command):
description = "generate protobuf class generation"
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
source_path = os.path.join(os.path.dirname(__file__), src_dir, package_directory, loggregator_dir)
for file_protobuf in os.listdir(source_path):
if file_protobuf.endswith('.proto'):
file_path = os.path.join(source_path, file_protobuf)
print('Generating %s from %s' % (file_protobuf, file_path))
subprocess.call(['protoc', '-I', source_path, '--python_out=%s' % source_path, file_path])
setup(name=package_name,
version=__version__,
zip_safe=True,
packages=find_packages(where=src_dir),
author='Benjamin Einaudi',
author_email='[email protected]',
description='A client library for CloudFoundry',
long_description=open('README.rst').read(),
url='http://github.com/antechrestos/cf-python-client',
classifiers=[
"Programming Language :: Python",
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Topic :: Communications",
],
entry_points={
'console_scripts': [
'cloudfoundry-client = %s.main.main:main' % package_directory,
]
},
cmdclass=dict(generate=GenerateCommand),
package_dir={package_directory: '%s/%s' % (src_dir, package_directory)},
install_requires=[requirement.rstrip(' \r\n') for requirement in open('requirements.txt')],
test_suite='test',
)