diff --git a/.github/workflows/python-client.yml b/.github/workflows/python-client.yml index df12b8261c..13ec0d8c5f 100644 --- a/.github/workflows/python-client.yml +++ b/.github/workflows/python-client.yml @@ -50,9 +50,6 @@ jobs: distribution: 'temurin' java-version: '21' - - name: Run regeneratePythonClient - run: ./gradlew regeneratePythonClient - - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5 with: diff --git a/.github/workflows/regtest.yml b/.github/workflows/regtest.yml index 91ce8559a6..b688a5fd64 100644 --- a/.github/workflows/regtest.yml +++ b/.github/workflows/regtest.yml @@ -43,9 +43,6 @@ jobs: - name: Fix permissions run: mkdir -p regtests/output && chmod 777 regtests/output && chmod 777 regtests/t_*/ref/* - - name: Run regeneratePythonClient - run: ./gradlew regeneratePythonClient - - name: Image build run: | ./gradlew \ diff --git a/.github/workflows/spark_client_regtests.yml b/.github/workflows/spark_client_regtests.yml index d31c7c0ae8..87dcb003e3 100644 --- a/.github/workflows/spark_client_regtests.yml +++ b/.github/workflows/spark_client_regtests.yml @@ -43,9 +43,6 @@ jobs: - name: Fix permissions run: mkdir -p regtests/output && chmod 777 regtests/output && chmod 777 regtests/t_*/ref/* - - name: Run regeneratePythonClient - run: ./gradlew regeneratePythonClient - - name: Project build without testing run: ./gradlew assemble diff --git a/client/python/build.py b/client/python/build.py new file mode 100644 index 0000000000..3944bafce9 --- /dev/null +++ b/client/python/build.py @@ -0,0 +1,91 @@ +# 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. +# +# 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. +import os.path +import subprocess +from pathlib import Path + +# Paths +PROJECT_ROOT = Path(__file__).parent +SPEC_DIR = os.path.join(PROJECT_ROOT, "spec") +POLARIS_MANAGEMENT_SPEC = os.path.join(SPEC_DIR, "polaris-management-service.yml") +ICEBERG_CATALOG_SPEC = os.path.join(SPEC_DIR, "iceberg-rest-catalog-open-api.yaml") +POLARIS_CATALOG_SPEC = os.path.join(SPEC_DIR, "polaris-catalog-service.yaml") +OPEN_API_GENERATOR_IGNORE = os.path.join(PROJECT_ROOT, ".openapi-generator-ignore") + +# Open API Generator Configs +PACKAGE_NAME_POLARIS_MANAGEMENT = "--additional-properties=packageName=polaris.management" +PACKAGE_NAME_POLARIS_CATALOG = "--additional-properties=packageName=polaris.catalog" +PYTHON_VERSION = "--additional-properties=pythonVersion=3.9" + +def generate_polaris_management_client() -> None: + subprocess.check_call([ + "openapi-generator-cli", "generate", + "-i", POLARIS_MANAGEMENT_SPEC, + "-g", "python", + "-o", PROJECT_ROOT, + PACKAGE_NAME_POLARIS_MANAGEMENT, + "--additional-properties=apiNamePrefix=polaris", + PYTHON_VERSION, + "--ignore-file-override", OPEN_API_GENERATOR_IGNORE + ], + stdout=subprocess.DEVNULL) + +def generate_polaris_catalog_client() -> None: + subprocess.check_call([ + "openapi-generator-cli", "generate", + "-i", POLARIS_CATALOG_SPEC, + "-g", "python", + "-o", PROJECT_ROOT, + PACKAGE_NAME_POLARIS_CATALOG, + "--additional-properties=apiNameSuffix=", + PYTHON_VERSION, + "--skip-validate-spec", + "--ignore-file-override", OPEN_API_GENERATOR_IGNORE + ], + stdout=subprocess.DEVNULL) + +def generate_iceberg_catalog_client() -> None: + subprocess.check_call([ + "openapi-generator-cli", "generate", + "-i", ICEBERG_CATALOG_SPEC, + "-g", "python", + "-o", PROJECT_ROOT, + PACKAGE_NAME_POLARIS_CATALOG, + "--additional-properties=apiNameSuffix=", + "--additional-properties=apiNamePrefix=Iceberg", + PYTHON_VERSION, + "--skip-validate-spec", + "--ignore-file-override", OPEN_API_GENERATOR_IGNORE + ], + stdout=subprocess.DEVNULL) + +def build() -> None: + generate_polaris_management_client() + generate_polaris_catalog_client() + generate_iceberg_catalog_client() + +if __name__ == "__main__": + build() \ No newline at end of file diff --git a/client/python/polaris/.keep b/client/python/polaris/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/client/python/pyproject.toml b/client/python/pyproject.toml index d33f6c10ee..b3825f1ab3 100644 --- a/client/python/pyproject.toml +++ b/client/python/pyproject.toml @@ -56,5 +56,9 @@ pyiceberg = "==0.9.1" pre-commit = "==4.2.0" [build-system] -requires = ["poetry-core>=2.0.0,<3.0.0"] +requires = ["poetry-core>=2.0.0,<3.0.0", "openapi-generator-cli==7.11.0.post0"] build-backend = "poetry.core.masonry.api" + +[tool.poetry.build] +generate-setup-file = false +script = "build.py" \ No newline at end of file diff --git a/client/python/spec b/client/python/spec new file mode 120000 index 0000000000..409f032979 --- /dev/null +++ b/client/python/spec @@ -0,0 +1 @@ +../../spec \ No newline at end of file diff --git a/regtests/run.sh b/regtests/run.sh index a267aed308..6471b2b254 100755 --- a/regtests/run.sh +++ b/regtests/run.sh @@ -45,7 +45,6 @@ function logred() { REGTEST_HOME=$(dirname $(realpath $0)) -cd "${SCRIPT_DIR}/.." && ./gradlew regeneratePythonClient cd ${REGTEST_HOME} ./setup.sh