/
setup.py
125 lines (94 loc) · 3.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# coding=utf-8
import os
import pathlib
from setuptools import setup, find_packages, Extension
from setuptools.command.build_ext import build_ext as build_ext_orig
from distutils.core import setup
here = os.path.abspath(os.path.dirname(__file__))
def get_description():
from codecs import open
# Get the long description from the README file
with open(os.path.join(here, 'README.md'), encoding='utf-8') as f:
return f.read()
def get_version():
import sys
sys.path.insert(0, os.path.join(here, "src", "sltp"))
import version
v = version.get_version()
sys.path = sys.path[1:]
return v
def main():
setup(
name='sltp',
version=get_version(),
description='The SLTP Generalized Planning Framework: Sample, Learn, Transform & Plan',
long_description=get_description(),
url='https://github.com/aig-upf/sltp',
author='Blai Bonet and Guillem Francès',
author_email='-',
keywords='planning logic STRIPS generalized planning',
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Science/Research',
'Topic :: Scientific/Engineering :: Artificial Intelligence',
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
],
packages=find_packages('src'), # include all packages under src
package_dir={'': 'src'}, # tell distutils packages are under src
install_requires=[
'setuptools',
'psutil',
'bitarray',
'numpy',
"tarski @ git+ssh://git@github.com/aig-upf/tarski.git@1c107d5#egg=tarski-devel"
],
# ext_modules=[CMakeExtension('featuregen', os.path.join(here, "src", "features"))],
# cmdclass={'build_ext': BuildExt, },
extras_require={
'dev': ['pytest', 'tox'],
'test': ['pytest', 'tox'],
},
)
class BuildExt(build_ext_orig):
""" A helper to build c++ code using CMake.
@see https://stackoverflow.com/a/48015772 """
def run(self):
for ext in self.extensions:
self.build_cmake(ext)
super().run()
def build_cmake(self, ext):
cwd = pathlib.Path().absolute()
# these dirs will be created in build_py, so if you don't have
# any python sources to bundle, the dirs will be missing
build_temp = pathlib.Path(self.build_temp)
build_temp.mkdir(parents=True, exist_ok=True)
extdir = pathlib.Path(self.get_ext_fullpath(ext.name))
extdir.mkdir(parents=True, exist_ok=True)
# example of cmake args
config = 'Debug' if self.debug else 'Release'
cmake_args = [
# '-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=' + str(extdir.parent.absolute()),
'-DCMAKE_RUNTIME_OUTPUT_DIRECTORY={}'.format(ext.path),
'-DCMAKE_BUILD_TYPE=' + config
]
# example of build args
build_args = [
'--config', config,
'--', '-j4'
]
os.chdir(str(build_temp))
self.spawn(['cmake', ext.path] + cmake_args)
if not self.dry_run:
self.spawn(['cmake', '--build', '.'] + build_args)
os.chdir(str(cwd))
class CMakeExtension(Extension):
def __init__(self, name, path):
# don't invoke the original build_ext for this special extension
super().__init__(name, sources=[])
self.path = path
if __name__ == '__main__':
main()