Skip to content

Commit

Permalink
FIX: Create separate conda and pip maturin builds
Browse files Browse the repository at this point in the history
  • Loading branch information
anuradhawick committed Aug 28, 2024
1 parent a235619 commit 6e0ce8f
Show file tree
Hide file tree
Showing 18 changed files with 266 additions and 25 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
24 changes: 22 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
File renamed without changes.
20 changes: 20 additions & 0 deletions conda/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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" }
23 changes: 23 additions & 0 deletions conda/pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"]
23 changes: 23 additions & 0 deletions conda/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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::<OligoComputer>()?;
m.add_class::<CgrComputer>()?;
m.add_class::<KmerGenerator>()?;
m.add_class::<MinimiserGenerator>()?;
Ok(())
}
72 changes: 72 additions & 0 deletions pip/.gitignore
Original file line number Diff line number Diff line change
@@ -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
8 changes: 2 additions & 6 deletions pykmertools/Cargo.toml → pip/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "pykmertools"
name = "pip"
version.workspace = true
edition.workspace = true
authors.workspace = true
Expand All @@ -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 = []
File renamed without changes.
15 changes: 3 additions & 12 deletions pykmertools/src/lib.rs → pip/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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<()> {
Expand All @@ -38,7 +30,6 @@ fn pykmertools(m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_class::<CgrComputer>()?;
m.add_class::<KmerGenerator>()?;
m.add_class::<MinimiserGenerator>()?;
#[cfg(feature = "cli")]
m.add_function(wrap_pyfunction!(run_cli, m)?)?;
Ok(())
}
72 changes: 72 additions & 0 deletions pybindings/.gitignore
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions pybindings/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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" }
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions pybindings/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pub mod cgr;
pub mod kmer;
pub mod min;
pub mod oligo;
File renamed without changes.
File renamed without changes.

0 comments on commit 6e0ce8f

Please sign in to comment.