Skip to content

Commit 2cbdbc6

Browse files
committed
Remove Python binding from library
- Remove python binding from library in favor of the standalone python package: https://github.com/aboutcode-org/purl-validator/ Signed-off-by: Keshav Priyadarshi <[email protected]>
1 parent 23b0f71 commit 2cbdbc6

File tree

5 files changed

+17
-213
lines changed

5 files changed

+17
-213
lines changed

Cargo.lock

Lines changed: 0 additions & 157 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,9 @@ edition = "2024"
55
authors = ["Keshav Priyadarshi <[email protected]>", "AboutCode <[email protected]>"]
66
description = "PackageURL validator using prebuilt FST"
77
license = "Apache-2.0"
8-
repository = "https://github.com/aboutcode-org/purl-validator"
8+
repository = "https://github.com/aboutcode-org/purl-validator-rust"
99

10-
[lib]
11-
name = "purl_validator"
12-
crate-type = ["cdylib", "rlib"]
13-
14-
[dependencies]
15-
fst = "0.4.7"
16-
once_cell = "1.21"
17-
pyo3 = { version = "0.27.1", features = ["extension-module"] }
18-
19-
[[bin]]
20-
name = "fst_builder"
21-
path = "fst_builder/main.rs"
10+
exclude = ["fst_builder/*"]
2211

2312
include = [
2413
"src/**",
@@ -28,8 +17,14 @@ include = [
2817
"LICENSE"
2918
]
3019

31-
[package.metadata.maturin]
20+
[lib]
3221
name = "purl_validator"
22+
crate-type = ["rlib"]
3323

34-
[tool.maturin]
35-
include = ["purls.fst"]
24+
[dependencies]
25+
fst = "0.4.7"
26+
once_cell = "1.21"
27+
28+
[[bin]]
29+
name = "fst_builder"
30+
path = "fst_builder/main.rs"

Makefile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
build-fst:
22
cargo run --bin fst_builder
33

4-
build-python:
5-
maturin build --release
64

75
clean:
86
cargo clean
97
rm -f purls.fst
108
rm -rf target
119

12-
.PHONY: build-fst build-python clean
10+
.PHONY: build-fst clean

pyproject.toml

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/lib.rs

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,12 @@
11
use fst::Set;
22
use once_cell::sync::Lazy;
33

4-
54
static FST_BYTES: &[u8] = include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/purls.fst"));
65

7-
static VALIDATOR: Lazy<Set<&[u8]>> = Lazy::new(|| {
8-
Set::new(FST_BYTES).expect("Failed to load FST from embedded bytes")
9-
});
10-
11-
12-
pub fn validate(word: &str) -> bool {
13-
VALIDATOR.contains(word)
14-
}
15-
16-
17-
#[pyo3::pymodule]
18-
mod purl_validator {
19-
use pyo3::prelude::*;
20-
use crate::validate;
6+
static VALIDATOR: Lazy<Set<&[u8]>> =
7+
Lazy::new(|| Set::new(FST_BYTES).expect("Failed to load FST from embedded bytes"));
218

22-
#[pyfunction(name = "validate")]
23-
fn py_validate(word: &str) -> PyResult<bool> {
24-
Ok(validate(word))
25-
}
9+
pub fn validate(packageurl: &str) -> bool {
10+
let trimmed_packageurl = packageurl.trim_end_matches("/");
11+
VALIDATOR.contains(trimmed_packageurl)
2612
}

0 commit comments

Comments
 (0)