Skip to content

Commit

Permalink
Use PyO3 abi3-py38 feature for ABI stable wheels
Browse files Browse the repository at this point in the history
Produces ABI stable wheels for Python >=3.8. This simplifies the
build/distribution by generating wheels that are forward compatible.
  • Loading branch information
manzt committed Dec 1, 2024
1 parent 6ea712f commit 97db077
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 23 deletions.
21 changes: 11 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
permissions:
contents: read
name: Test

on:
push:
branches: [main]
pull_request:

name: Test
permissions:
contents: read

env:
# Disable incremental compilation for faster from-scratch builds
CARGO_INCREMENTAL: 0

jobs:
Test:
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v3
- uses: actions/checkout@v4
- run: rustup update

- name: Check formatting
run: cargo fmt --all --manifest-path ./oxbow/Cargo.toml -- --check
run: cargo fmt --all --check

- name: Download fixtures
run: cd fixtures && wget -i list.txt

- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: --manifest-path ./oxbow/Cargo.toml
run: cargo test
2 changes: 1 addition & 1 deletion py-oxbow/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ crate-type = ["cdylib"]

[dependencies]
oxbow = { workspace = true }
pyo3 = { version = "0.23.2", features = ["extension-module"] }
pyo3 = { version = "0.23.2", features = ["abi3-py38"] }
2 changes: 1 addition & 1 deletion py-oxbow/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ authors = [
{ name = "Oxbow Developers", email = "[email protected]" }
]
license = { text = "MIT OR Apache-2.0" }
requires-python = ">=3.7"
requires-python = ">=3.8"
classifiers = [
"Programming Language :: Rust",
"Programming Language :: Python :: Implementation :: CPython",
Expand Down
24 changes: 13 additions & 11 deletions py-oxbow/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fn read_fasta(path: &str, region: Option<&str>) -> Vec<u8> {
fn read_fastq(py: Python, path_or_file_like: PyObject) -> Vec<u8> {
if let Ok(string_ref) = path_or_file_like.downcast_bound::<PyString>(py) {
// If it's a string, treat it like a path
let mut reader = FastqReader::new_from_path(string_ref.to_str().unwrap()).unwrap();
let mut reader = FastqReader::new_from_path(string_ref.to_string_lossy().as_ref()).unwrap();
reader.records_to_ipc().unwrap()
} else {
// Otherwise, treat it as file-like
Expand All @@ -69,7 +69,7 @@ fn read_bam(
) -> Vec<u8> {
if let Ok(string_ref) = path_or_file_like.downcast_bound::<PyString>(py) {
// If it's a string, treat it as a path
let mut reader = BamReader::new_from_path(string_ref.to_str().unwrap()).unwrap();
let mut reader = BamReader::new_from_path(string_ref.to_string_lossy().as_ref()).unwrap();
reader.records_to_ipc(region).unwrap()
} else {
// Otherwise, treat it as file-like
Expand All @@ -94,7 +94,7 @@ fn read_bam_vpos(
) -> Vec<u8> {
if let Ok(string_ref) = path_or_file_like.downcast_bound::<PyString>(py) {
// If it's a string, treat it as a path
let mut reader = BamReader::new_from_path(string_ref.to_str().unwrap()).unwrap();
let mut reader = BamReader::new_from_path(string_ref.to_string_lossy().as_ref()).unwrap();
reader.records_to_ipc_from_vpos(pos_lo, pos_hi).unwrap()
} else {
// Otherwise, treat it as file-like
Expand All @@ -118,7 +118,7 @@ fn read_vcf(
) -> Vec<u8> {
if let Ok(string_ref) = path_or_file_like.downcast_bound::<PyString>(py) {
// If it's a string, treat it as a path
let mut reader = VcfReader::new_from_path(string_ref.to_str().unwrap()).unwrap();
let mut reader = VcfReader::new_from_path(string_ref.to_string_lossy().as_ref()).unwrap();
reader.records_to_ipc(region).unwrap()
} else {
// Otherwise, treat it as file-like
Expand All @@ -143,7 +143,7 @@ fn read_vcf_vpos(
) -> Vec<u8> {
if let Ok(string_ref) = path_or_file_like.downcast_bound::<PyString>(py) {
// If it's a string, treat it as a path
let mut reader = VcfReader::new_from_path(string_ref.to_str().unwrap()).unwrap();
let mut reader = VcfReader::new_from_path(string_ref.to_string_lossy().as_ref()).unwrap();
reader.records_to_ipc_from_vpos(pos_lo, pos_hi).unwrap()
} else {
// Otherwise, treat it as file-like
Expand All @@ -167,7 +167,7 @@ fn read_bcf(
) -> Vec<u8> {
if let Ok(string_ref) = path_or_file_like.downcast_bound::<PyString>(py) {
// If it's a string, treat it as a path
let mut reader = BcfReader::new_from_path(string_ref.to_str().unwrap()).unwrap();
let mut reader = BcfReader::new_from_path(string_ref.to_string_lossy().as_ref()).unwrap();
reader.records_to_ipc(region).unwrap()
} else {
// Otherwise, treat it as file-like
Expand All @@ -192,7 +192,7 @@ fn read_bcf_vpos(
) -> Vec<u8> {
if let Ok(string_ref) = path_or_file_like.downcast_bound::<PyString>(py) {
// If it's a string, treat it as a path
let mut reader = VcfReader::new_from_path(string_ref.to_str().unwrap()).unwrap();
let mut reader = VcfReader::new_from_path(string_ref.to_string_lossy().as_ref()).unwrap();
reader.records_to_ipc_from_vpos(pos_lo, pos_hi).unwrap()
} else {
// Otherwise, treat it as file-like
Expand Down Expand Up @@ -220,7 +220,8 @@ fn read_bigwig(
.map(|h| h.iter().map(String::as_str).collect::<HashSet<&str>>());
if let Ok(string_ref) = path_or_file_like.downcast_bound::<PyString>(py) {
// If it's a string, treat it as a path
let mut reader = BigWigReader::new_from_path(string_ref.to_str().unwrap()).unwrap();
let mut reader =
BigWigReader::new_from_path(string_ref.to_string_lossy().as_ref()).unwrap();
match zoom_level {
Some(zoom_level) => reader
.zoom_records_to_ipc(region, zoom_level, zoom_summary_columns_ref)
Expand Down Expand Up @@ -254,7 +255,8 @@ fn read_bigbed(
.map(|h| h.iter().map(String::as_str).collect::<HashSet<&str>>());
if let Ok(string_ref) = path_or_file_like.downcast_bound::<PyString>(py) {
// If it's a string, treat it as a path
let mut reader = BigBedReader::new_from_path(string_ref.to_str().unwrap()).unwrap();
let mut reader =
BigBedReader::new_from_path(string_ref.to_string_lossy().as_ref()).unwrap();
reader.records_to_ipc(region, fields_ref).unwrap()
} else {
// Otherwise, treat it as file-like
Expand All @@ -269,7 +271,7 @@ fn read_bigbed(
fn read_gff(py: Python, path_or_file_like: PyObject) -> Vec<u8> {
if let Ok(string_ref) = path_or_file_like.downcast_bound::<PyString>(py) {
// If it's a string, treat it as a path
let mut reader = GffReader::new_from_path(string_ref.to_str().unwrap()).unwrap();
let mut reader = GffReader::new_from_path(string_ref.to_string_lossy().as_ref()).unwrap();
reader.records_to_ipc().unwrap()
} else {
// Otherwise, treat it as file-like
Expand All @@ -284,7 +286,7 @@ fn read_gff(py: Python, path_or_file_like: PyObject) -> Vec<u8> {
fn read_gtf(py: Python, path_or_file_like: PyObject) -> Vec<u8> {
if let Ok(string_ref) = path_or_file_like.downcast_bound::<PyString>(py) {
// If it's a string, treat it as a path
let mut reader = GtfReader::new_from_path(string_ref.to_str().unwrap()).unwrap();
let mut reader = GtfReader::new_from_path(string_ref.to_string_lossy().as_ref()).unwrap();
reader.records_to_ipc().unwrap()
} else {
// Otherwise, treat it as file-like
Expand Down

0 comments on commit 97db077

Please sign in to comment.