Skip to content

Commit f6536f0

Browse files
authored
update finding libscip (path to config.h) (#1106)
The path to config.h in SCIP 10 is given by lib/shared/include/scip/config.h now. Before this was avoided by using NO_CONFIG_HEADER.
1 parent 33d0664 commit f6536f0

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

setup.py

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
else:
2323
# fall back to global installation
2424
if platform.system() == "Darwin":
25-
includedir = "/usr/local/include"
25+
includedirs = ["/usr/local/include"]
2626
libdir = "/usr/local/lib"
2727
else:
28-
includedir = "."
28+
includedirs = ["."]
2929
libdir = "."
3030
libname = "libscip" if platform.system() == "Windows" else "scip"
3131
print("Assuming that SCIP is installed globally, because SCIPOPTDIR is undefined.\n")
@@ -34,39 +34,36 @@
3434

3535
# check whether SCIP is installed in the given directory
3636
if os.path.exists(os.path.join(scipoptdir, "include")):
37-
includedir = os.path.abspath(os.path.join(scipoptdir, "include"))
37+
includedirs = [os.path.abspath(os.path.join(scipoptdir, "include"))]
3838
else:
39-
print(f"SCIPOPTDIR={scipoptdir} does not contain an include directory; searching for include files in src or ../src directory.")
39+
print("SCIPOPTDIR=%s does not contain an include directory; searching for include files in src or ../src directory.\n" % scipoptdir)
4040

4141
if os.path.exists(os.path.join(scipoptdir, "src")):
4242
# SCIP seems to be installed in-place; check whether it was built using make or cmake
4343
if os.path.exists(os.path.join(scipoptdir, "src", "scip")):
4444
# assume that SCIPOPTDIR pointed to the main source directory (make)
45-
includedir = os.path.abspath(os.path.join(scipoptdir, "src"))
45+
includedirs = [os.path.abspath(os.path.join(scipoptdir, "src")), os.path.abspath(os.path.join(scipoptdir, "lib/shared/include"))]
4646
else:
4747
# assume that SCIPOPTDIR pointed to a cmake build directory; try one level up (this is just a heuristic)
4848
if os.path.exists(os.path.join(scipoptdir, "..", "src", "scip")):
49-
includedir = os.path.abspath(os.path.join(scipoptdir, "..", "src"))
49+
includedirs = [os.path.abspath(os.path.join(scipoptdir, "..", "src"))]
5050
else:
51-
sys.exit(f"Could neither find src/scip nor ../src/scip directory in SCIPOPTDIR={scipoptdir}. Consider installing SCIP in a separate directory.")
51+
sys.exit("Could neither find src/scip nor ../src/scip directory in SCIPOPTDIR=%s. Consider installing SCIP in a separate directory." % scipoptdir)
5252
else:
53-
sys.exit(f"Could not find a src directory in SCIPOPTDIR={scipoptdir}; maybe it points to a wrong directory.")
53+
sys.exit("Could not find a src directory in SCIPOPTDIR=%s; maybe it points to a wrong directory." % scipoptdir)
5454

5555
# determine library
5656
if os.path.exists(os.path.join(scipoptdir, "lib", "shared", "libscip.so")):
5757
# SCIP seems to be created with make
5858
libdir = os.path.abspath(os.path.join(scipoptdir, "lib", "shared"))
5959
libname = "scip"
60-
extra_compile_args.append("-DNO_CONFIG_HEADER")
61-
# the following is a temporary hack to make it compile with SCIP/make:
62-
extra_compile_args.append("-DTPI_NONE") # if other TPIs are used, please modify
6360
else:
6461
# assume that SCIP is installed on the system
6562
libdir = os.path.abspath(os.path.join(scipoptdir, "lib"))
6663
libname = "libscip" if platform.system() == "Windows" else "scip"
6764

68-
print(f"Using include path {includedir}.")
69-
print(f"Using SCIP library {libname} at {libdir}.\n")
65+
print("Using include path %s." % includedirs)
66+
print("Using SCIP library %s at %s.\n" % (libname, libdir))
7067

7168
# set runtime libraries
7269
if platform.system() in ["Linux", "Darwin"]:
@@ -96,16 +93,15 @@
9693

9794
ext = ".pyx" if use_cython else ".c"
9895

99-
10096
on_github_actions = os.getenv('GITHUB_ACTIONS') == 'true'
10197
release_mode = os.getenv('RELEASE') == 'true'
10298
compile_with_line_tracing = on_github_actions and not release_mode
10399

104100
extensions = [
105101
Extension(
106102
"pyscipopt.scip",
107-
[os.path.join(packagedir, f"scip{ext}")],
108-
include_dirs=[includedir],
103+
[os.path.join(packagedir, "scip%s" % ext)],
104+
include_dirs=includedirs,
109105
library_dirs=[libdir],
110106
libraries=[libname],
111107
extra_compile_args=extra_compile_args,

0 commit comments

Comments
 (0)