-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_commands.py
More file actions
55 lines (41 loc) · 1.29 KB
/
build_commands.py
File metadata and controls
55 lines (41 loc) · 1.29 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
from setuptools.command.install import install
from setuptools.command.develop import develop
from setuptools.command.egg_info import egg_info
from setuptools.command.build_ext import build_ext
import subprocess
import os
def customize(command):
command_name = str(command.mro()[1].__name__).strip()
original_run = command.run
def run(self):
# Run the rest of the installer first
original_run(self)
# Create a new subprocess to run the included shell script
print("Running " + command_name + " commands...")
current_dir_path = os.path.dirname(os.path.realpath(__file__))
create_service_script_path = os.path.join(current_dir_path, 'setup.sh')
if os.path.exists(create_service_script_path):
# stdout and stderr are combined in shell output
output = subprocess.run(
[create_service_script_path, command_name],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
cwd=current_dir_path,
).stdout
print(output.decode('UTF-8'))
else:
print("setup.sh not found; skipping post-" + command_name + " actions.")
command.run = run
return command
@customize
class CustomInstallCommand(install):
pass
@customize
class CustomDevelopCommand(develop):
pass
@customize
class CustomEggInfoCommand(egg_info):
pass
@customize
class CustomBuildExtCommand(build_ext):
pass