forked from gambitproject/gambit
-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
153 lines (137 loc) · 5.21 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#
# This file is part of Gambit
# Copyright (c) 1994-2023, The Gambit Project (http://www.gambit-project.org)
#
# FILE: src/python/setup.py
# Setuptools configuration file for Gambit Python extension
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
import glob
import platform
import Cython.Build
import setuptools
# By compiling this separately as a C library, we avoid problems
# with passing C++-specific flags when building the extension
lrslib = ("lrslib", {"sources": glob.glob("src/solvers/lrs/*.c")})
cppgambit_include_dirs = ["src"]
cppgambit_cflags = (
["-std=c++17"] if platform.system() == "Darwin"
else ["/std:c++17"] if platform.system() == "Windows"
else []
)
cppgambit_core = (
"cppgambit_core",
{
"sources": glob.glob("src/core/*.cc"),
"obj_deps": {"": glob.glob("src/core/*.h") + glob.glob("src/core/*.imp")},
"include_dirs": cppgambit_include_dirs,
"cflags": cppgambit_cflags,
}
)
cppgambit_games = (
"cppgambit_games",
{
"sources": glob.glob("src/games/*.cc") + glob.glob("src/games/agg/*.cc"),
"obj_deps": {
"": (
glob.glob("src/core/*.h") + glob.glob("src/core/*.imp") +
glob.glob("src/games/*.h") + glob.glob("src/games/*.imp") +
glob.glob("src/games/agg/*.h")
)
},
"include_dirs": cppgambit_include_dirs,
"cflags": cppgambit_cflags,
}
)
def solver_library_config(library_name: str, paths: list) -> tuple:
return (
library_name,
{
"sources": [fn for solver in paths for fn in glob.glob(f"src/solvers/{solver}/*.cc")],
"obj_deps": {
"": (
glob.glob("src/core/*.h") + glob.glob("src/games/*.h") +
glob.glob("src/games/agg/*.h") +
[fn for solver in paths for fn in glob.glob(f"src/solvers/{solver}/*.h")]
)
},
"include_dirs": cppgambit_include_dirs,
"cflags": cppgambit_cflags,
}
)
cppgambit_bimatrix = solver_library_config("cppgambit_bimatrix",
["linalg", "lp", "lcp", "enummixed"])
cppgambit_liap = solver_library_config("cppgambit_liap", ["liap"])
cppgambit_logit = solver_library_config("cppgambit_logit", ["logit"])
cppgambit_gtracer = solver_library_config("cppgambit_gtracer", ["gtracer", "ipa", "gnm"])
cppgambit_simpdiv = solver_library_config("cppgambit_simpdiv", ["simpdiv"])
libgambit = setuptools.Extension(
"pygambit.gambit",
sources=["src/pygambit/gambit.pyx"],
language="c++",
include_dirs=["src", "src/pygambit"],
extra_compile_args=(
["-std=c++17"] if platform.system() == "Darwin"
else ["/std:c++17"] if platform.system() == "Windows"
else []
)
)
def readme():
with open("src/README.rst") as f:
return f.read()
setuptools.setup(
name="pygambit",
version="16.2.0",
description="The package for computation in game theory",
long_description=readme(),
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: Scientific/Engineering :: Mathematics"
],
keywords="game theory Nash equilibrium",
license="GPL2+",
author="Theodore Turocy",
author_email="ted.turocy@gmail.com",
url="http://www.gambit-project.org",
project_urls={
"Documentation": "https://gambitproject.readthedocs.io/",
"Source": "https://github.com/gambitproject/gambit",
"Tracker": "https://github.com/gambitproject/gambit/issues",
},
python_requires=">=3.8",
install_requires=[
"lxml", # used for reading/writing GTE files
"numpy",
"scipy",
"deprecated",
],
libraries=[cppgambit_bimatrix, cppgambit_liap, cppgambit_logit, cppgambit_simpdiv,
cppgambit_gtracer,
cppgambit_games, cppgambit_core, lrslib],
package_dir={"": "src"},
packages=["pygambit"],
ext_modules=Cython.Build.cythonize(libgambit,
language_level="3str",
compiler_directives={"binding": True})
)