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 8de182689 infra: improve python binding setup (#2178)
8de182689 is described below

commit 8de1826897a0e461e2b459e37fb6d55978a72e59
Author: Kevin Liu <[email protected]>
AuthorDate: Wed Feb 25 19:48:06 2026 -0500

    infra: improve python binding setup (#2178)
    
    ## Which issue does this PR close?
    
    - Closes #.
    
    ## What changes are included in this PR?
    
    While reviewing #1997, i noticed a couple of improvements we can make
    
    1. `make install` should install the local editable `pyiceberg-core` so
    that i can do `make install && make test`
    2. CI should fail on warnings
    3. test should not read local env files (we made a similar fix in
    pyiceberg https://github.com/apache/iceberg-python/pull/3006/).
    Otherwise, tests were reading `~/.pyiceberg.yaml` and polluting the runs
    
    ## Are these changes tested?
    
    Yes.
    
    For (2), see that [it fails in
    
CI](https://github.com/apache/iceberg-rust/actions/runs/22410058261/job/64880767855?pr=2178)
    before removing the use of deprecated `register_table_provider`
---
 bindings/python/Makefile                                |  9 ++++++---
 bindings/python/pyproject.toml                          |  5 +++++
 bindings/python/tests/conftest.py                       | 15 +++++++++++++++
 bindings/python/tests/test_datafusion_table_provider.py |  4 ++--
 4 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/bindings/python/Makefile b/bindings/python/Makefile
index c36a1091d..0e8b9632d 100644
--- a/bindings/python/Makefile
+++ b/bindings/python/Makefile
@@ -15,12 +15,15 @@
 # specific language governing permissions and limitations
 # under the License.
 
-
-install:
-       uv sync --group dev --no-install-project
+.PHONY: build install test
 
 build:
        uv run maturin develop
 
+# uv sync may remove local editable pyiceberg-core, so install rebuilds it 
afterwards.
+install:
+       uv sync --group dev --no-install-project
+       $(MAKE) build
+
 test:
        uv run --no-sync pytest
diff --git a/bindings/python/pyproject.toml b/bindings/python/pyproject.toml
index 38efa00b3..9f62b5716 100644
--- a/bindings/python/pyproject.toml
+++ b/bindings/python/pyproject.toml
@@ -51,6 +51,11 @@ include = [
 [tool.ruff.lint]
 ignore = ["F403", "F405"]
 
+[tool.pytest.ini_options]
+filterwarnings = [
+  "error",
+]
+
 [dependency-groups]
 dev = [
     "maturin>=1.0,<2.0",
diff --git a/bindings/python/tests/conftest.py 
b/bindings/python/tests/conftest.py
index 75ee3f36a..db672c733 100644
--- a/bindings/python/tests/conftest.py
+++ b/bindings/python/tests/conftest.py
@@ -25,6 +25,7 @@ from typing import (
 
 import pytest
 from pydantic_core import to_json
+from pyiceberg.utils.config import Config
 
 from pyiceberg.partitioning import PartitionField, PartitionSpec
 from pyiceberg.schema import Schema
@@ -36,6 +37,20 @@ from pyiceberg.types import (
 )
 
 
[email protected](scope="session", autouse=True)
+def isolate_pyiceberg_config() -> Generator[None, None, None]:
+    monkeypatch = pytest.MonkeyPatch()
+    with TemporaryDirectory() as empty_home_dir:
+        monkeypatch.setenv("HOME", empty_home_dir)
+        monkeypatch.setenv("PYICEBERG_HOME", empty_home_dir)
+
+        import pyiceberg.catalog as catalog
+
+        monkeypatch.setattr(catalog, "_ENV_CONFIG", Config())
+        yield
+    monkeypatch.undo()
+
+
 @pytest.fixture(scope="session")
 def avro_schema_manifest_entry() -> Dict[str, Any]:
     return {
diff --git a/bindings/python/tests/test_datafusion_table_provider.py 
b/bindings/python/tests/test_datafusion_table_provider.py
index 915b78769..3b2d881e1 100644
--- a/bindings/python/tests/test_datafusion_table_provider.py
+++ b/bindings/python/tests/test_datafusion_table_provider.py
@@ -106,7 +106,7 @@ def test_register_iceberg_table_provider(
     )
 
     ctx = SessionContext()
-    ctx.register_table_provider("test", iceberg_table_provider)
+    ctx.register_table("test", iceberg_table_provider)
 
     datafusion_table = ctx.table("test")
     assert datafusion_table is not None
@@ -154,7 +154,7 @@ def test_register_pyiceberg_table(
     )
 
     ctx = SessionContext()
-    ctx.register_table_provider("test", iceberg_table)
+    ctx.register_table("test", iceberg_table)
 
     datafusion_table = ctx.table("test")
     assert datafusion_table is not None

Reply via email to