forked from Kattis/problemtools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·95 lines (75 loc) · 2.65 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/env python2
from setuptools import setup, find_packages
from setuptools.command.bdist_egg import bdist_egg as _bdist_egg
import distutils.cmd
from distutils.command.build import build as _build
import os
import subprocess
class BuildSupport(distutils.cmd.Command):
"""A custom command to build the support programs."""
description = 'build the problemtools support programs'
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
"""Run command."""
# FIXME this seems very fragile...
dest = os.path.join(os.path.realpath(self.distribution.command_obj['build'].build_lib),
'problemtools', 'support')
command = ['make', '-C', 'support', 'install', 'DESTDIR=%s' % dest]
self.announce('Running command: %s' % ' '.join(command), level=distutils.log.INFO)
subprocess.check_call(command)
class bdist_egg(_bdist_egg):
"""Updated bdist_egg command that also builds support."""
def run(self):
self.run_command('build_support')
_bdist_egg.run(self)
class build(_build):
"""Updated build command that also builds support."""
def run(self):
self.run_command('build_support')
_build.run(self)
def get_version():
base_dir = os.path.dirname(__file__)
__version__ = None
try:
update_script = os.path.join(base_dir, 'admin', 'update_version.py.sh')
__version__ = subprocess.check_output([update_script])
except:
pass
if __version__ is None:
version_file = os.path.join(base_dir, 'problemtools', '_version.py')
with open(version_file, 'r') as version_in:
exec(version_in.read())
return __version__
setup(name='problemtools',
version=get_version(),
description='Kattis Problem Tools',
maintainer='Per Austrin',
maintainer_email='[email protected]',
url='https://github.com/Kattis/problemtools',
license='MIT',
packages=find_packages(),
entry_points = {
'console_scripts': [
'verifyproblem=problemtools.verifyproblem:main',
'problem2html=problemtools.problem2html:main',
'problem2pdf=problemtools.problem2pdf:main',
]
},
include_package_data=True,
install_requires=[
'PyYAML',
'plasTeX',
],
# Temporarily disabled, see setup.cfg
# For now tests can be run manually with pytest
# setup_requires=['pytest-runner'],
# tests_require=['pytest'],
cmdclass={
'build_support': BuildSupport,
'bdist_egg': bdist_egg,
'build': build
},
)