Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
baseplate-admin committed May 14, 2024
1 parent 0be235c commit 53ffa4b
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "resvg_py"
version = "0.1.5"
edition = "2021"

authors = ['baseplate-admin']
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
name = "resvg_py"
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import resvg_py

project = "resvg_py"
author = "baseplate-admin"
author = resvg_py.__author__
copyright = f"2024-{datetime.date.today().year}, {author}"
release = resvg_py.__version__

Expand Down
3 changes: 3 additions & 0 deletions docs/resvg.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@
.. autoclass:: __version__
.. autoclass:: __author__
```
4 changes: 2 additions & 2 deletions resvg_py.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Literal


__version__ : str
__version__: str
__author__: str

def svg_to_bytes(
svg_string: str | None = None,
Expand Down
10 changes: 10 additions & 0 deletions src/rust/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,10 +358,20 @@ fn get_version() -> &'static str {
})
}

fn get_author() -> &'static str {
static AUTHOR : std::sync::OnceLock<String> = std::sync::OnceLock::new();

AUTHOR.get_or_init(||{

env!("CARGO_PKG_AUTHORS").to_owned()
})
}

/// A Python module implemented in Rust.
#[pymodule]
fn resvg_py(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add("__version__",get_version())?;
m.add("__author__", get_author())?;
m.add_function(wrap_pyfunction!(svg_to_bytes, m)?)?;
Ok(())
}
3 changes: 3 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from resvg_py import __author__

print(__author__)

0 comments on commit 53ffa4b

Please sign in to comment.