Skip to content

Commit 88f0bd8

Browse files
authored
Merge pull request #35 from scipopt/simplify-global-scip
Try to find global SCIP installation
2 parents e031f0b + 759b48a commit 88f0bd8

File tree

1,045 files changed

+74
-308567
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,045 files changed

+74
-308567
lines changed

.github/workflows/build_and_test.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,31 @@ jobs:
6868
cargo t --features from-source create
6969
cargo t --features from-source --examples
7070
71+
linux-system-test:
72+
runs-on: ubuntu-22.04
73+
env:
74+
SCIP_VERSION: 9.2.4
75+
steps:
76+
- uses: actions/checkout@v3
77+
78+
- name: Install SCIP from debian package
79+
run: |
80+
wget --quiet --no-check-certificate https://github.com/scipopt/scip/releases/download/v$(echo "${{ env.SCIP_VERSION }}" | tr -d '.')/SCIPOptSuite-${{ env.SCIP_VERSION }}-Linux-ubuntu22.deb
81+
sudo apt-get update
82+
sudo apt install -y ./SCIPOptSuite-${{ env.SCIP_VERSION }}-Linux-ubuntu22.deb
83+
84+
- name: Verify SCIP headers are in standard locations
85+
run: |
86+
echo "Checking for headers in standard locations..."
87+
ls -la /usr/include/scip/ || echo "No headers in /usr/include/scip"
88+
ls -la /usr/local/include/scip/ || echo "No headers in /usr/local/include/scip"
89+
90+
- name: Build and test (should find headers in system directories)
91+
run: |
92+
cargo b -vv
93+
cargo t create
94+
cargo t --examples
95+
7196
linux-conda-test:
7297
runs-on: ubuntu-latest
7398
steps:

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ repository = "https://github.com/scipopt/scip-sys"
77
license = "Apache-2.0"
88
links = "scip"
99

10+
[package.metadata.docs.rs]
11+
features = ["bundled"]
12+
1013
[features]
1114
bundled = ["ureq", "zip", "tempfile", "zip-extract"]
1215
from-source = ["ureq", "zip", "tempfile", "zip-extract", "cmake"]

build.rs

Lines changed: 46 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,40 @@ fn look_in_scipoptdir_and_conda_env() -> Option<bindgen::Builder> {
9393
return None;
9494
}
9595

96+
fn try_system_include_paths() -> Option<bindgen::Builder> {
97+
println!("cargo:warning=Searching for SCIP in standard system directories");
98+
99+
// Common system include paths
100+
let search_paths = vec![
101+
"/usr/include",
102+
"/usr/local/include",
103+
"/opt/local/include", // MacPorts
104+
"/opt/homebrew/include", // Homebrew ARM Mac
105+
"/usr/local/opt/scip/include", // Homebrew Intel Mac
106+
];
107+
108+
for base_path in search_paths {
109+
let base = PathBuf::from(base_path);
110+
let scip_h = base.join("scip").join("scip.h");
111+
let scipdefplugins_h = base.join("scip").join("scipdefplugins.h");
112+
113+
if scip_h.exists() && scipdefplugins_h.exists() {
114+
println!("cargo:warning=Found SCIP headers in {}", base_path);
115+
116+
return Some(
117+
bindgen::Builder::default()
118+
.header(scip_h.to_str().unwrap())
119+
.header(scipdefplugins_h.to_str().unwrap())
120+
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
121+
.clang_arg(format!("-I{}", base_path))
122+
);
123+
}
124+
}
125+
126+
println!("cargo:warning=Could not find SCIP headers in standard system directories");
127+
None
128+
}
129+
96130
fn main() -> Result<(), Box<dyn Error>> {
97131
let builder = if is_bundled_feature_enabled() {
98132
download_scip();
@@ -107,29 +141,20 @@ fn main() -> Result<(), Box<dyn Error>> {
107141
if builder.is_some() {
108142
builder.unwrap()
109143
} else {
110-
println!("cargo:warning=SCIP was not found in SCIPOPTDIR or in Conda environemnt");
144+
println!("cargo:warning=SCIP was not found in SCIPOPTDIR or in Conda environment");
111145
println!("cargo:warning=Looking for SCIP in system libraries");
112146

113-
let headers_dir_path = "headers/";
114-
let headers_dir = PathBuf::from(headers_dir_path);
115-
let scip_header_file = PathBuf::from(&headers_dir)
116-
.join("scip")
117-
.join("scip.h")
118-
.to_str()
119-
.unwrap()
120-
.to_owned();
121-
let scipdefplugins_header_file = PathBuf::from(&headers_dir)
122-
.join("scip")
123-
.join("scipdefplugins.h")
124-
.to_str()
125-
.unwrap()
126-
.to_owned();
127-
128-
bindgen::Builder::default()
129-
.header(scip_header_file)
130-
.header(scipdefplugins_header_file)
131-
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
132-
.clang_arg(format!("-I{}", headers_dir_path))
147+
// Try common system include paths
148+
try_system_include_paths().unwrap_or_else(|| {
149+
panic!(
150+
"Could not find SCIP installation.\n\
151+
Please either:\n\
152+
- Set SCIPOPTDIR environment variable to point to your SCIP installation\n\
153+
- Install SCIP system-wide (headers in /usr/include or /usr/local/include)\n\
154+
- Use --features bundled to download and use a bundled version\n\
155+
- Use --features from-source to build SCIP from source"
156+
)
157+
})
133158
}
134159
};
135160

0 commit comments

Comments
 (0)