-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
48 lines (42 loc) · 1.38 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
import os
import setuptools
from setuptools.command.build_py import build_py
from distutils.spawn import spawn, find_executable
package_name = 'digitex_engine_client'
class BuildPyCommand(build_py):
"""A custom build command to compile the proto file."""
def find_protoc(self):
protoc = os.environ.get('PROTOC', default=None)
if protoc and os.path.exists(protoc):
return protoc
return find_executable('protoc')
def run_protoc(self, protoc, source):
print('Generating Python code from', source)
out_path = os.path.join(self.build_lib, package_name)
self.mkpath(out_path)
spawn([
protoc,
source,
'-I' + os.path.dirname(source),
'--python_out=' + out_path
])
def run(self):
protoc = self.find_protoc()
if not protoc:
raise RuntimeError('Failed to find protoc')
messages_proto = os.path.join('src', package_name, 'messages.proto')
self.run_protoc(protoc, messages_proto)
setuptools.command.build_py.build_py.run(self)
setuptools.setup(
name='digitex-engine-client',
version='3.135.2-release',
author='Sergey Bugaev',
packages=[package_name],
package_dir={'': 'src'},
install_requires=[
'aiohttp',
'protobuf',
'pytz'
],
cmdclass={'build_py': BuildPyCommand}
)