This is an automated email from the ASF dual-hosted git repository.

yuxia pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/fluss-rust.git


The following commit(s) were added to refs/heads/main by this push:
     new a5b44bb  [feat] Set up uv, ruff, and other settings for Python binding 
(#7)
a5b44bb is described below

commit a5b44bb69f164dfaf416f134da9395450be307d7
Author: naivedogger <[email protected]>
AuthorDate: Tue Sep 16 11:54:04 2025 +0800

    [feat] Set up uv, ruff, and other settings for Python binding (#7)
---
 bindings/python/Cargo.toml     |  38 +++++++++++
 bindings/python/README.md      | 149 +++++++++++++++++++++++++++++++++++++++++
 bindings/python/pyproject.toml |  96 ++++++++++++++++++++++++++
 3 files changed, 283 insertions(+)

diff --git a/bindings/python/Cargo.toml b/bindings/python/Cargo.toml
new file mode 100644
index 0000000..aee1a21
--- /dev/null
+++ b/bindings/python/Cargo.toml
@@ -0,0 +1,38 @@
+# 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.
+
+[package]
+name = "fluss_python"
+edition = "2024"
+version = "0.1.0"
+license = "apache-2.0"
+rust-version = "1.85"
+
+[lib]
+name = "fluss"
+crate-type = ["cdylib"]
+
+[workspace]
+
+[dependencies]
+pyo3 = { version = "0.24", features = ["extension-module"] }
+fluss = { path = "../../crates/fluss" }
+tokio = { workspace = true }
+arrow = { workspace = true }
+arrow-pyarrow = "55.1.0"
+pyo3-async-runtimes = { version = "0.24.0", features = ["tokio-runtime"] }
+chrono = { workspace = true }
diff --git a/bindings/python/README.md b/bindings/python/README.md
new file mode 100644
index 0000000..5258f53
--- /dev/null
+++ b/bindings/python/README.md
@@ -0,0 +1,149 @@
+<!--
+  ~ 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.
+-->
+
+# Apache Fluss™ Python Bindings
+
+Python bindings for Fluss using PyO3 and Maturin.
+
+## API Overview
+
+### Basic Usage
+
+TODO: Add basic usage examples here
+
+### Core Classes
+
+#### `Config`
+
+Configuration for Fluss connection parameters
+
+#### `FlussConnection`
+
+Main interface for connecting to Fluss cluster
+
+#### `FlussAdmin`
+
+Administrative operations for managing tables (create, delete, etc.)
+
+#### `FlussTable`
+
+Represents a Fluss table, providing read and write operations
+
+#### `TableWriter`
+
+Used for writing data to tables, supports PyArrow and Pandas
+
+#### `LogScanner`
+
+Used for scanning table log data
+
+## Development
+
+## Requirements
+
+- Python 3.9+
+- Rust 1.70+
+- [uv](https://docs.astral.sh/uv/) package manager
+- Linux or MacOS
+
+> **⚠️ Before you start:**  
+> Please make sure you can successfully build and run the [Fluss Rust 
client](../../crates/fluss/README.md) on your machine.  
+> The Python bindings require a working Fluss Rust backend and compatible 
environment.
+
+### Install Development Dependencies
+
+```bash
+cd bindings/python
+uv sync --all-extras
+```
+
+### Build Development Version
+
+```bash
+source .venv/bin/activate
+uv run maturin develop
+```
+
+### Build Release Version
+
+```bash
+uv run maturin build --release
+```
+
+### Code Formatting and Linting
+
+```bash
+uv run ruff format python/
+uv run ruff check python/
+```
+
+### Type Checking
+
+```bash
+uv run mypy python/
+```
+
+### Run Examples
+
+```bash
+uv run python example/example.py
+```
+
+### Build API docs:
+
+```bash
+uv run pdoc fluss_python
+```
+
+### Release
+
+```bash
+# Build wheel
+uv run maturin build --release
+
+# Publish to PyPI
+uv run maturin publish
+```
+
+## Project Structure
+```
+bindings/python/
+├── Cargo.toml              # Rust dependency configuration
+├── pyproject.toml          # Python project configuration
+├── README.md              # This file
+├── src/                   # Rust source code
+│   ├── lib.rs            # Main entry module
+│   ├── config.rs         # Configuration related
+│   ├── connection.rs     # Connection management
+│   ├── admin.rs          # Admin operations
+│   ├── table.rs          # Table operations
+│   ├── types.rs          # Data types
+│   └── error.rs          # Error handling
+├── python/               # Python package source
+│   └── fluss_python/
+│       ├── __init__.py   # Python package entry
+│       ├── __init__.pyi  # Stub file
+│       └── py.typed      # Type declarations
+└── example/              # Example code
+    └── example.py
+```
+
+## License
+
+Apache 2.0 License
diff --git a/bindings/python/pyproject.toml b/bindings/python/pyproject.toml
new file mode 100644
index 0000000..fe9d588
--- /dev/null
+++ b/bindings/python/pyproject.toml
@@ -0,0 +1,96 @@
+# 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.
+
+[build-system]
+requires = ["maturin>=1.0,<2.0"]
+build-backend = "maturin"
+
+[project]
+name = "fluss"
+description = "Python bindings for Fluss on fluss-rust with Pandas integration"
+authors = [{name = "Fluss Team"}]
+license = {text = "Apache-2.0"}
+readme = "README.md"
+requires-python = ">=3.9"
+classifiers = [
+    "License :: OSI Approved :: Apache Software License",
+    "Programming Language :: Python :: 3.9",
+    "Programming Language :: Python :: 3.10",
+    "Programming Language :: Python :: 3.11",
+    "Programming Language :: Python :: 3.12",
+]
+
+dynamic = ["version"]
+
+dependencies = [
+    "pandas>=2.3.1",
+    "pyarrow>=10.0.0",
+]
+
+[project.urls]
+Repository = "https://github.com/apache/fluss-rust";
+
+[project.optional-dependencies]
+dev = [
+    "mypy>=1.17.1",
+    "pytest>=8.3.5",
+    "pytest-asyncio>=0.25.3",
+    "ruff>=0.9.10",
+    "maturin>=1.8.2",
+]
+docs = [
+    "pdoc>=15.0.4",
+]
+
+[tool.maturin]
+python-source = "python"
+module-name = "fluss._fluss"
+features = ["pyo3/extension-module"]
+
+[tool.uv]
+cache-keys = [
+  { file = "pyproject.toml" },
+  { file = "Cargo.toml" },
+  { file = "src/**/*.rs" },
+  { file = "../../crates/**/*.rs" },
+]
+
+[tool.ruff]
+line-length = 88
+fix = true
+
+[tool.ruff.lint]
+ignore = ["E402", "F403", "F405"]
+select = ["E", "F", "I"]
+
+[tool.ruff.lint.pycodestyle]
+max-doc-length = 88
+
+[tool.ruff.lint.pydocstyle]
+convention = "numpy"
+
+[tool.ruff.format]
+docstring-code-format = true
+
+[tool.ruff.lint.isort]
+known-first-party = ["fluss"]
+
+[tool.mypy]
+python_version = "3.9"
+warn_return_any = true
+warn_unused_configs = true
+ignore_missing_imports = true

Reply via email to