mirror of
https://github.com/google/go-jsonnet.git
synced 2025-08-08 07:17:12 +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
|
from subprocess import Popen, PIPE
|
||||||
|
|
||||||
DIR = os.path.abspath(os.path.dirname(__file__))
|
DIR = os.path.abspath(os.path.dirname(__file__))
|
||||||
LIB_DIR = DIR + '/c-bindings'
|
LIB_DIR = DIR + "/c-bindings"
|
||||||
MODULE_SOURCES = ['python/_jsonnet.c']
|
MODULE_SOURCES = ["python/_jsonnet.c"]
|
||||||
|
|
||||||
|
|
||||||
def get_version():
|
def get_version():
|
||||||
"""
|
"""
|
||||||
Parses the version out of vm.go
|
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:
|
for line in f:
|
||||||
if 'const' in line and 'version' in line:
|
if "const" in line and "version" in line:
|
||||||
v_code = line.partition('=')[2].strip('\n "')
|
v_code = line.partition("=")[2].strip('\n "')
|
||||||
if v_code[0] == 'v':
|
if v_code[0] == "v":
|
||||||
return v_code[1:]
|
return v_code[1:]
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
class BuildJsonnetExt(BuildExt):
|
class BuildJsonnetExt(BuildExt):
|
||||||
def run(self):
|
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()
|
p.wait()
|
||||||
|
|
||||||
if p.returncode != 0:
|
if p.returncode != 0:
|
||||||
raise Exception('Could not build libgojsonnet.a')
|
raise Exception("Could not build libgojsonnet.a")
|
||||||
|
|
||||||
BuildExt.run(self)
|
BuildExt.run(self)
|
||||||
|
|
||||||
|
|
||||||
class NoopTestCommand(TestCommand):
|
class NoopTestCommand(TestCommand):
|
||||||
def __init__(self, dist):
|
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(
|
jsonnet_ext = Extension(
|
||||||
'_gojsonnet',
|
"_gojsonnet",
|
||||||
sources=MODULE_SOURCES,
|
sources=MODULE_SOURCES,
|
||||||
extra_objects=[
|
extra_objects=[
|
||||||
LIB_DIR + '/libgojsonnet.a',
|
LIB_DIR + "/libgojsonnet.a",
|
||||||
],
|
],
|
||||||
include_dirs = ['cpp-jsonnet/include'],
|
include_dirs=["cpp-jsonnet/include"],
|
||||||
language='c++',
|
language="c++",
|
||||||
)
|
)
|
||||||
|
|
||||||
setup(name='gojsonnet',
|
setup(
|
||||||
url='https://jsonnet.org',
|
name="gojsonnet",
|
||||||
description='Python bindings for Jsonnet - The data templating language ',
|
url="https://jsonnet.org",
|
||||||
author='David Cunningham',
|
description="Python bindings for Jsonnet - The data templating language ",
|
||||||
author_email='dcunnin@google.com',
|
author="David Cunningham",
|
||||||
|
author_email="dcunnin@google.com",
|
||||||
version=get_version(),
|
version=get_version(),
|
||||||
cmdclass={
|
cmdclass={
|
||||||
'build_ext': BuildJsonnetExt,
|
"build_ext": BuildJsonnetExt,
|
||||||
'test': NoopTestCommand,
|
"test": NoopTestCommand,
|
||||||
},
|
},
|
||||||
ext_modules=[jsonnet_ext],
|
ext_modules=[jsonnet_ext],
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user