Skip to content

Commit

Permalink
expose rust crate version to python binding
Browse files Browse the repository at this point in the history
also switch pyo3 to build abi3 wheels
  • Loading branch information
Qingping Hou authored and rtyler committed Jan 15, 2021
1 parent 14228be commit 60afb06
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 72 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/python_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,14 @@ jobs:
restore-keys: |
python-${{ runner.OS }}-target-incremental-
- uses: actions/setup-python@v2
- name: Format Python code with Black
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: 3.6

- uses: psf/black@stable
with:
black_args: ". --check"

- name: Setup virtualenv
run: |
Expand Down Expand Up @@ -69,5 +74,5 @@ jobs:
maturin build --manylinux off
ls -lh ../target/wheels
PY_MINOR_VER=$(python -V | cut -d. -f 2)
pip install $(printf ../target/wheels/deltalake-*-cp3${PY_MINOR_VER}-*.whl)'[devel,pandas]'
pip install $(printf ../target/wheels/deltalake-*-cp36-abi3-*.whl)'[devel,pandas]'
py.test tests
12 changes: 0 additions & 12 deletions .github/workflows/python_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,6 @@ jobs:
- uses: actions/setup-python@v2
with:
python-version: 3.6
- uses: actions/setup-python@v2
with:
python-version: 3.7
- uses: actions/setup-python@v2
with:
python-version: 3.8
- uses: actions/setup-python@v2
with:
python-version: 3.9

- name: Install matruin
run: |
Expand Down Expand Up @@ -94,9 +85,6 @@ jobs:
- name: Enable manylinux Python targets
run: |
echo "/opt/python/cp36-cp36m/bin" >> $GITHUB_PATH
echo "/opt/python/cp37-cp37m/bin" >> $GITHUB_PATH
echo "/opt/python/cp38-cp38/bin" >> $GITHUB_PATH
echo "/opt/python/cp39-cp39/bin" >> $GITHUB_PATH
- name: Install matruin
run: |
Expand Down
68 changes: 18 additions & 50 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions python/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "deltalake-python"
version = "0.1.4"
version = "0.2.0"
authors = ["Qingping Hou <[email protected]>"]
homepage = "https://github.com/delta-io/delta-rs"
license = "Apache-2.0"
Expand All @@ -19,8 +19,8 @@ reqwest = { version = "0.10", features = ["native-tls-vendored"] }
env_logger = "0"

[dependencies.pyo3]
version = "0.12.*"
features = ["extension-module"]
version = "0.13.*"
features = ["extension-module", "abi3", "abi3-py36"]

[dependencies.deltalake]
path = "../rust"
Expand Down
4 changes: 2 additions & 2 deletions python/deltalake/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import pyarrow
from pyarrow.dataset import dataset

from .deltalake import RawDeltaTable
from .deltalake import RawDeltaTable, rust_core_version


class DeltaTable():
class DeltaTable:
def __init__(self, table_path: str):
self._table = RawDeltaTable(table_path)

Expand Down
7 changes: 7 additions & 0 deletions python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,17 @@ impl RawDeltaTable {
}
}

#[pyfunction]
fn rust_core_version() -> &'static str {
deltalake::crate_version()
}

#[pymodule]
// module name need to match project name
fn deltalake(py: Python, m: &PyModule) -> PyResult<()> {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("warn")).init();

m.add_function(pyo3::wrap_pyfunction!(rust_core_version, m)?)?;
m.add_class::<RawDeltaTable>()?;
m.add("DeltaTableError", py.get_type::<PyDeltaTableError>())?;
Ok(())
Expand Down
3 changes: 1 addition & 2 deletions python/tests/test_table_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@
def test_read_simple_table_to_dict():
table_path = "../rust/tests/data/simple_table"
dt = DeltaTable(table_path)
assert dt.to_pyarrow_dataset().to_table().to_pydict() == {'id': [5, 7, 9]}

assert dt.to_pyarrow_dataset().to_table().to_pydict() == {"id": [5, 7, 9]}
6 changes: 6 additions & 0 deletions python/tests/test_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from deltalake import rust_core_version


def test_read_simple_table_to_dict():
v = rust_core_version()
assert len(v.split(".")) == 3
5 changes: 5 additions & 0 deletions rust/src/delta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -635,3 +635,8 @@ pub async fn open_table_with_ds(table_path: &str, ds: &str) -> Result<DeltaTable

Ok(table)
}

/// Returns rust create version, can be use used in language bindings to expose Rust core version
pub fn crate_version() -> &'static str {
env!("CARGO_PKG_VERSION")
}

0 comments on commit 60afb06

Please sign in to comment.