forked from open-reaction-database/ord-schema
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
41 lines (34 loc) · 1.25 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
#! /usr/bin/env python
import os
from distutils.command import build_py
from distutils import spawn
import glob
import setuptools
import subprocess
class BuildPyCommand(build_py.build_py):
"""Command that generates Python interface for protocol buffers."""
def run(self):
"""Runs the protocol buffer compiler."""
protoc = spawn.find_executable('protoc')
if not protoc:
raise RuntimeError('cannot find protoc')
for source in glob.glob('proto/*.proto'):
protoc_command = [
protoc,
'--proto_path=..',
'--python_out=.',
os.path.join('ord-schema', source)
]
self.announce(f'running {protoc_command}')
subprocess.check_call(protoc_command)
# build_py.build_py is an old-style class, so super() doesn't work.
build_py.build_py.run(self)
if __name__ == '__main__':
setuptools.setup(
name='ord-schema',
description='Schema for the Open Reaction Database',
url='https://github.com/Open-Reaction-Database/ord-schema',
license='Apache License, Version 2.0',
version="0.1",
packages=setuptools.find_packages(),
cmdclass={'build_py': BuildPyCommand})