forked from Metta-AI/mettagrid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
87 lines (78 loc) · 2.63 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
from sympy import li
from setuptools import Extension, setup, find_packages, Command
from Cython.Build import cythonize
import numpy
import os
import multiprocessing
import sys
multiprocessing.freeze_support()
def build_ext(srcs, module_name=None):
if module_name is None:
module_name = srcs[0].replace("/", ".").replace(".pyx", "").replace(".cpp", "")
return Extension(
module_name,
srcs,
define_macros=[('NPY_NO_DEPRECATED_API', 'NPY_1_7_API_VERSION')],
)
ext_modules = [
build_ext(["mettagrid/action.pyx"]),
build_ext(["mettagrid/event.pyx"]),
build_ext(["mettagrid/grid.cpp"]),
build_ext(["mettagrid/grid_env.pyx"]),
build_ext(["mettagrid/grid_object.pyx"]),
build_ext(["mettagrid/base_encoder.pyx"]),
build_ext(["mettagrid/stats_tracker.pyx"]),
build_ext(["mettagrid/objects.pyx"]),
build_ext(["mettagrid/observation_encoder.pyx"]),
build_ext(["mettagrid/actions/actions.pyx"]),
build_ext(["mettagrid/actions/attack.pyx"]),
build_ext(["mettagrid/actions/gift.pyx"]),
build_ext(["mettagrid/actions/move.pyx"]),
build_ext(["mettagrid/actions/noop.pyx"]),
build_ext(["mettagrid/actions/rotate.pyx"]),
build_ext(["mettagrid/actions/shield.pyx"]),
build_ext(["mettagrid/actions/swap.pyx"]),
build_ext(["mettagrid/actions/use.pyx"]),
build_ext(["mettagrid/mettagrid.pyx"], "mettagrid.mettagrid_c"),
]
debug = os.getenv('DEBUG', '0') == '1'
annotate = os.getenv('ANNOTATE', '0') == '1'
build_dir = 'build'
if debug:
build_dir = 'build_debug'
os.makedirs(build_dir, exist_ok=True)
num_threads = multiprocessing.cpu_count() if sys.platform == 'linux' else None
setup(
name='metta',
version='0.1',
packages=find_packages(),
nthreads=num_threads,
entry_points={
'console_scripts': [
# If you want to create any executable scripts in your package
# For example: 'script_name = module:function'
]
},
include_dirs=[numpy.get_include()],
ext_modules=cythonize(
ext_modules,
build_dir=build_dir,
compiler_directives={
"language_level": "3",
"embedsignature": debug,
"annotation_typing": debug,
"cdivision": debug,
"boundscheck": debug,
"wraparound": debug,
"initializedcheck": debug,
"nonecheck": debug,
"overflowcheck": debug,
"overflowcheck.fold": debug,
"profile": debug,
"linetrace": debug,
"c_string_encoding": "utf-8",
"c_string_type": "str",
},
annotate=debug or annotate,
),
)