Repository navigation
Expand file tree
/
Copy pathsetup.py
More file actions
executable file
·69 lines (57 loc) · 2.18 KB
/
Copy pathsetup.py
File metadata and controls
executable file
·69 lines (57 loc) · 2.18 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env python3
# Supported environment variables:
#
# PUCCINI_REPO: set this to override the Puccini git repo location (i.e. to use a local clone)
# PUCCINI_GO_VERSION: set this to override the Go distribution version used to compile Puccini
import os, os.path, setuptools, subprocess, tempfile, shutil, sys
with open(os.path.join(os.path.dirname(__file__), 'puccini', '__init__.py')) as f:
globals_ = {}
exec(f.read(), globals_)
version = globals_['__version__']
with open(os.path.join(os.path.dirname(__file__), 'description.md')) as f:
description = f.read()
go_version = os.environ.get('PUCCINI_GO_VERSION', '1.18')
root = os.path.abspath(os.path.dirname(__file__)).replace('"', '\\"')
script = '''\
# Install Go
curl https://go.dev/dl/go{go_version}.linux-amd64.tar.gz --silent --location | tar -xz
GO=$PWD/go
# Build library
cd "{root}/puccini/go-source/puccini-tosca"
"$GO/bin/go" build \
-buildmode=c-shared \
-o=../../libpuccini.so \
-ldflags " \
-X 'github.com/tliron/kutil/version.GitVersion={version}'"
'''.format(root=root, version=version, go_version=go_version)
t = tempfile.mkdtemp()
try:
subprocess.check_output(('bash', '-o', 'pipefail', '-euxc', script), cwd=t)
except subprocess.CalledProcessError as e:
print(e.output)
sys.exit(e.returncode)
finally:
shutil.rmtree(t)
class Distribution(setuptools.dist.Distribution):
def has_ext_modules(_): # https://stackoverflow.com/a/62668026
return True
setuptools.setup(
name='puccini',
version=version,
description='Puccini',
long_description=description,
long_description_content_type='text/markdown',
license='Apache License 2.0',
author='Tal Liron',
author_email='tal.liron@gmail.com',
url='https://github.com/tliron/puccini',
download_url='https://github.com/tliron/puccini/releases',
classifiers=(
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License'),
packages=('puccini',),
package_dir={'puccini': 'puccini'},
package_data={'puccini': ['libpuccini.so']}, # for bdist
install_requires=('ard',),
distclass=Distribution)