-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
56 lines (43 loc) · 1.51 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import os
import sys
import subprocess
import shutil
from setuptools import setup
from setuptools.command.build_py import build_py
from contextlib import ContextDecorator
def try_exec(*cmds):
proc = subprocess.run(cmds)
if proc.returncode != 0:
print('`{}` failed'.format(' '.join(cmds)), file=sys.stderr)
proc.check_returncode()
class enter_dir(ContextDecorator):
def __init__(self, path):
self.path = path
self.old_path = os.getcwd()
def __enter__(self):
os.chdir(self.path)
return self
def __exit__(self, *exc):
os.chdir(self.old_path)
return False
class build_libbash(build_py):
def run(self):
build_py.run(self)
with enter_dir('libbash/bash-5.2'):
try_exec('./configure')
try_exec('make', 'clean', 'all')
shutil.copy2('libbash/bash-5.2/bash.so', os.path.join(self.build_lib, 'libbash/bash-5.2/bash.so'))
setup(name='libbash',
packages=['libbash', 'libbash.bash_command'],
cmdclass={'build_py': build_libbash},
package_data={'': ['libbash/bash-5.2']},
include_package_data=True,
version='0.1.13',
description="A Python library for parsing Bash scripts into an AST",
long_description=open('README.md').read(),
long_description_content_type='text/markdown',
url="https://github.com/binpash/libbash/",
author='Seth Sabar',
author_email='[email protected]',
license="GPL-3.0",
has_ext_modules=lambda: True)