diff --git a/Cargo.lock b/Cargo.lock index 34dcd648..14b57af2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1654,6 +1654,12 @@ dependencies = [ "regex", ] +[[package]] +name = "indoc" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adab1eaa3408fb7f0c777a73e7465fd5656136fc93b670eb6df3c88c2c1344e3" + [[package]] name = "infer" version = "0.2.3" @@ -2436,6 +2442,65 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "pyo3" +version = "0.16.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0220c44442c9b239dd4357aa856ac468a4f5e1f0df19ddb89b2522952eb4c6ca" +dependencies = [ + "cfg-if 1.0.0", + "indoc", + "libc", + "parking_lot", + "pyo3-build-config", + "pyo3-ffi", + "pyo3-macros", + "unindent", +] + +[[package]] +name = "pyo3-build-config" +version = "0.16.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c819d397859445928609d0ec5afc2da5204e0d0f73d6bf9e153b04e83c9cdc2" +dependencies = [ + "once_cell", + "target-lexicon", +] + +[[package]] +name = "pyo3-ffi" +version = "0.16.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca882703ab55f54702d7bfe1189b41b0af10272389f04cae38fe4cd56c65f75f" +dependencies = [ + "libc", + "pyo3-build-config", +] + +[[package]] +name = "pyo3-macros" +version = "0.16.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "568749402955ad7be7bad9a09b8593851cd36e549ac90bfd44079cea500f3f21" +dependencies = [ + "proc-macro2", + "pyo3-macros-backend", + "quote", + "syn", +] + +[[package]] +name = "pyo3-macros-backend" +version = "0.16.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "611f64e82d98f447787e82b8e7b0ebc681e1eb78fc1252668b2c605ffb4e1eb8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "querystring" version = "1.1.0" @@ -3328,6 +3393,7 @@ dependencies = [ "openssl", "paste", "posthog-rs", + "pyo3", "querystring", "rand 0.8.4", "regex", @@ -3431,6 +3497,12 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" +[[package]] +name = "target-lexicon" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c02424087780c9b71cc96799eaeddff35af2bc513278cda5c99fc1f5d026d3c1" + [[package]] name = "tempfile" version = "3.2.0" @@ -3808,6 +3880,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" +[[package]] +name = "unindent" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58ee9362deb4a96cef4d437d1ad49cffc9b9e92d202b6995674e928ce684f112" + [[package]] name = "universal-hash" version = "0.4.1" diff --git a/synth/Cargo.toml b/synth/Cargo.toml index 8ec34230..93895d4e 100644 --- a/synth/Cargo.toml +++ b/synth/Cargo.toml @@ -15,9 +15,14 @@ exclude = ["testing_harness/*", "tmp"] name = "bench" harness = false +[lib] +name = "synth" +crate-type = ["cdylib", "rlib"] + [features] default = [] telemetry = ["posthog-rs", "uuid", "backtrace", "console"] +python = ["pyo3"] [build-dependencies] git2 = "0.13.20" @@ -90,3 +95,6 @@ uriparse = "0.6.3" querystring = "1.1.0" csv = "1.1.6" + +# Python Dependencies +pyo3 = { version = "0.16.5", features = ["extension-module", "abi3-py37"], optional = true } diff --git a/synth/pyproject.toml b/synth/pyproject.toml new file mode 100644 index 00000000..22edc3ca --- /dev/null +++ b/synth/pyproject.toml @@ -0,0 +1,16 @@ +[build-system] +requires = ["maturin>=0.13,<0.14"] +build-backend = "maturin" + +[project] +name = "getsynthpy" +requires-python = ">=3.7" +classifiers = [ + "Programming Language :: Rust", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", +] + +[tool.maturin] +features = ["python"] + diff --git a/synth/src/lib.rs b/synth/src/lib.rs index 70b00967..bd45bd26 100644 --- a/synth/src/lib.rs +++ b/synth/src/lib.rs @@ -16,3 +16,21 @@ pub mod datasource; pub mod sampler; pub mod utils; pub mod version; + +// Python Code +#[cfg(feature = "python")] +use pyo3::prelude::*; + +#[cfg(feature = "python")] +#[pymodule] +fn synth(_py: Python, m: &PyModule) -> PyResult<()> { + m.add_function(wrap_pyfunction!(generate, m)?)?; + + Ok(()) +} + +#[cfg(feature = "py")] +#[pyfunction] +pub fn generate() { + todo!(); +}