forked from Kattis/problemtools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
executable file
·46 lines (33 loc) · 1.3 KB
/
Copy pathsetup.py
File metadata and controls
executable file
·46 lines (33 loc) · 1.3 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
#!/usr/bin/env python3
import os
import subprocess
import setuptools
import setuptools.command.build
class BuildSupport(setuptools.Command):
"""A custom command to build the support programs."""
description = 'build the problemtools support programs'
build_lib: str | None
def initialize_options(self) -> None:
self.build_lib = None
def finalize_options(self) -> None:
self.set_undefined_options('build_py', ('build_lib', 'build_lib'))
def run(self):
dest = os.path.join(os.path.realpath(self.build_lib), 'problemtools', 'support')
command = ['make', '-C', 'support', 'install', 'DESTDIR=%s' % dest]
subprocess.check_call(command)
# It's *very* unclear from setuptools' documentation what the best way to do this is.
#
# I think that the ideal way would be to insert BuildSupport as a SubCommand
# (https://setuptools.pypa.io/en/latest/userguide/extension.html), but I cannot find
# any documented way to inject a new subcommand (aside from overwriting one of
# the existing `build_*`, but those are only run conditionally).
class build(setuptools.command.build.build):
def run(self):
self.run_command('build_support')
super().run()
setuptools.setup(
cmdclass={
'build_support': BuildSupport,
'build': build,
},
)