This is an automated email from the ASF dual-hosted git repository.
liurenjie1024 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-rust.git
The following commit(s) were added to refs/heads/main by this push:
new 68069e3 feat: Establish subproject pyiceberg_core (#518)
68069e3 is described below
commit 68069e36657b63b49a94d927ec5e398a8155d026
Author: Xuanwo <[email protected]>
AuthorDate: Wed Aug 7 20:32:18 2024 +0800
feat: Establish subproject pyiceberg_core (#518)
Signed-off-by: Xuanwo <[email protected]>
---
.github/workflows/bindings_python_ci.yml | 83 ++++++++++++++++++++++
.gitignore | 7 +-
Cargo.toml | 13 ++--
.gitignore => bindings/python/Cargo.toml | 24 +++++--
bindings/python/README.md | 44 ++++++++++++
.gitignore => bindings/python/pyproject.toml | 32 +++++++--
.../python/python/pyiceberg_core/__init__.py | 10 ++-
bindings/python/src/lib.rs | 31 ++++++++
.gitignore => bindings/python/tests/test_basic.py | 11 ++-
9 files changed, 224 insertions(+), 31 deletions(-)
diff --git a/.github/workflows/bindings_python_ci.yml
b/.github/workflows/bindings_python_ci.yml
new file mode 100644
index 0000000..b51593d
--- /dev/null
+++ b/.github/workflows/bindings_python_ci.yml
@@ -0,0 +1,83 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+name: Bindings Python CI
+
+on:
+ push:
+ branches:
+ - main
+ pull_request:
+ branches:
+ - main
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
+ cancel-in-progress: true
+
+jobs:
+ check-rust:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - name: Check format
+ run: cargo fmt --all -- --check
+ - name: Check clippy
+ run: cargo clippy --all-targets --all-features -- -D warnings
+
+ check-python:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - name: Install tools
+ run: |
+ pip install ruff
+ - name: Check format
+ working-directory: "bindings/python"
+ run: |
+ ruff format . --diff
+ - name: Check style
+ working-directory: "bindings/python"
+ run: |
+ ruff check .
+
+ test:
+ runs-on: ${{ matrix.os }}
+ strategy:
+ matrix:
+ os:
+ - ubuntu-latest
+ - macos-latest
+ - windows-latest
+ steps:
+ - uses: actions/checkout@v4
+ - uses: actions/setup-python@v4
+ with:
+ python-version: 3.8
+ - uses: PyO3/maturin-action@v1
+ with:
+ working-directory: "bindings/python"
+ command: build
+ args: --out dist --sdist
+ - name: Run tests
+ working-directory: "bindings/python"
+ shell: bash
+ run: |
+ set -e
+ pip install dist/pyiceberg_core-*.whl --force-reinstall
+ pip install pytest
+ pytest -v
diff --git a/.gitignore b/.gitignore
index 25b8032..05c11ed 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,9 +15,12 @@
# specific language governing permissions and limitations
# under the License.
-/target
-/Cargo.lock
+target
+Cargo.lock
.idea
.vscode
**/.DS_Store
dist/*
+**/venv
+*.so
+*.pyc
diff --git a/Cargo.toml b/Cargo.toml
index 642c99b..4826da2 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -18,11 +18,14 @@
[workspace]
resolver = "2"
members = [
- "crates/catalog/*",
- "crates/examples",
- "crates/iceberg",
- "crates/integrations/*",
- "crates/test_utils",
+ "crates/catalog/*",
+ "crates/examples",
+ "crates/iceberg",
+ "crates/integrations/*",
+ "crates/test_utils",
+]
+exclude = [
+ "bindings/python"
]
[workspace.package]
diff --git a/.gitignore b/bindings/python/Cargo.toml
similarity index 64%
copy from .gitignore
copy to bindings/python/Cargo.toml
index 25b8032..c2c1007 100644
--- a/.gitignore
+++ b/bindings/python/Cargo.toml
@@ -15,9 +15,21 @@
# specific language governing permissions and limitations
# under the License.
-/target
-/Cargo.lock
-.idea
-.vscode
-**/.DS_Store
-dist/*
+[package]
+name = "pyiceberg_core_rust"
+version = "0.0.1"
+edition = "2021"
+homepage = "https://rust.iceberg.apache.org"
+rust-version = "1.77.1"
+# This crate is used to build python bindings, we don't want to publish it
+publish = false
+
+license = "Apache-2.0"
+keywords = ["iceberg"]
+
+[lib]
+crate-type = ["cdylib"]
+
+[dependencies]
+iceberg = { path = "../../crates/iceberg" }
+pyo3 = { version = "0.22", features = ["extension-module"] }
diff --git a/bindings/python/README.md b/bindings/python/README.md
new file mode 100644
index 0000000..566a7bc
--- /dev/null
+++ b/bindings/python/README.md
@@ -0,0 +1,44 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+-->
+
+# Pyiceberg Core
+
+This project is used to build an iceberg-rust powered core for pyiceberg.
+
+## Setup
+
+```shell
+python -m venv venv
+source ./venv/bin/activate
+
+pip install maturin
+```
+
+## Build
+
+```shell
+maturin develop
+```
+
+## Test
+
+```shell
+maturin develop -E test
+pytest -v
+```
\ No newline at end of file
diff --git a/.gitignore b/bindings/python/pyproject.toml
similarity index 55%
copy from .gitignore
copy to bindings/python/pyproject.toml
index 25b8032..4a489ad 100644
--- a/.gitignore
+++ b/bindings/python/pyproject.toml
@@ -15,9 +15,29 @@
# specific language governing permissions and limitations
# under the License.
-/target
-/Cargo.lock
-.idea
-.vscode
-**/.DS_Store
-dist/*
+[build-system]
+requires = ["maturin>=1.0,<2.0"]
+build-backend = "maturin"
+
+[project]
+name = "pyiceberg_core"
+version = "0.0.1"
+classifiers = [
+ "Development Status :: 4 - Beta",
+ "Intended Audience :: Developers",
+ "License :: OSI Approved :: Apache Software License",
+ "Operating System :: OS Independent",
+ "Programming Language :: Python :: 3.11",
+ "Programming Language :: Python :: 3.12",
+]
+
+[project.optional-dependencies]
+test = ["pytest"]
+
+[tool.maturin]
+features = ["pyo3/extension-module"]
+python-source = "python"
+module-name = "pyiceberg_core.pyiceberg_core_rust"
+
+[tool.ruff.lint]
+ignore = ["F403", "F405"]
diff --git a/.gitignore b/bindings/python/python/pyiceberg_core/__init__.py
similarity index 87%
copy from .gitignore
copy to bindings/python/python/pyiceberg_core/__init__.py
index 25b8032..067bb6f 100644
--- a/.gitignore
+++ b/bindings/python/python/pyiceberg_core/__init__.py
@@ -15,9 +15,7 @@
# specific language governing permissions and limitations
# under the License.
-/target
-/Cargo.lock
-.idea
-.vscode
-**/.DS_Store
-dist/*
+from .pyiceberg_core_rust import *
+
+__doc__ = pyiceberg_core_rust.__doc__
+__all__ = pyiceberg_core_rust.__all__
diff --git a/bindings/python/src/lib.rs b/bindings/python/src/lib.rs
new file mode 100644
index 0000000..f0d5d19
--- /dev/null
+++ b/bindings/python/src/lib.rs
@@ -0,0 +1,31 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use iceberg::io::FileIOBuilder;
+use pyo3::prelude::*;
+
+#[pyfunction]
+fn hello_world() -> PyResult<String> {
+ let _ = FileIOBuilder::new_fs_io().build().unwrap();
+ Ok("Hello, world!".to_string())
+}
+
+#[pymodule]
+fn pyiceberg_core_rust(m: &Bound<'_, PyModule>) -> PyResult<()> {
+ m.add_function(wrap_pyfunction!(hello_world, m)?)?;
+ Ok(())
+}
diff --git a/.gitignore b/bindings/python/tests/test_basic.py
similarity index 90%
copy from .gitignore
copy to bindings/python/tests/test_basic.py
index 25b8032..817793b 100644
--- a/.gitignore
+++ b/bindings/python/tests/test_basic.py
@@ -15,9 +15,8 @@
# specific language governing permissions and limitations
# under the License.
-/target
-/Cargo.lock
-.idea
-.vscode
-**/.DS_Store
-dist/*
+from pyiceberg_core import hello_world
+
+
+def test_hello_world():
+ hello_world()