diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index 83be97b..9543174 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -26,7 +26,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.platform.target }} - args: --release --out dist --find-interpreter --manifest-path ./pykmertools/Cargo.toml --features cli + args: --release --out dist --find-interpreter --manifest-path ./pip/Cargo.toml sccache: 'true' manylinux: auto - name: Upload wheels @@ -53,7 +53,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.platform.target }} - args: --release --out dist --find-interpreter --manifest-path ./pykmertools/Cargo.toml --features cli + args: --release --out dist --find-interpreter --manifest-path ./pip/Cargo.toml sccache: 'true' manylinux: musllinux_1_2 - name: Upload wheels @@ -79,7 +79,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.platform.target }} - args: --release --out dist --find-interpreter --manifest-path ./pykmertools/Cargo.toml --features cli + args: --release --out dist --find-interpreter --manifest-path ./pip/Cargo.toml sccache: 'true' - name: Upload wheels uses: actions/upload-artifact@v4 @@ -105,7 +105,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.platform.target }} - args: --release --out dist --find-interpreter --manifest-path ./pykmertools/Cargo.toml --features cli + args: --release --out dist --find-interpreter --manifest-path ./pip/Cargo.toml sccache: 'true' - name: Upload wheels uses: actions/upload-artifact@v4 diff --git a/Cargo.lock b/Cargo.lock index 2b0cf3a..869558e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -243,6 +243,16 @@ dependencies = [ "rayon", ] +[[package]] +name = "conda" +version = "0.1.3" +dependencies = [ + "clap", + "pybindings", + "pyo3", + "rayon", +] + [[package]] name = "console" version = "0.15.8" @@ -752,6 +762,17 @@ dependencies = [ "indexmap", ] +[[package]] +name = "pip" +version = "0.1.3" +dependencies = [ + "clap", + "kmertools", + "pybindings", + "pyo3", + "rayon", +] + [[package]] name = "portable-atomic" version = "1.6.0" @@ -774,13 +795,12 @@ dependencies = [ ] [[package]] -name = "pykmertools" +name = "pybindings" version = "0.1.3" dependencies = [ "clap", "composition", "kmer", - "kmertools", "pyo3", "rayon", ] diff --git a/Cargo.toml b/Cargo.toml index 69912e1..eae40fe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,5 +6,5 @@ package.description = "kmertools is a k-mer based feature extraction tool design package.readme = "README.md" package.license-file = "LICENSE" -members = ["composition", "coverage", "kmertools", "kmer", "ktio", "counter", "misc", "pykmertools"] +members = ["composition", "coverage", "kmertools", "kmer", "ktio", "counter", "misc", "pybindings", "pip", "conda"] resolver = "2" diff --git a/pykmertools/.gitignore b/conda/.gitignore similarity index 100% rename from pykmertools/.gitignore rename to conda/.gitignore diff --git a/conda/Cargo.toml b/conda/Cargo.toml new file mode 100644 index 0000000..36fb894 --- /dev/null +++ b/conda/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "conda" +version.workspace = true +edition.workspace = true +authors.workspace = true +description.workspace = true +readme.workspace = true +license-file.workspace = true + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[lib] +name = "pykmertools" +crate-type = ["cdylib"] +test = false + +[dependencies] +pyo3 = { version = "0.22.0", "features" = ["abi3-py39"] } +rayon = "1.10.0" +clap = { version = "4.5.4" } +pybindings = { path = "../pybindings" } diff --git a/conda/pyproject.toml b/conda/pyproject.toml new file mode 100644 index 0000000..7e98503 --- /dev/null +++ b/conda/pyproject.toml @@ -0,0 +1,23 @@ +[build-system] +requires = ["maturin>=1.7,<2.0"] +build-backend = "maturin" + +[project] +name = "pykmertools" +requires-python = ">=3.9" +classifiers = [ + "Programming Language :: Rust", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", +] +dynamic = ["version", "description", "license", "readme"] +keywords = ["genomics", "bioinformatics"] + + +[project.urls] +Documentation = "https://github.com/anuradhawick/kmertools/wiki" +"Bug Tracker" = "https://github.com/anuradhawick/kmertools/issues" +"Source Code" = "https://github.com/anuradhawick/kmertools/" + +[tool.maturin] +features = ["pyo3/extension-module"] diff --git a/conda/src/lib.rs b/conda/src/lib.rs new file mode 100644 index 0000000..bc59d72 --- /dev/null +++ b/conda/src/lib.rs @@ -0,0 +1,23 @@ +use pybindings::{ + cgr::CgrComputer, kmer::KmerGenerator, min::MinimiserGenerator, oligo::OligoComputer, +}; +use pyo3::prelude::*; + +/// Pykmertools: kmertools python wrapper +/// Modules: +/// OligoComputer - computing oligonucleotide frequency vectors +/// from DNA sequences +/// CgrComputer - computing chaos game representations +/// for DNA sequences +/// KmerGenerator - an iterator object to generate k-mers +/// as (forward, reverse) numeric kmer tuples +/// MinimiserGenerator - an iterator object to iterate minimisers +/// as (kmer, start, end) numeric minimiser tuples +#[pymodule] +fn pykmertools(m: &Bound<'_, PyModule>) -> PyResult<()> { + m.add_class::()?; + m.add_class::()?; + m.add_class::()?; + m.add_class::()?; + Ok(()) +} diff --git a/pip/.gitignore b/pip/.gitignore new file mode 100644 index 0000000..c8f0442 --- /dev/null +++ b/pip/.gitignore @@ -0,0 +1,72 @@ +/target + +# Byte-compiled / optimized / DLL files +__pycache__/ +.pytest_cache/ +*.py[cod] + +# C extensions +*.so + +# Distribution / packaging +.Python +.venv/ +env/ +bin/ +build/ +develop-eggs/ +dist/ +eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +include/ +man/ +venv/ +*.egg-info/ +.installed.cfg +*.egg + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt +pip-selfcheck.json + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.cache +nosetests.xml +coverage.xml + +# Translations +*.mo + +# Mr Developer +.mr.developer.cfg +.project +.pydevproject + +# Rope +.ropeproject + +# Django stuff: +*.log +*.pot + +.DS_Store + +# Sphinx documentation +docs/_build/ + +# PyCharm +.idea/ + +# VSCode +.vscode/ + +# Pyenv +.python-version diff --git a/pykmertools/Cargo.toml b/pip/Cargo.toml similarity index 81% rename from pykmertools/Cargo.toml rename to pip/Cargo.toml index e5da265..64d3999 100644 --- a/pykmertools/Cargo.toml +++ b/pip/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "pykmertools" +name = "pip" version.workspace = true edition.workspace = true authors.workspace = true @@ -17,9 +17,5 @@ test = false pyo3 = { version = "0.22.0", "features" = ["abi3-py39"] } rayon = "1.10.0" clap = { version = "4.5.4" } -composition = { path = "../composition" } -kmer = { path = "../kmer" } +pybindings = { path = "../pybindings" } kmertools = { path = "../kmertools" } - -[features] -cli = [] diff --git a/pykmertools/pyproject.toml b/pip/pyproject.toml similarity index 100% rename from pykmertools/pyproject.toml rename to pip/pyproject.toml diff --git a/pykmertools/src/lib.rs b/pip/src/lib.rs similarity index 83% rename from pykmertools/src/lib.rs rename to pip/src/lib.rs index 9c84b5a..7212b1d 100644 --- a/pykmertools/src/lib.rs +++ b/pip/src/lib.rs @@ -1,18 +1,10 @@ -mod cgr; -mod kmer; -mod min; -mod oligo; -use cgr::CgrComputer; -#[cfg(feature = "cli")] use clap::Parser; -use kmer::KmerGenerator; -#[cfg(feature = "cli")] use kmertools::args::{cli, Cli}; -use min::MinimiserGenerator; -use oligo::OligoComputer; +use pybindings::{ + cgr::CgrComputer, kmer::KmerGenerator, min::MinimiserGenerator, oligo::OligoComputer, +}; use pyo3::prelude::*; -#[cfg(feature = "cli")] #[pyfunction] // TODO: remove after https://github.com/PyO3/maturin/issues/368 is resolved fn run_cli(_py: Python) -> PyResult<()> { @@ -38,7 +30,6 @@ fn pykmertools(m: &Bound<'_, PyModule>) -> PyResult<()> { m.add_class::()?; m.add_class::()?; m.add_class::()?; - #[cfg(feature = "cli")] m.add_function(wrap_pyfunction!(run_cli, m)?)?; Ok(()) } diff --git a/pybindings/.gitignore b/pybindings/.gitignore new file mode 100644 index 0000000..c8f0442 --- /dev/null +++ b/pybindings/.gitignore @@ -0,0 +1,72 @@ +/target + +# Byte-compiled / optimized / DLL files +__pycache__/ +.pytest_cache/ +*.py[cod] + +# C extensions +*.so + +# Distribution / packaging +.Python +.venv/ +env/ +bin/ +build/ +develop-eggs/ +dist/ +eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +include/ +man/ +venv/ +*.egg-info/ +.installed.cfg +*.egg + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt +pip-selfcheck.json + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.cache +nosetests.xml +coverage.xml + +# Translations +*.mo + +# Mr Developer +.mr.developer.cfg +.project +.pydevproject + +# Rope +.ropeproject + +# Django stuff: +*.log +*.pot + +.DS_Store + +# Sphinx documentation +docs/_build/ + +# PyCharm +.idea/ + +# VSCode +.vscode/ + +# Pyenv +.python-version diff --git a/pybindings/Cargo.toml b/pybindings/Cargo.toml new file mode 100644 index 0000000..9d59859 --- /dev/null +++ b/pybindings/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "pybindings" +version.workspace = true +edition.workspace = true +authors.workspace = true +description.workspace = true +readme.workspace = true +license-file.workspace = true + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[lib] +name = "pybindings" +test = false + +[dependencies] +pyo3 = { version = "0.22.0", "features" = ["abi3-py39"] } +rayon = "1.10.0" +clap = { version = "4.5.4" } +composition = { path = "../composition" } +kmer = { path = "../kmer" } diff --git a/pykmertools/src/cgr.rs b/pybindings/src/cgr.rs similarity index 100% rename from pykmertools/src/cgr.rs rename to pybindings/src/cgr.rs diff --git a/pykmertools/src/kmer.rs b/pybindings/src/kmer.rs similarity index 100% rename from pykmertools/src/kmer.rs rename to pybindings/src/kmer.rs diff --git a/pybindings/src/lib.rs b/pybindings/src/lib.rs new file mode 100644 index 0000000..b37c3f7 --- /dev/null +++ b/pybindings/src/lib.rs @@ -0,0 +1,4 @@ +pub mod cgr; +pub mod kmer; +pub mod min; +pub mod oligo; diff --git a/pykmertools/src/min.rs b/pybindings/src/min.rs similarity index 100% rename from pykmertools/src/min.rs rename to pybindings/src/min.rs diff --git a/pykmertools/src/oligo.rs b/pybindings/src/oligo.rs similarity index 100% rename from pykmertools/src/oligo.rs rename to pybindings/src/oligo.rs