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

amoghj pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iceberg.git


The following commit(s) were added to refs/heads/master by this push:
     new 2a48d35623 Python: Add checks after building the wheels (#8532)
2a48d35623 is described below

commit 2a48d356238fc6e74044c0aa8d7a91268dbf12be
Author: Fokko Driesprong <[email protected]>
AuthorDate: Sun Sep 10 17:06:59 2023 +0200

    Python: Add checks after building the wheels (#8532)
    
    * Python: Add checks after building the wheels
    
    * Improvements
---
 .github/workflows/python-release.yml | 17 +++++++++++++----
 python/build-module.py               | 34 +++++++++++++---------------------
 python/pyproject.toml                |  3 ++-
 python/tests/conftest.py             | 22 +++++++++++++++++-----
 4 files changed, 45 insertions(+), 31 deletions(-)

diff --git a/.github/workflows/python-release.yml 
b/.github/workflows/python-release.yml
index e310acdcb1..32b02a0022 100644
--- a/.github/workflows/python-release.yml
+++ b/.github/workflows/python-release.yml
@@ -34,7 +34,7 @@ jobs:
     runs-on: ${{ matrix.os }}
     strategy:
       matrix:
-        os: [ ubuntu-20.04, windows-2019, macos-11 ]
+        os: [ ubuntu-22.04, windows-2022, macos-11 ]
 
     steps:
       - uses: actions/checkout@v3
@@ -46,11 +46,10 @@ jobs:
           python-version: '3.8'
 
       - name: Install poetry
-        run: pip3 install poetry
-        working-directory: ./python
+        run: pip install poetry
 
       - name: Set version
-        run: python3 -m poetry version "${{ inputs.version }}"
+        run: python -m poetry version "${{ inputs.version }}"
         working-directory: ./python
         if: "${{ github.event.inputs.version != 'master' }}"
 
@@ -68,7 +67,17 @@ jobs:
           output-dir: wheelhouse
           config-file: "python/pyproject.toml"
         env:
+          # Ignore 32 bit architectures
+          CIBW_ARCHS: "auto64"
           CIBW_PROJECT_REQUIRES_PYTHON: ">=3.8,<3.12"
+          CIBW_TEST_REQUIRES: "pytest moto"
+          CIBW_TEST_EXTRAS: "s3fs,glue"
+          CIBW_TEST_COMMAND: "pytest -Werror 
{project}/python/tests/avro/test_decoder.py"
+          # There is an upstream issue with installing on MacOSX
+          # https://github.com/pypa/cibuildwheel/issues/1603
+          # Ignore tests for pypy since not all dependencies are compiled for 
it
+          # and would require a local rust build chain
+          CIBW_TEST_SKIP: "pp* *macosx*"
 
       - name: Add source distribution
         if: "${{ matrix.os == 'ubuntu-20.04' }}"
diff --git a/python/build-module.py b/python/build-module.py
index c6794ec624..208a123b90 100644
--- a/python/build-module.py
+++ b/python/build-module.py
@@ -25,8 +25,8 @@ allowed_to_fail = False
 
 
 def build_cython_extensions() -> None:
-    import Cython.Compiler.Options  # pyright: ignore [reportMissingImports]
-    from Cython.Build import build_ext, cythonize  # pyright: ignore 
[reportMissingImports]
+    import Cython.Compiler.Options
+    from Cython.Build import build_ext, cythonize
     from setuptools import Extension
     from setuptools.dist import Distribution
 
@@ -40,28 +40,20 @@ def build_cython_extensions() -> None:
         extra_compile_args = [
             "-O3",
         ]
-    # Relative to project root directory
-    include_dirs = {
-        "pyiceberg/",
-    }
 
-    extensions = [
-        Extension(
-            # Your .pyx file will be available to cpython at this location.
-            "pyiceberg.avro.decoder_fast",
-            [
-                "pyiceberg/avro/decoder_fast.pyx",
-            ],
-            include_dirs=list(include_dirs),
-            extra_compile_args=extra_compile_args,
-            language="c",
-        ),
-    ]
+    package_path = "pyiceberg"
 
-    for extension in extensions:
-        include_dirs.update(extension.include_dirs)
+    extension = Extension(
+        # Your .pyx file will be available to cpython at this location.
+        name="pyiceberg.avro.decoder_fast",
+        sources=[
+            os.path.join(package_path, "avro", "decoder_fast.pyx"),
+        ],
+        extra_compile_args=extra_compile_args,
+        language="c",
+    )
 
-    ext_modules = cythonize(extensions, include_path=list(include_dirs), 
language_level=3, annotate=True)
+    ext_modules = cythonize([extension], include_path=list(package_path), 
language_level=3, annotate=True)
     dist = Distribution({"ext_modules": ext_modules})
     cmd = build_ext(dist)
     cmd.ensure_finalized()
diff --git a/python/pyproject.toml b/python/pyproject.toml
index a375cdcc9e..abeb5bdf82 100644
--- a/python/pyproject.toml
+++ b/python/pyproject.toml
@@ -41,7 +41,8 @@ packages = [
 ]
 include = [
   { path = "dev", format = "sdist" },
-  { path = "pyiceberg/**/*.so", format = "wheel" }
+  { path = "pyiceberg/**/*.so", format = "wheel" },
+  { path = "pyiceberg/**/*.pyd", format = "wheel" },
 ]
 
 [tool.poetry.dependencies]
diff --git a/python/tests/conftest.py b/python/tests/conftest.py
index e01f982e52..ed7f1caa21 100644
--- a/python/tests/conftest.py
+++ b/python/tests/conftest.py
@@ -32,6 +32,7 @@ from datetime import datetime
 from random import choice
 from tempfile import TemporaryDirectory
 from typing import (
+    TYPE_CHECKING,
     Any,
     Callable,
     Dict,
@@ -50,10 +51,8 @@ import aiohttp.typedefs
 import boto3
 import botocore.awsrequest
 import botocore.model
-import pyarrow as pa
 import pytest
 from moto import mock_dynamodb, mock_glue, mock_s3
-from pyarrow import parquet as pq
 
 from pyiceberg import schema
 from pyiceberg.catalog import Catalog
@@ -69,7 +68,6 @@ from pyiceberg.io import (
     load_file_io,
 )
 from pyiceberg.io.fsspec import FsspecFileIO
-from pyiceberg.io.pyarrow import PyArrowFile, PyArrowFileIO
 from pyiceberg.manifest import DataFile, FileFormat
 from pyiceberg.schema import Schema
 from pyiceberg.serializers import ToOutputFile
@@ -91,6 +89,9 @@ from pyiceberg.types import (
 )
 from pyiceberg.utils.datetime import datetime_to_millis
 
+if TYPE_CHECKING:
+    from pyiceberg.io.pyarrow import PyArrowFile, PyArrowFileIO
+
 
 def pytest_collection_modifyitems(items: List[pytest.Item]) -> None:
     for item in items:
@@ -421,6 +422,8 @@ def example_table_metadata_v2() -> Dict[str, Any]:
 
 @pytest.fixture(scope="session")
 def metadata_location(tmp_path_factory: pytest.TempPathFactory) -> str:
+    from pyiceberg.io.pyarrow import PyArrowFileIO
+
     metadata_location = str(tmp_path_factory.mktemp("metadata") / 
f"{uuid.uuid4()}.metadata.json")
     metadata = TableMetadataV2(**EXAMPLE_TABLE_METADATA_V2)
     ToOutputFile.table_metadata(metadata, 
PyArrowFileIO().new_output(location=metadata_location), overwrite=True)
@@ -429,6 +432,8 @@ def metadata_location(tmp_path_factory: 
pytest.TempPathFactory) -> str:
 
 @pytest.fixture(scope="session")
 def metadata_location_gz(tmp_path_factory: pytest.TempPathFactory) -> str:
+    from pyiceberg.io.pyarrow import PyArrowFileIO
+
     metadata_location = str(tmp_path_factory.mktemp("metadata") / 
f"{uuid.uuid4()}.gz.metadata.json")
     metadata = TableMetadataV2(**EXAMPLE_TABLE_METADATA_V2)
     ToOutputFile.table_metadata(metadata, 
PyArrowFileIO().new_output(location=metadata_location), overwrite=True)
@@ -1146,7 +1151,9 @@ class LocalOutputFile(OutputFile):
     def exists(self) -> bool:
         return os.path.exists(self._path)
 
-    def to_input_file(self) -> PyArrowFile:
+    def to_input_file(self) -> "PyArrowFile":
+        from pyiceberg.io.pyarrow import PyArrowFileIO
+
         return PyArrowFileIO().new_input(location=self.location)
 
     def create(self, overwrite: bool = False) -> OutputStream:
@@ -1399,7 +1406,9 @@ def fsspec_fileio_gcs(request: pytest.FixtureRequest) -> 
FsspecFileIO:
 
 
 @pytest.fixture
-def pyarrow_fileio_gcs(request: pytest.FixtureRequest) -> PyArrowFileIO:
+def pyarrow_fileio_gcs(request: pytest.FixtureRequest) -> "PyArrowFileIO":
+    from pyiceberg.io.pyarrow import PyArrowFileIO
+
     properties = {
         GCS_ENDPOINT: request.config.getoption("--gcs.endpoint"),
         GCS_TOKEN: request.config.getoption("--gcs.oauth2.token"),
@@ -1620,6 +1629,9 @@ def clean_up(test_catalog: Catalog) -> None:
 
 @pytest.fixture
 def data_file(table_schema_simple: Schema, tmp_path: str) -> str:
+    import pyarrow as pa
+    from pyarrow import parquet as pq
+
     table = pa.table(
         {"foo": ["a", "b", "c"], "bar": [1, 2, 3], "baz": [True, False, None]},
         metadata={"iceberg.schema": table_schema_simple.model_dump_json()},

Reply via email to