|
20 | 20 | from subprocess import Popen, PIPE
|
21 | 21 |
|
22 | 22 | DIR = os.path.abspath(os.path.dirname(__file__))
|
23 |
| -LIB_DIR = DIR + '/c-bindings' |
24 |
| -MODULE_SOURCES = ['python/_jsonnet.c'] |
| 23 | +LIB_DIR = DIR + "/c-bindings" |
| 24 | +MODULE_SOURCES = ["python/_jsonnet.c"] |
| 25 | + |
25 | 26 |
|
26 | 27 | def get_version():
|
27 | 28 | """
|
28 | 29 | Parses the version out of vm.go
|
29 | 30 | """
|
30 |
| - with open(os.path.join(DIR, 'vm.go')) as f: |
| 31 | + with open(os.path.join(DIR, "vm.go")) as f: |
31 | 32 | for line in f:
|
32 |
| - if 'const' in line and 'version' in line: |
33 |
| - v_code = line.partition('=')[2].strip('\n "') |
34 |
| - if v_code[0] == 'v': |
| 33 | + if "const" in line and "version" in line: |
| 34 | + v_code = line.partition("=")[2].strip('\n "') |
| 35 | + if v_code[0] == "v": |
35 | 36 | return v_code[1:]
|
36 | 37 |
|
37 | 38 | return None
|
38 | 39 |
|
| 40 | + |
39 | 41 | class BuildJsonnetExt(BuildExt):
|
40 | 42 | def run(self):
|
41 |
| - p = Popen(['go', 'build', '-o', 'libgojsonnet.a', '-buildmode=c-archive'], cwd=LIB_DIR, stdout=PIPE) |
| 43 | + p = Popen( |
| 44 | + ["go", "build", "-o", "libgojsonnet.a", "-buildmode=c-archive"], |
| 45 | + cwd=LIB_DIR, |
| 46 | + stdout=PIPE, |
| 47 | + ) |
42 | 48 | p.wait()
|
43 | 49 |
|
44 | 50 | if p.returncode != 0:
|
45 |
| - raise Exception('Could not build libgojsonnet.a') |
| 51 | + raise Exception("Could not build libgojsonnet.a") |
46 | 52 |
|
47 | 53 | BuildExt.run(self)
|
48 | 54 |
|
| 55 | + |
49 | 56 | class NoopTestCommand(TestCommand):
|
50 | 57 | def __init__(self, dist):
|
51 |
| - print("_gojsonnet does not support running tests with 'python setup.py test'. Please run 'pytest'.") |
| 58 | + print( |
| 59 | + "_gojsonnet does not support running tests with 'python setup.py test'. Please run 'pytest'." |
| 60 | + ) |
| 61 | + |
52 | 62 |
|
53 | 63 | jsonnet_ext = Extension(
|
54 |
| - '_gojsonnet', |
| 64 | + "_gojsonnet", |
55 | 65 | sources=MODULE_SOURCES,
|
56 | 66 | extra_objects=[
|
57 |
| - LIB_DIR + '/libgojsonnet.a', |
| 67 | + LIB_DIR + "/libgojsonnet.a", |
58 | 68 | ],
|
59 |
| - include_dirs = ['cpp-jsonnet/include'], |
60 |
| - language='c++', |
| 69 | + include_dirs=["cpp-jsonnet/include"], |
| 70 | + language="c++", |
61 | 71 | )
|
62 | 72 |
|
63 |
| -setup(name='gojsonnet', |
64 |
| - url='https://jsonnet.org', |
65 |
| - description='Python bindings for Jsonnet - The data templating language ', |
66 |
| - author='David Cunningham', |
67 |
| - |
| 73 | +setup( |
| 74 | + name="gojsonnet", |
| 75 | + url="https://jsonnet.org", |
| 76 | + description="Python bindings for Jsonnet - The data templating language ", |
| 77 | + author="David Cunningham", |
| 78 | + |
68 | 79 | version=get_version(),
|
69 | 80 | cmdclass={
|
70 |
| - 'build_ext': BuildJsonnetExt, |
71 |
| - 'test': NoopTestCommand, |
| 81 | + "build_ext": BuildJsonnetExt, |
| 82 | + "test": NoopTestCommand, |
72 | 83 | },
|
73 | 84 | ext_modules=[jsonnet_ext],
|
74 | 85 | )
|
0 commit comments