Skip to content

[feat] Set up uv, ruff, and other settings for Python binding#7

Merged
luoyuxia merged 6 commits intoapache:mainfrom
naivedogger:pr/basic-settings
Sep 16, 2025
Merged

[feat] Set up uv, ruff, and other settings for Python binding#7
luoyuxia merged 6 commits intoapache:mainfrom
naivedogger:pr/basic-settings

Conversation

@naivedogger
Copy link
Contributor

@naivedogger naivedogger commented Aug 28, 2025

Purpose

Linked issue: close #12

Brief change log

Tests

API and Format

Documentation

@naivedogger naivedogger changed the title Pr/basic settings [feat] Set up uv, ruff, and other settings for the binding Aug 28, 2025
@naivedogger naivedogger marked this pull request as ready for review August 28, 2025 12:47
@naivedogger naivedogger changed the title [feat] Set up uv, ruff, and other settings for the binding [feat] Set up uv, ruff, and other settings for Python binding Aug 29, 2025
@luoyuxia luoyuxia requested a review from Copilot September 9, 2025 02:12
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR sets up the foundation for Python bindings for Fluss using PyO3 and Maturin, including development tooling configuration and project structure.

Key changes:

  • Configures Python project with pyproject.toml including dependencies, build system, and tooling settings
  • Sets up development environment with uv, ruff, and mypy configurations
  • Adds comprehensive README with development workflow and API documentation

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.

File Description
bindings/python/pyproject.toml Defines Python project configuration, dependencies, and tooling settings
bindings/python/README.md Provides development setup instructions and project documentation
bindings/python/Cargo.toml Configures Rust crate for Python bindings with PyO3 dependencies
.licenserc.yaml Excludes uv.lock from license header requirements

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Contributor

@luoyuxia luoyuxia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@naivedogger Thanks for the pr. Left some comments.

.licenserc.yaml Outdated
- 'LICENSE'
- 'NOTICE'
- 'DISCLAIMER'
- 'bindings/python/uv.lock'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why we need to add uv.lock, haven't seen any python binding project include it. I think we don't need to include it since cargo.lock is also ignored by us

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleted.

rust-version = "1.85"

[lib]
name = "fluss_python"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have gone through other projects, we should use fluss

Suggested change
name = "fluss_python"
name = "fluss"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

arrow-pyarrow = "55.1.0"
pyo3-async-runtimes = { version = "0.24.0", features = ["tokio-runtime"] }
chrono = "0.4.41"
once_cell = "1.21.3"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why once_cell is needed? If needed, we can attach it in following pull requests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will introduce this later on

[dependencies]
pyo3 = { version = "0.24", features = ["extension-module"] }
fluss = { path = "../../crates/fluss" }
tokio = { version = "1.44.2", features = ["full"] }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tokio = { workspace = true }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

pyo3 = { version = "0.24", features = ["extension-module"] }
fluss = { path = "../../crates/fluss" }
tokio = { version = "1.44.2", features = ["full"] }
arrow = "55.1.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to suggestion arrow also use { workspace = true }

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this looks better.

- Python 3.9+
- Rust 1.70+
- uv package manager
- MacOS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Linux or macOs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


- Python 3.9+
- Rust 1.70+
- uv package manager
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a link for uv package manager?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

~ under the License.
-->

# Fluss Python Bindings
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Apache Fluss™ Python Bindings

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

## API Overview

### Basic Usage

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add todo in here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

└── example.py
```

## API Overview
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we shuld always put user-faced api into first. So, let's organize it as, assuming System Requirements is only for developer:

<!--
  ~ 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

### 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

### Release

```bash
# Build wheel
uv run maturin build --release

# Publish to PyPI
uv run maturin publish

Development

Requirements

  • Python 3.9+
  • Rust 1.70+
  • uv package manager
  • MacOS

⚠️ Before you start:
Please make sure you can successfully build and run the Fluss Rust client on your machine.
The Python bindings require a working Fluss Rust backend and compatible environment.

Install Dependencies-dev

cd bindings/python
uv sync --all-extras

Build Development Version

source .venv/bin/activate
uv run maturin develop

Build Release Version

uv run maturin build --release

Code Formatting and Linting

uv run ruff format python/
uv run ruff check python/

Type Checking

uv run mypy python/

Run Examples

uv run python example/example.py

Build API docs:

uv run pdoc fluss_python

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great!

@luoyuxia luoyuxia merged commit a5b44bb into apache:main Sep 16, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Set up the Python binding project

2 participants