Skip to content

Commit 68069e3

Browse files
authored
feat: Establish subproject pyiceberg_core (#518)
Signed-off-by: Xuanwo <[email protected]>
1 parent 9b4ea11 commit 68069e3

File tree

9 files changed

+292
-7
lines changed

9 files changed

+292
-7
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
name: Bindings Python CI
19+
20+
on:
21+
push:
22+
branches:
23+
- main
24+
pull_request:
25+
branches:
26+
- main
27+
28+
concurrency:
29+
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
30+
cancel-in-progress: true
31+
32+
jobs:
33+
check-rust:
34+
runs-on: ubuntu-latest
35+
steps:
36+
- uses: actions/checkout@v4
37+
- name: Check format
38+
run: cargo fmt --all -- --check
39+
- name: Check clippy
40+
run: cargo clippy --all-targets --all-features -- -D warnings
41+
42+
check-python:
43+
runs-on: ubuntu-latest
44+
steps:
45+
- uses: actions/checkout@v4
46+
- name: Install tools
47+
run: |
48+
pip install ruff
49+
- name: Check format
50+
working-directory: "bindings/python"
51+
run: |
52+
ruff format . --diff
53+
- name: Check style
54+
working-directory: "bindings/python"
55+
run: |
56+
ruff check .
57+
58+
test:
59+
runs-on: ${{ matrix.os }}
60+
strategy:
61+
matrix:
62+
os:
63+
- ubuntu-latest
64+
- macos-latest
65+
- windows-latest
66+
steps:
67+
- uses: actions/checkout@v4
68+
- uses: actions/setup-python@v4
69+
with:
70+
python-version: 3.8
71+
- uses: PyO3/maturin-action@v1
72+
with:
73+
working-directory: "bindings/python"
74+
command: build
75+
args: --out dist --sdist
76+
- name: Run tests
77+
working-directory: "bindings/python"
78+
shell: bash
79+
run: |
80+
set -e
81+
pip install dist/pyiceberg_core-*.whl --force-reinstall
82+
pip install pytest
83+
pytest -v

.gitignore

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
/target
19-
/Cargo.lock
18+
target
19+
Cargo.lock
2020
.idea
2121
.vscode
2222
**/.DS_Store
2323
dist/*
24+
**/venv
25+
*.so
26+
*.pyc

Cargo.toml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,14 @@
1818
[workspace]
1919
resolver = "2"
2020
members = [
21-
"crates/catalog/*",
22-
"crates/examples",
23-
"crates/iceberg",
24-
"crates/integrations/*",
25-
"crates/test_utils",
21+
"crates/catalog/*",
22+
"crates/examples",
23+
"crates/iceberg",
24+
"crates/integrations/*",
25+
"crates/test_utils",
26+
]
27+
exclude = [
28+
"bindings/python"
2629
]
2730

2831
[workspace.package]

bindings/python/Cargo.toml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
[package]
19+
name = "pyiceberg_core_rust"
20+
version = "0.0.1"
21+
edition = "2021"
22+
homepage = "https://rust.iceberg.apache.org"
23+
rust-version = "1.77.1"
24+
# This crate is used to build python bindings, we don't want to publish it
25+
publish = false
26+
27+
license = "Apache-2.0"
28+
keywords = ["iceberg"]
29+
30+
[lib]
31+
crate-type = ["cdylib"]
32+
33+
[dependencies]
34+
iceberg = { path = "../../crates/iceberg" }
35+
pyo3 = { version = "0.22", features = ["extension-module"] }

bindings/python/README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<!--
2+
~ Licensed to the Apache Software Foundation (ASF) under one
3+
~ or more contributor license agreements. See the NOTICE file
4+
~ distributed with this work for additional information
5+
~ regarding copyright ownership. The ASF licenses this file
6+
~ to you under the Apache License, Version 2.0 (the
7+
~ "License"); you may not use this file except in compliance
8+
~ with the License. You may obtain a copy of the License at
9+
~
10+
~ http://www.apache.org/licenses/LICENSE-2.0
11+
~
12+
~ Unless required by applicable law or agreed to in writing,
13+
~ software distributed under the License is distributed on an
14+
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
~ KIND, either express or implied. See the License for the
16+
~ specific language governing permissions and limitations
17+
~ under the License.
18+
-->
19+
20+
# Pyiceberg Core
21+
22+
This project is used to build an iceberg-rust powered core for pyiceberg.
23+
24+
## Setup
25+
26+
```shell
27+
python -m venv venv
28+
source ./venv/bin/activate
29+
30+
pip install maturin
31+
```
32+
33+
## Build
34+
35+
```shell
36+
maturin develop
37+
```
38+
39+
## Test
40+
41+
```shell
42+
maturin develop -E test
43+
pytest -v
44+
```

bindings/python/pyproject.toml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
[build-system]
19+
requires = ["maturin>=1.0,<2.0"]
20+
build-backend = "maturin"
21+
22+
[project]
23+
name = "pyiceberg_core"
24+
version = "0.0.1"
25+
classifiers = [
26+
"Development Status :: 4 - Beta",
27+
"Intended Audience :: Developers",
28+
"License :: OSI Approved :: Apache Software License",
29+
"Operating System :: OS Independent",
30+
"Programming Language :: Python :: 3.11",
31+
"Programming Language :: Python :: 3.12",
32+
]
33+
34+
[project.optional-dependencies]
35+
test = ["pytest"]
36+
37+
[tool.maturin]
38+
features = ["pyo3/extension-module"]
39+
python-source = "python"
40+
module-name = "pyiceberg_core.pyiceberg_core_rust"
41+
42+
[tool.ruff.lint]
43+
ignore = ["F403", "F405"]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
from .pyiceberg_core_rust import *
19+
20+
__doc__ = pyiceberg_core_rust.__doc__
21+
__all__ = pyiceberg_core_rust.__all__

bindings/python/src/lib.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
use iceberg::io::FileIOBuilder;
19+
use pyo3::prelude::*;
20+
21+
#[pyfunction]
22+
fn hello_world() -> PyResult<String> {
23+
let _ = FileIOBuilder::new_fs_io().build().unwrap();
24+
Ok("Hello, world!".to_string())
25+
}
26+
27+
#[pymodule]
28+
fn pyiceberg_core_rust(m: &Bound<'_, PyModule>) -> PyResult<()> {
29+
m.add_function(wrap_pyfunction!(hello_world, m)?)?;
30+
Ok(())
31+
}

bindings/python/tests/test_basic.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
from pyiceberg_core import hello_world
19+
20+
21+
def test_hello_world():
22+
hello_world()

0 commit comments

Comments
 (0)