Skip to content

Commit 14c9aaa

Browse files
authored
feat(cli): Add hwlib feature flags (#421)
* chore: fix .code-workspace file the extensions and settings should be outside the folders section * feat: add cli feature flag * feat: add pybindings feature flag * chore: bump hwlib version * ci: add --all-features flag * ci: add pybindings feature to maturin * docs: you can run maturin from the client directory now that the rust library is not in a workspace, you can run maturin from the client directory
1 parent 14efebf commit 14c9aaa

File tree

8 files changed

+36
-43
lines changed

8 files changed

+36
-43
lines changed

.github/workflows/test_client.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ jobs:
3838
with:
3939
toolchain: stable
4040
components: rustfmt, clippy
41-
- run: cargo build
42-
- run: cargo check
41+
- run: cargo build --all-features
42+
- run: cargo check --all-features
4343
- run: cargo fmt --all -- --check
4444
- run: cargo clippy --all-features --verbose
45-
- run: cargo clippy --tests --verbose
45+
- run: cargo clippy --all-features --tests --verbose
4646
- name: Run cargo test
47-
run: cargo test
47+
run: cargo test --all-features
4848

4949
py-bindings-test:
5050
name: Test Python bindings

client/CONTRIBUTING.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,7 @@ environment to be configured to work with it:
4242
virtualenv venv
4343
source venv/bin/activate
4444
pip install maturin
45-
```
46-
47-
Then run the following commands:
48-
49-
```shell
50-
cd hwlib
51-
maturin develop
45+
maturin develop --features pybindings
5246
```
5347

5448
Now you can use the library in your Python code. The library requires root
@@ -71,7 +65,6 @@ and Python code. To execute them, run the following commands:
7165
- Run Python tests: You need to have [`tox`][tox] (`pip install tox`). Then you
7266
can run Python tests with `$ tox`
7367

74-
7568
[snap]: https://snapcraft.io/hwctl
7669
[snapcraft]: https://github.com/canonical/snapcraft
7770
[pyo3]: https://github.com/PyO3/pyo3

client/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/Cargo.toml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "hwlib"
33
description = "Tool for checking Ubuntu hardware certification status"
4-
version = "0.10.0"
4+
version = "0.10.1"
55
edition = "2021"
66
authors = [
77
"Canonical Hardware Certification <[email protected]>",
@@ -20,17 +20,22 @@ crate-type = ["cdylib", "rlib"]
2020
[[bin]]
2121
name = "hwctl"
2222
path = "bin/hwctl.rs"
23+
features = ["cli"]
2324

2425
[dependencies]
2526
anyhow = "~1.0.0"
26-
clap = { version = "4.5.41", features = ["derive", "env"] }
27+
clap = { version = "4.5.41", features = ["derive", "env"], optional = true }
2728
minreq = { version = "2.14.0", features = ["native-tls", "json-using-serde"], default-features = false }
2829
os-release = { version = "0.1.0" }
29-
pyo3 = { version = "0.26.0", features = ["extension-module"] }
30+
pyo3 = { version = "0.26.0", features = ["extension-module"], optional = true }
3031
serde = { version = "~1.0.0", features = ["derive"] }
3132
serde_json = "~1.0.0"
3233
smbios-lib = "0.9.0"
3334

3435
[dev-dependencies]
3536
pretty_assertions = "1.4.1"
3637
simple_test_case = "1.2.0"
38+
39+
[features]
40+
cli = ["clap"]
41+
pybindings = ["pyo3"]

client/snapcraft.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ apps:
4040
parts:
4141
hwctl:
4242
plugin: rust
43+
rust-features: ["cli"]
4344
source: .
4445
build-packages:
4546
- jq

client/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub mod collectors;
2525
mod constants;
2626
mod helpers;
2727
pub mod models;
28+
#[cfg(feature = "pybindings")]
2829
pub mod py_bindings;
2930

3031
use anyhow::Result;

client/tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ deps =
1010
pytest
1111
maturin
1212
commands_pre =
13-
{envbindir}/maturin develop
13+
{envbindir}/maturin develop --features pybindings
1414
commands =
1515
{envbindir}/python -m black --check pytests/
1616
{envbindir}/python -m ruff check pytests/

hardware-api.code-workspace

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,21 @@
11
{
2-
"folders": [
3-
{
4-
"name": "Server",
5-
"path": "server",
6-
"extensions": {
7-
"recommendations": [
8-
"ms-python.python"
9-
]
10-
},
11-
"settings": {
12-
"python.pythonPath": "server/.venv/bin/python"
13-
}
14-
},
15-
{
16-
"name": "hwlib",
17-
"path": "client",
18-
"extensions": {
19-
"recommendations": [
20-
"matklad.rust-analyzer"
21-
]
22-
},
23-
"settings": {
24-
"rust-analyzer.linkedProjects": ["client/Cargo.toml"]
25-
}
26-
}
2+
"folders": [
3+
{
4+
"name": "Server",
5+
"path": "server",
6+
},
7+
{
8+
"name": "Client",
9+
"path": "client",
10+
}
11+
],
12+
"extensions": {
13+
"recommendations": [
14+
"ms-python.python",
15+
"rust-lang.rust-analyzer"
2716
]
28-
}
17+
},
18+
"settings": {
19+
"rust-analyzer.cargo.features": "all",
20+
},
21+
}

0 commit comments

Comments
 (0)