mirror of
https://github.com/microsoft/regorus.git
synced 2026-08-05 02:16:11 +00:00
Publish python packages (#117)
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
committed by
GitHub
parent
bf75813c43
commit
ca91c0ea20
@@ -1,7 +1,7 @@
|
|||||||
# This file is autogenerated by maturin v1.4.0
|
# This file is autogenerated by maturin v1.4.0
|
||||||
# To update, run
|
# To update, run
|
||||||
#
|
#
|
||||||
# maturin generate-ci github --zig
|
# maturin generate-ci --manifest-path bindings/python/Cargo.toml github
|
||||||
#
|
#
|
||||||
name: publish-python
|
name: publish-python
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ jobs:
|
|||||||
uses: PyO3/maturin-action@v1
|
uses: PyO3/maturin-action@v1
|
||||||
with:
|
with:
|
||||||
target: ${{ matrix.target }}
|
target: ${{ matrix.target }}
|
||||||
args: --release --out dist --find-interpreter --zig
|
args: --release --out dist --find-interpreter --manifest-path bindings/python/Cargo.toml
|
||||||
sccache: 'true'
|
sccache: 'true'
|
||||||
manylinux: auto
|
manylinux: auto
|
||||||
- name: Upload wheels
|
- name: Upload wheels
|
||||||
@@ -50,7 +50,7 @@ jobs:
|
|||||||
uses: PyO3/maturin-action@v1
|
uses: PyO3/maturin-action@v1
|
||||||
with:
|
with:
|
||||||
target: ${{ matrix.target }}
|
target: ${{ matrix.target }}
|
||||||
args: --release --out dist --find-interpreter
|
args: --release --out dist --find-interpreter --manifest-path bindings/python/Cargo.toml
|
||||||
sccache: 'true'
|
sccache: 'true'
|
||||||
- name: Upload wheels
|
- name: Upload wheels
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
@@ -62,7 +62,7 @@ jobs:
|
|||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
target: [x86_64, aarch64]
|
target: [x86_64, aarch64, universal2-apple-darwin]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-python@v4
|
- uses: actions/setup-python@v4
|
||||||
@@ -72,7 +72,7 @@ jobs:
|
|||||||
uses: PyO3/maturin-action@v1
|
uses: PyO3/maturin-action@v1
|
||||||
with:
|
with:
|
||||||
target: ${{ matrix.target }}
|
target: ${{ matrix.target }}
|
||||||
args: --release --out dist --find-interpreter
|
args: --release --out dist --find-interpreter --manifest-path bindings/python/Cargo.toml
|
||||||
sccache: 'true'
|
sccache: 'true'
|
||||||
- name: Upload wheels
|
- name: Upload wheels
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
@@ -88,7 +88,7 @@ jobs:
|
|||||||
uses: PyO3/maturin-action@v1
|
uses: PyO3/maturin-action@v1
|
||||||
with:
|
with:
|
||||||
command: sdist
|
command: sdist
|
||||||
args: --out dist
|
args: --out dist --manifest-path bindings/python/Cargo.toml
|
||||||
- name: Upload sdist
|
- name: Upload sdist
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -7,12 +7,12 @@ use pyo3::types::*;
|
|||||||
|
|
||||||
use std::collections::{BTreeMap, BTreeSet};
|
use std::collections::{BTreeMap, BTreeSet};
|
||||||
|
|
||||||
use regorus::Value;
|
use ::regorus::Value;
|
||||||
|
|
||||||
/// Python wrapper for [`regorus::Engine`]
|
/// Regorus engine.
|
||||||
#[pyclass(unsendable)]
|
#[pyclass(unsendable)]
|
||||||
pub struct Engine {
|
pub struct Engine {
|
||||||
engine: regorus::Engine,
|
engine: ::regorus::Engine,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Engine {
|
impl Default for Engine {
|
||||||
@@ -171,7 +171,7 @@ impl Engine {
|
|||||||
#[new]
|
#[new]
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
engine: regorus::Engine::new(),
|
engine: ::regorus::Engine::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,7 +199,7 @@ impl Engine {
|
|||||||
///
|
///
|
||||||
/// * `data`: JSON encoded value to be used as policy data.
|
/// * `data`: JSON encoded value to be used as policy data.
|
||||||
pub fn add_data_json(&mut self, data: String) -> Result<()> {
|
pub fn add_data_json(&mut self, data: String) -> Result<()> {
|
||||||
let data = regorus::Value::from_json_str(&data)?;
|
let data = Value::from_json_str(&data)?;
|
||||||
self.engine.add_data(data)
|
self.engine.add_data(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,7 +223,7 @@ impl Engine {
|
|||||||
///
|
///
|
||||||
/// * `input`: JSON encoded value to be used as input to query.
|
/// * `input`: JSON encoded value to be used as input to query.
|
||||||
pub fn set_input_json(&mut self, input: String) -> Result<()> {
|
pub fn set_input_json(&mut self, input: String) -> Result<()> {
|
||||||
let input = regorus::Value::from_json_str(&input)?;
|
let input = Value::from_json_str(&input)?;
|
||||||
self.engine.set_input(input);
|
self.engine.set_input(input);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -270,10 +270,7 @@ impl Engine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mod export {
|
#[pymodule]
|
||||||
use pyo3::prelude::*;
|
pub fn regorus(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
|
||||||
#[pymodule]
|
m.add_class::<crate::Engine>()
|
||||||
fn regorus(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
|
|
||||||
m.add_class::<crate::Engine>()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user