diff --git a/.cargo/config b/.cargo/config new file mode 100644 index 0000000..84f3e53 --- /dev/null +++ b/.cargo/config @@ -0,0 +1,5 @@ +[target.x86_64-apple-darwin] +rustc-cdylib-link-arg = [ + "-undefined", + "dynamic_lookup", +] \ No newline at end of file diff --git a/.gitignore b/.gitignore index cbed4d7..daac202 100644 --- a/.gitignore +++ b/.gitignore @@ -8,5 +8,6 @@ Cargo.lock # These are backup files generated by rustfmt **/*.rs.bk +**/__pycache__ .idea/ diff --git a/.travis.yml b/.travis.yml index 049c002..6739aa5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,26 +13,18 @@ matrix: script: - make test - - name: Run CPython wrapper linter - language: rust - rust: stable - install: - [] - before_script: - - cargo install cargo-deny - - rustup component add rustfmt - script: - - make -C python lint - - name: Run CPython wrapper tests language: rust rust: nightly install: [] before_script: + - cargo install cargo-deny + - rustup component add rustfmt + - rustup component add clippy - sudo apt update && sudo apt install python3 python3-pip python3-dev python3-venv - pip3 install --upgrade pip - pip3 install maturin - python3 -m venv venv script: - - source venv/bin/activate && make -C python test + - source venv/bin/activate && make test_py diff --git a/Cargo.toml b/Cargo.toml index 24a0660..0443a5f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,8 +7,12 @@ version = "1.2.0" edition = "2018" authors = ["Christopher Berner "] +[lib] +crate-type = ["cdylib", "rlib"] + [dependencies] serde = {version = "1.0.102", features=["std", "derive"]} +pyo3 = {version = "0.8.4", features=["extension-module"], optional = true } [dev-dependencies] criterion = "0.3" @@ -37,3 +41,4 @@ debug = true [features] benchmarking = [] +python = ["pyo3"] diff --git a/Makefile b/Makefile index 7a106fe..547a1c0 100644 --- a/Makefile +++ b/Makefile @@ -20,3 +20,18 @@ bench: pre profile: RUSTFLAGS='-Cforce-frame-pointers' cargo bench --no-run --features benchmarking + +build_py: pre + maturin build --cargo-extra-args="--features python" + +release_py: pre + maturin build --release --cargo-extra-args="--features python" + +publish_py: test_py + maturin publish --cargo-extra-args="--features python" + +install_py: pre + maturin develop --cargo-extra-args="--features python" + +test_py: install_py + python3 -m unittest discover diff --git a/README.md b/README.md index b8268b8..d0456db 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,28 @@ Note that the additional classes exported by the `benchmarking` feature flag are crate's public API. Breaking changes to those classes may occur without warning. The flag is only provided so that internal classes can be used in this crate's benchmarks. +## Python bindings + +The Python bindings are generated using [pyo3](https://github.com/PyO3/pyo3). +Rust 1.37.0-nightly or higher is required for building [pyo3](https://github.com/PyO3/pyo3) projects. +``` +$ rustup install nightly +$ rustup override set nightly +``` + +Some operating systems require additional packages to be installed. +``` +$ sudo apt install python3-dev +``` + +[maturin](https://github.com/PyO3/maturin) is recommended for building the Python bindings in this crate. +``` +$ pip install maturin +$ maturin build +``` + +Alternatively, refer to the [Building and Distribution section](https://pyo3.rs/v0.8.5/building_and_distribution.html) in the [pyo3 user guide](https://pyo3.rs/v0.8.5/). + ## License Licensed under diff --git a/python/pyproject.toml b/pyproject.toml similarity index 100% rename from python/pyproject.toml rename to pyproject.toml diff --git a/python/.cargo/config b/python/.cargo/config deleted file mode 100644 index 58103f6..0000000 --- a/python/.cargo/config +++ /dev/null @@ -1,5 +0,0 @@ -[target.x86_64-apple-darwin] -rustflags = [ - "-C", "link-arg=-undefined", - "-C", "link-arg=dynamic_lookup", -] \ No newline at end of file diff --git a/python/.gitignore b/python/.gitignore deleted file mode 100644 index a6f89c2..0000000 --- a/python/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/target/ \ No newline at end of file diff --git a/python/Cargo.lock b/python/Cargo.lock deleted file mode 100644 index 70f2e2d..0000000 --- a/python/Cargo.lock +++ /dev/null @@ -1,326 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "aho-corasick" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "autocfg" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "ctor" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "ghost" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "indoc" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "indoc-impl 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "indoc-impl" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", - "unindent 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "inventory" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "ctor 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "ghost 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "inventory-impl 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "inventory-impl" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "itoa" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "libc" -version = "0.2.66" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "memchr" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "num-traits" -version = "0.2.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "paste" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "paste-impl 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "paste-impl" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "proc-macro-hack" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "proc-macro2" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "pyo3" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "indoc 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "inventory 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", - "paste 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "pyo3cls 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", - "spin 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "unindent 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "version_check 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "pyo3-derive-backend" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "pyo3cls" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "pyo3-derive-backend 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "quote" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "raptorq" -version = "1.2.0" -dependencies = [ - "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "raptorq-py" -version = "0.1.0" -dependencies = [ - "pyo3 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", - "raptorq 1.2.0", -] - -[[package]] -name = "regex" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "regex-syntax" -version = "0.6.12" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "ryu" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "serde" -version = "1.0.104" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "serde_derive" -version = "1.0.104" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "serde_json" -version = "1.0.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "spin" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "syn" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "thread_local" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "unicode-xid" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "unindent" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "version_check" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[metadata] -"checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" -"checksum autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" -"checksum ctor 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "cd8ce37ad4184ab2ce004c33bf6379185d3b1c95801cab51026bd271bf68eedc" -"checksum ghost 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2a36606a68532b5640dc86bb1f33c64b45c4682aad4c50f3937b317ea387f3d6" -"checksum indoc 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3f9553c1e16c114b8b77ebeb329e5f2876eed62a8d51178c8bc6bff0d65f98f8" -"checksum indoc-impl 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b714fc08d0961716390977cdff1536234415ac37b509e34e5a983def8340fb75" -"checksum inventory 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f4cece20baea71d9f3435e7bbe9adf4765f091c5fe404975f844006964a71299" -"checksum inventory-impl 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2869bf972e998977b1cb87e60df70341d48e48dca0823f534feb91ea44adaf9" -"checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" -"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -"checksum libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)" = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558" -"checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" -"checksum num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c81ffc11c212fa327657cb19dd85eb7419e163b5b076bede2bdb5c974c07e4" -"checksum paste 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "423a519e1c6e828f1e73b720f9d9ed2fa643dce8a7737fb43235ce0b41eeaa49" -"checksum paste-impl 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "4214c9e912ef61bf42b81ba9a47e8aad1b2ffaf739ab162bf96d1e011f54e6c5" -"checksum proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)" = "ecd45702f76d6d3c75a80564378ae228a85f0b59d2f3ed43c91b4a69eb2ebfc5" -"checksum proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9c9e470a8dc4aeae2dee2f335e8f533e2d4b347e1434e5671afc49b054592f27" -"checksum pyo3 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)" = "7f9df1468dddf8a59ec799cf3b930bb75ec09deabe875ba953e06c51d1077136" -"checksum pyo3-derive-backend 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)" = "9f6e56fb3e97b344a8f87d036f94578399402c6b75949de6270cd07928f790b1" -"checksum pyo3cls 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)" = "97452dcdf5941627ebc5c06664a07821fc7fc88d7515f02178193a8ebe316468" -"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" -"checksum regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dc220bd33bdce8f093101afe22a037b8eb0e5af33592e6a9caafff0d4cb81cbd" -"checksum regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "11a7e20d1cce64ef2fed88b66d347f88bd9babb82845b2b858f3edbf59a4f716" -"checksum ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bfa8506c1de11c9c4e4c38863ccbe02a305c8188e85a05a784c9e11e1c3910c8" -"checksum serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449" -"checksum serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64" -"checksum serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)" = "48c575e0cc52bdd09b47f330f646cf59afc586e9c4e3ccd6fc1f625b8ea1dad7" -"checksum spin 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" -"checksum syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "dff0acdb207ae2fe6d5976617f887eb1e35a2ba52c13c7234c790960cdad9238" -"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" -"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" -"checksum unindent 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "63f18aa3b0e35fed5a0048f029558b1518095ffe2a0a31fb87c93dece93a4993" -"checksum version_check 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce" diff --git a/python/Cargo.toml b/python/Cargo.toml deleted file mode 100644 index e8ed851..0000000 --- a/python/Cargo.toml +++ /dev/null @@ -1,20 +0,0 @@ -[package] -name = "raptorq-py" -description = "RaptorQ (RFC6330)" -license = "Apache-2.0" -repository = "https://github.com/cberner/raptorq" -version = "0.1.0" -authors = ["Felix Schorer "] -edition = "2018" - -[lib] -name = "raptorq" -crate-type = ["cdylib"] - -[dependencies.raptorq] -path = "../" -version = "1.0.0" - -[dependencies.pyo3] -version = "0.8.4" -features = ["extension-module"] \ No newline at end of file diff --git a/python/Makefile b/python/Makefile deleted file mode 100644 index 998a61a..0000000 --- a/python/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -build: - maturin build - -release: - maturin build --release - -install: - maturin develop - -lint: - cargo deny check licenses - cargo fmt --all -- --check - -test: install - python3 -m unittest discover \ No newline at end of file diff --git a/python/README.md b/python/README.md deleted file mode 100644 index 3ce3917..0000000 --- a/python/README.md +++ /dev/null @@ -1,19 +0,0 @@ -The Python bindings are generated using [pyo3](https://github.com/PyO3/pyo3). -Rust 1.37.0-nightly or higher is required for building [pyo3](https://github.com/PyO3/pyo3) projects. -``` -$ rustup install nightly -$ rustup override set nightly -``` - -Some operating systems require additional packages to be installed. -``` -$ sudo apt install python3-dev -``` - -[maturin](https://github.com/PyO3/maturin) is recommended for building this crate. -``` -$ pip install maturin -$ maturin build -``` - -Alternatively, refer to the [Building and Distribution section](https://pyo3.rs/v0.8.5/building_and_distribution.html) in the [pyo3 user guide](https://pyo3.rs/v0.8.5/). \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 2610650..3592086 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,6 +13,8 @@ mod octet_matrix; mod octets; mod operation_vector; mod pi_solver; +#[cfg(feature = "python")] +mod python; mod rng; mod sparse_matrix; mod sparse_vec; @@ -23,11 +25,19 @@ mod util; pub use crate::base::EncodingPacket; pub use crate::base::ObjectTransmissionInformation; pub use crate::base::PayloadId; +#[cfg(not(feature = "python"))] pub use crate::decoder::Decoder; pub use crate::decoder::SourceBlockDecoder; +#[cfg(not(feature = "python"))] pub use crate::encoder::Encoder; pub use crate::encoder::SourceBlockEncoder; pub use crate::encoder::SourceBlockEncodingPlan; +#[cfg(feature = "python")] +pub use crate::python::raptorq; +#[cfg(feature = "python")] +pub use crate::python::Decoder; +#[cfg(feature = "python")] +pub use crate::python::Encoder; #[cfg(feature = "benchmarking")] pub use crate::constraint_matrix::generate_constraint_matrix; diff --git a/python/src/lib.rs b/src/python.rs similarity index 86% rename from python/src/lib.rs rename to src/python.rs index 2421746..3c17464 100644 --- a/python/src/lib.rs +++ b/src/python.rs @@ -1,12 +1,11 @@ +use crate::base::{EncodingPacket, ObjectTransmissionInformation}; +use crate::decoder::Decoder as DecoderNative; +use crate::encoder::Encoder as EncoderNative; use pyo3::prelude::*; use pyo3::types::*; -use raptorq::{ - Decoder as DecoderNative, Encoder as EncoderNative, EncodingPacket, - ObjectTransmissionInformation, -}; #[pyclass] -struct Encoder { +pub struct Encoder { encoder: EncoderNative, } @@ -35,7 +34,7 @@ impl Encoder { } #[pyclass] -struct Decoder { +pub struct Decoder { decoder: DecoderNative, } @@ -67,7 +66,7 @@ impl Decoder { } #[pymodule] -fn raptorq(_py: Python, m: &PyModule) -> PyResult<()> { +pub fn raptorq(_py: Python, m: &PyModule) -> PyResult<()> { m.add_class::()?; m.add_class::()?; Ok(()) diff --git a/python/test/__init__.py b/test/__init__.py similarity index 100% rename from python/test/__init__.py rename to test/__init__.py