Skip to content

Commit e3e8664

Browse files
Merge remote-tracking branch 'origin/master' into fix-unsound
# Conflicts: # src/lib.rs # src/option.rs
2 parents d8d7019 + 98befbf commit e3e8664

File tree

14 files changed

+709
-300
lines changed

14 files changed

+709
-300
lines changed

.github/workflows/ci.yml

Lines changed: 19 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -10,75 +10,33 @@ env:
1010
CARGO_TERM_COLOR: always
1111

1212
jobs:
13-
check:
14-
name: Check
15-
runs-on: ubuntu-22.04
16-
strategy:
17-
matrix:
18-
rust:
19-
- stable
20-
- 1.60.0
21-
steps:
22-
- uses: actions/checkout@v2
23-
- uses: actions-rs/toolchain@v1
24-
with:
25-
profile: minimal
26-
toolchain: ${{ matrix.rust }}
27-
override: true
28-
- run: sudo apt-get -y install libmetis-dev libclang-dev
29-
- uses: actions-rs/cargo@v1
30-
with:
31-
command: check
32-
3313
test:
3414
name: Test Suite
3515
runs-on: ubuntu-22.04
3616
strategy:
3717
matrix:
3818
rust:
3919
- stable
40-
- 1.60.0
41-
steps:
42-
- uses: actions/checkout@v2
43-
- uses: actions-rs/toolchain@v1
44-
with:
45-
profile: minimal
46-
toolchain: ${{ matrix.rust }}
47-
override: true
48-
- run: sudo apt-get -y install libmetis-dev libclang-dev
49-
- uses: actions-rs/cargo@v1
50-
with:
51-
command: test
52-
53-
fmt:
54-
name: Rustfmt
55-
runs-on: ubuntu-22.04
20+
- 1.67.0
21+
- nightly
22+
features:
23+
- vendored
24+
- use-system
5625
steps:
57-
- uses: actions/checkout@v2
58-
- uses: actions-rs/toolchain@v1
26+
- uses: actions/checkout@v4
5927
with:
60-
profile: minimal
61-
toolchain: stable
62-
override: true
63-
components: rustfmt
64-
- uses: actions-rs/cargo@v1
28+
submodules: recursive
29+
- uses: dtolnay/rust-toolchain@master
6530
with:
66-
command: fmt
67-
args: -p metis -- --check
68-
69-
clippy:
70-
name: Clippy
71-
runs-on: ubuntu-22.04
72-
steps:
73-
- uses: actions/checkout@v2
74-
- uses: actions-rs/toolchain@v1
75-
with:
76-
profile: minimal
77-
toolchain: stable
78-
override: true
79-
components: clippy
31+
components: clippy, rustfmt
32+
toolchain: ${{ matrix.rust }}
8033
- run: sudo apt-get -y install libmetis-dev libclang-dev
81-
- uses: actions-rs/cargo@v1
82-
with:
83-
command: clippy
84-
args: -p metis -- -D warnings
34+
if: matrix.features == 'use-system'
35+
- name: Check Format
36+
run: cargo fmt -- --check
37+
- name: Run Check
38+
run: cargo check --features ${{ matrix.features }} --no-default-features
39+
- name: Run Clippy
40+
run: cargo clippy --features ${{ matrix.features }} --no-default-features
41+
- name: Run Tests
42+
run: cargo test --features ${{ matrix.features }} --no-default-features --all

.github/workflows/rustdoc.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,21 @@ jobs:
1616
runs-on: ubuntu-22.04
1717

1818
steps:
19-
- uses: actions/checkout@v2
19+
- uses: actions/checkout@v4
20+
with:
21+
submodules: recursive
2022
- uses: actions-rs/toolchain@v1
2123
with:
2224
toolchain: stable
2325
profile: minimal
2426
override: true
2527
components: rustfmt, rust-src
26-
- run: sudo apt-get -y install libmetis-dev libclang-dev
2728
- uses: actions-rs/cargo@v1
2829
with:
2930
command: doc
3031
args: --all --no-deps
3132
- name: Deploy Docs
32-
uses: peaceiris/actions-gh-pages@364c31d33bb99327c77b3a5438a83a357a6729ad # v3.4.0
33+
uses: peaceiris/actions-gh-pages@v3
3334
with:
3435
github_token: ${{ secrets.GITHUB_TOKEN }}
3536
publish_branch: gh-pages

.gitmodules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[submodule "vendor/GKlib"]
2+
path = vendor/GKlib
3+
url = https://github.com/KarypisLab/GKlib
4+
[submodule "vendor/metis"]
5+
path = vendor/metis
6+
url = https://github.com/KarypisLab/METIS

Cargo.toml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ members = [".", "metis-sys"]
33

44
[package]
55
name = "metis"
6-
version = "0.1.2"
7-
authors = ["Hubert Hirtz <[email protected]>"]
6+
version = "0.2.0"
7+
authors = ["Hubert Hirtz <[email protected]>", "Cedric Chevalier <[email protected]>"]
88
edition = "2021"
99
license = "MIT OR Apache-2.0"
1010
repository = "https://github.com/LIHPC-Computational-Geometry/metis-rs"
@@ -14,5 +14,14 @@ keywords = ["graph", "mesh", "matrix", "partitioning", "ordering"]
1414

1515
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1616

17+
[features]
18+
default = ["metis-sys/default"]
19+
20+
# Build and statically link to METIS and GKLib.
21+
vendored = ["metis-sys/vendored"]
22+
23+
# Use existing METIS install and links dynamically to it.
24+
use-system = ["metis-sys/use-system"]
25+
1726
[dependencies]
18-
metis-sys = { version = "0.2", path = "metis-sys" }
27+
metis-sys = { version = "0.3", path = "metis-sys", default-features = false }

README.md

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,48 @@
11
# metis-rs
22

3-
Idiomatic bindings to [libmetis][METIS], a graph and mesh partitioner.
3+
**metis-rs** is a Rust library providing idiomatic bindings to [libmetis][METIS], a library for graph and mesh
4+
partitioning. It is made to be used with Rust version 1.67.0 or above.
45

5-
## Building
6+
## Features
67

7-
Prerequisites:
8+
### Use of Vendored Feature
89

9-
- METIS
10-
- clang v5.0 or above
11-
- Rust v1.60.0 or above
10+
The `vendored` feature enables metis-rs to build METIS from source and link to it statically. If not enabled, metis-rs
11+
looks for an existing installation and links to it dynamically.
1212

13-
Bindings to METIS are made on the fly. If METIS is installed in a non-standard
14-
location, please use the following commands:
13+
### Use of System-wide Feature
1514

16-
export METISDIR=path/to/your/metis/installation
17-
export CPATH="$METISDIR/include"
18-
export RUSTFLAGS="-L$METISDIR/lib"
15+
The `use-system` feature enables metis-rs to use the system-wide installation of METIS. If not enabled, metis-rs will
16+
refer to its own version of METIS.
1917

20-
The environment variable `$METISDIR` must point to a directory containing a
21-
`lib/` and a `include/` directory containing the shared libraries and the
22-
headers of METIS, respectively.
18+
Please note, `vendored` and `use-system` features are mutually exclusive.
2319

24-
Once these variables are set, you can build the bindings with `cargo build`.
20+
## Guidance for non-standard METIS installations
2521

26-
### Build the documentation
22+
If you enabled the `use-system` feature and METIS is installed in a non-standard location, you must set the following
23+
environment variables:
24+
```bash
25+
export METISDIR=path/to/your/metis/installation
26+
export CPATH="$METISDIR/include"
27+
export RUSTFLAGS="-L$METISDIR/lib"
28+
```
2729

28-
If your METIS installation lies in a non-standard path, you will need to set
29-
the `RUSTDOCFLAGS` environment variable to build the documentation:
30+
`$METISDIR` must point to a directory containing both `lib/` and `include/` directories with METIS's shared libraries and headers, respectively.
3031

31-
export RUSTDOCFLAGS="-L$METISDIR/lib"
32+
## Building the documentation
3233

33-
Then you can call `cargo doc --no-deps --open`.
34+
To build the documentation, especially if METIS is installed in a non-standard location, set the `RUSTDOCFLAGS` environment variable:
35+
36+
```bash
37+
export RUSTDOCFLAGS="-L$METISDIR/lib"
38+
```
39+
Then the following command will generate and open the documentation:
40+
```bash
41+
cargo doc --no-deps --open
42+
```
3443

3544
## License
3645

37-
This program is distributed under the terms of both the MIT license and the
38-
Apache License (Version 2.0). See `LICENSE-APACHE` and `LICENSE-MIT` for
39-
details.
46+
metis-rs is distributed under the terms of both the MIT license and the Apache License (Version 2.0). Refer to `LICENSE-APACHE` and `LICENSE-MIT` for more details.
4047

41-
[METIS]: http://glaros.dtc.umn.edu/gkhome/metis/metis/overview
48+
[METIS]: http://glaros.dtc.umn.edu/gkhome/metis/metis/overview

examples/graph.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use metis::Graph;
22

33
fn main() -> Result<(), metis::Error> {
4-
let xadj = &mut [0, 2, 5, 8, 11, 13, 16, 20, 24, 28, 31, 33, 36, 39, 42, 44];
4+
let xadj = &[0, 2, 5, 8, 11, 13, 16, 20, 24, 28, 31, 33, 36, 39, 42, 44];
55
#[rustfmt::skip]
6-
let adjncy = &mut [
6+
let adjncy = &[
77
1, 5,
88
0, 2, 6,
99
1, 3, 7,

metis-sys/Cargo.toml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "metis-sys"
3-
version = "0.2.1"
4-
authors = ["Hubert Hirtz <[email protected]>"]
3+
version = "0.3.0"
4+
authors = ["Hubert Hirtz <[email protected]>", "Cedric Chevalier <[email protected]>"]
55
edition = "2021"
66
license = "MIT OR Apache-2.0"
77
repository = "https://github.com/LIHPC-Computational-Geometry/metis-rs"
@@ -11,5 +11,19 @@ categories = ["external-ffi-bindings", "mathematics"]
1111
keywords = ["graph", "mesh", "matrix", "partitioning", "ordering"]
1212

1313

14+
[features]
15+
default = ["vendored"]
16+
17+
# Build and statically link to METIS and GKLib.
18+
vendored = ["dep:cc"]
19+
20+
# Use existing METIS install and links dynamically to it.
21+
use-system = ["bindgen"]
22+
23+
# Regenerate bindings in metis-sys/gen/bindings.rs from METIS in the "vendor"
24+
# directory. Also enables "vendored".
25+
generate-bindings = ["vendored", "bindgen"]
26+
1427
[build-dependencies]
15-
bindgen = { version = "0.66", default-features = false, features = ["runtime"] }
28+
bindgen = { version = "0.69", default-features = false, features = ["runtime"], optional = true }
29+
cc = { version = "1", features = ["parallel"], optional = true }

0 commit comments

Comments
 (0)