mirror of
https://github.com/google/go-jsonnet.git
synced 2025-08-07 23:07:14 +02:00
reformat setup.py
This commit is contained in:
parent
3c92d79e96
commit
7c36700ad7
51
setup.py
51
setup.py
@ -20,55 +20,66 @@ from setuptools.command.test import test as TestCommand
|
||||
from subprocess import Popen, PIPE
|
||||
|
||||
DIR = os.path.abspath(os.path.dirname(__file__))
|
||||
LIB_DIR = DIR + '/c-bindings'
|
||||
MODULE_SOURCES = ['python/_jsonnet.c']
|
||||
LIB_DIR = DIR + "/c-bindings"
|
||||
MODULE_SOURCES = ["python/_jsonnet.c"]
|
||||
|
||||
|
||||
def get_version():
|
||||
"""
|
||||
Parses the version out of vm.go
|
||||
"""
|
||||
with open(os.path.join(DIR, 'vm.go')) as f:
|
||||
with open(os.path.join(DIR, "vm.go")) as f:
|
||||
for line in f:
|
||||
if 'const' in line and 'version' in line:
|
||||
v_code = line.partition('=')[2].strip('\n "')
|
||||
if v_code[0] == 'v':
|
||||
if "const" in line and "version" in line:
|
||||
v_code = line.partition("=")[2].strip('\n "')
|
||||
if v_code[0] == "v":
|
||||
return v_code[1:]
|
||||
|
||||
return None
|
||||
|
||||
|
||||
class BuildJsonnetExt(BuildExt):
|
||||
def run(self):
|
||||
p = Popen(['go', 'build', '-o', 'libgojsonnet.a', '-buildmode=c-archive'], cwd=LIB_DIR, stdout=PIPE)
|
||||
p = Popen(
|
||||
["go", "build", "-o", "libgojsonnet.a", "-buildmode=c-archive"],
|
||||
cwd=LIB_DIR,
|
||||
stdout=PIPE,
|
||||
)
|
||||
p.wait()
|
||||
|
||||
if p.returncode != 0:
|
||||
raise Exception('Could not build libgojsonnet.a')
|
||||
raise Exception("Could not build libgojsonnet.a")
|
||||
|
||||
BuildExt.run(self)
|
||||
|
||||
|
||||
class NoopTestCommand(TestCommand):
|
||||
def __init__(self, dist):
|
||||
print("_gojsonnet does not support running tests with 'python setup.py test'. Please run 'pytest'.")
|
||||
print(
|
||||
"_gojsonnet does not support running tests with 'python setup.py test'. Please run 'pytest'."
|
||||
)
|
||||
|
||||
|
||||
jsonnet_ext = Extension(
|
||||
'_gojsonnet',
|
||||
"_gojsonnet",
|
||||
sources=MODULE_SOURCES,
|
||||
extra_objects=[
|
||||
LIB_DIR + '/libgojsonnet.a',
|
||||
LIB_DIR + "/libgojsonnet.a",
|
||||
],
|
||||
include_dirs = ['cpp-jsonnet/include'],
|
||||
language='c++',
|
||||
include_dirs=["cpp-jsonnet/include"],
|
||||
language="c++",
|
||||
)
|
||||
|
||||
setup(name='gojsonnet',
|
||||
url='https://jsonnet.org',
|
||||
description='Python bindings for Jsonnet - The data templating language ',
|
||||
author='David Cunningham',
|
||||
author_email='dcunnin@google.com',
|
||||
setup(
|
||||
name="gojsonnet",
|
||||
url="https://jsonnet.org",
|
||||
description="Python bindings for Jsonnet - The data templating language ",
|
||||
author="David Cunningham",
|
||||
author_email="dcunnin@google.com",
|
||||
version=get_version(),
|
||||
cmdclass={
|
||||
'build_ext': BuildJsonnetExt,
|
||||
'test': NoopTestCommand,
|
||||
"build_ext": BuildJsonnetExt,
|
||||
"test": NoopTestCommand,
|
||||
},
|
||||
ext_modules=[jsonnet_ext],
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user