Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
{
matchManagers: [
"gradle", "gradle-wrapper",
"pip_requirements", "pip_setup", "poetry", "setup-cfg",
"pip_requirements", "pip_setup", "uv", "setup-cfg",
"dockerfile", "devcontainer", "docker-compose",
"github-actions"],
automerge: false, // just be explicit (false is the default)
Expand All @@ -61,7 +61,7 @@
},
// boto3 (release frequency: multiple times per week)
{
matchManagers: ["pip_requirements", "pip_setup", "poetry"],
matchManagers: ["pip_requirements", "pip_setup", "uv"],
matchPackagePrefixes: ["boto3"],
extends: ["schedule:weekly"],
},
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Python project with Poetry and cache/restore any dependencies to improve the workflow execution time
# This workflow will build a Python project with UV and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/use-cases-and-examples/building-and-testing/building-and-testing-python

name: Python Client CI
Expand Down
8 changes: 3 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@
regtests/derby.log
regtests/metastore_db
regtests/output/
# This file, if checked in after running for example regtests, contains unmanaged dependencies that eventually
# cause unnecessary "security alerts" like https://github.com/apache/polaris/pull/718.
client/python/poetry.lock
client/python/uv.lock

# Python stuff (see note about poetry.lock above as well!)
/poetry.lock
# Python stuff
/uv.lock
/polaris-venv/
/pyproject.toml
client/python/.openapi-generator/
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ request adding CHANGELOG notes for breaking (!) changes and possibly other secti
- Added Windows support for Python client.
- (Before/After)UpdateTableEvent is emitted for all table updates within a transaction.
- Added KMS options to Polaris CLI
- Changed from Poetry to UV for Python package management

### Deprecations

Expand Down
24 changes: 12 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ ACTIVATE_AND_CD = source $(VENV_DIR)/bin/activate && cd $(PYTHON_CLIENT_DIR)
## Version information
BUILD_VERSION := $(shell cat version.txt)
GIT_COMMIT := $(shell git rev-parse HEAD)
POETRY_VERSION := $(shell cat client/python/pyproject.toml | grep requires-poetry | sed 's/requires-poetry *= *"\(.*\)"/\1/')
UV_VERSION := $(shell cat client/python/pyproject.toml | grep -A1 tool.uv | grep -v tool.uv | grep required-version | sed 's/required-version *= *"\([^"]*\)".*/\1/')

##@ General

Expand All @@ -45,7 +45,7 @@ help: ## Display this help
version: ## Display version information
@echo "Build version: ${BUILD_VERSION}"
@echo "Git commit: ${GIT_COMMIT}"
@echo "Poetry version: ${POETRY_VERSION}"
@echo "UV version: ${UV_VERSION}"

##@ Polaris Build

Expand Down Expand Up @@ -114,21 +114,21 @@ $(VENV_DIR):

.PHONY: client-install-dependencies
client-install-dependencies: $(VENV_DIR)
@echo "Installing Poetry and project dependencies into $(VENV_DIR)..."
@echo "Installing UV and project dependencies into $(VENV_DIR)..."
@$(VENV_DIR)/bin/pip install --upgrade pip
@if [ ! -f "$(VENV_DIR)/bin/poetry" ]; then \
$(VENV_DIR)/bin/pip install --upgrade "poetry$(POETRY_VERSION)"; \
@if [ ! -f "$(VENV_DIR)/bin/uv" ]; then \
$(VENV_DIR)/bin/pip install --upgrade "uv$(UV_VERSION)"; \
fi
@$(ACTIVATE_AND_CD) && poetry lock && poetry install --all-extras
@echo "Poetry and dependencies installed."
@$(ACTIVATE_AND_CD) && uv lock && uv sync --active --all-extras
@echo "uv and dependencies installed."

.PHONY: client-setup-env
client-setup-env: $(VENV_DIR) client-install-dependencies

.PHONY: client-lint
client-lint: client-setup-env ## Run linting checks for Polaris client
@echo "--- Running client linting checks ---"
@$(ACTIVATE_AND_CD) && poetry run pre-commit run --files integration_tests/* generate_clients.py apache_polaris/cli/* apache_polaris/cli/command/* apache_polaris/cli/options/* test/*
@$(ACTIVATE_AND_CD) && uv run --active pre-commit run --files integration_tests/* generate_clients.py apache_polaris/cli/* apache_polaris/cli/command/* apache_polaris/cli/options/* test/*
@echo "--- Client linting checks complete ---"

.PHONY: client-regenerate
Expand All @@ -140,7 +140,7 @@ client-regenerate: client-setup-env ## Regenerate the client code
.PHONY: client-unit-test
client-unit-test: client-setup-env ## Run client unit tests
@echo "--- Running client unit tests ---"
@$(ACTIVATE_AND_CD) && poetry run pytest test/
@$(ACTIVATE_AND_CD) && uv run --active pytest test/
@echo "--- Client unit tests complete ---"

.PHONY: client-integration-test
Expand All @@ -157,7 +157,7 @@ client-integration-test: build-server client-setup-env ## Run client integration
sleep 2; \
done
@echo "Polaris is healthy. Starting integration tests..."
@$(ACTIVATE_AND_CD) && poetry run pytest integration_tests/
@$(ACTIVATE_AND_CD) && uv run --active pytest integration_tests/
@echo "--- Client integration tests complete ---"
@echo "Tearing down Docker Compose services..."
@$(DOCKER) compose -f $(PYTHON_CLIENT_DIR)/docker-compose.yml down || true # Ensure teardown even if tests fail
Expand All @@ -177,10 +177,10 @@ client-build: client-setup-env ## Build client distribution. Pass FORMAT=sdist o
exit 1; \
fi; \
echo "Building with format: $(FORMAT)"; \
$(ACTIVATE_AND_CD) && poetry build --format $(FORMAT); \
$(ACTIVATE_AND_CD) && uv build --format $(FORMAT); \
else \
echo "Building default distribution (sdist and wheel)"; \
$(ACTIVATE_AND_CD) && poetry build; \
$(ACTIVATE_AND_CD) && uv build; \
fi
@echo "--- Client distribution build complete ---"

Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ tasks.named<RatTask>("rat").configure {
// Python
excludes.add("**/.venv/**")
excludes.add("**/polaris-venv/**")
excludes.add("**/poetry.lock")
excludes.add("**/uv.lock")
excludes.add("**/.ruff_cache/**")
excludes.add("**/.mypy_cache/**")
excludes.add("**/.pytest_cache/**")
Expand Down
2 changes: 1 addition & 1 deletion client/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The Apache Polaris Python package provides a client for interacting with the Apa

### Prerequisites
- Python 3.10 or later
- poetry >= 2.1
- uv >= 0.9.0

### Installation
First we need to generate the OpenAPI client code from the OpenAPI specification by running the following command **from the project root directory**:
Expand Down
28 changes: 12 additions & 16 deletions client/python/generate_clients.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
# 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.
# 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
#
Expand All @@ -23,7 +15,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

#
import sys
import os.path
import subprocess
Expand Down Expand Up @@ -61,6 +53,7 @@
Path(".openapi-generator-ignore"),
Path(".pytest_cache"),
Path("test/test_cli_parsing.py"),
Path("__pycache__"),
Path("apache_polaris/__pycache__"),
Path("apache_polaris/cli"),
Path("apache_polaris/sdk/__pycache__"),
Expand All @@ -80,11 +73,14 @@
Path(".DS_Store"),
Path("Makefile"),
Path("poetry.lock"),
Path("uv.lock"),
Path("docker-compose.yml"),
Path(".pre-commit-config.yaml"),
Path("README.md"),
Path("generate_clients.py"),
Path("hatch_build.py"),
Path(".venv"),
Path("venv"),
Path("dist"),
Path("templates"),
Path("spec"),
Expand Down
27 changes: 27 additions & 0 deletions client/python/hatch_build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#
# 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.
#
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
import subprocess
import sys


class GenerateClientsHook(BuildHookInterface):
def initialize(self, version, build_data):
subprocess.check_call([sys.executable, "generate_clients.py"])

77 changes: 44 additions & 33 deletions client/python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@
name = "apache-polaris"
version = "1.4.0"
description = "Apache Polaris"
authors = [
{name = "Apache Software Foundation", email = "dev@polaris.apache.org"}
]
readme = "README.md"
authors = [{ name = "Apache Software Foundation", email = "dev@polaris.apache.org" }]
requires-python = ">=3.10,<4.0"
readme = "README.md"
license = "Apache-2.0"
keywords = ["Apache Polaris", "Polaris", "Polaris Management Service", "Apache Iceberg REST Catalog API"]
dynamic = ["classifiers"]
keywords = [
"Apache Polaris",
"Polaris",
"Polaris Management Service",
"Apache Iceberg REST Catalog API",
]
dependencies = [
"urllib3>=1.25.3,<3.0.0",
"python-dateutil>=2.8.2",
Expand All @@ -44,39 +46,48 @@ repository = "https://github.com/apache/polaris/"
[project.scripts]
polaris = "apache_polaris.cli.polaris_cli:main"

[tool.poetry]
requires-poetry = "==2.2.1"
packages = [
{ include = "apache_polaris" }
[dependency-groups]
dev = [
"pytest>= 7.2.1",
"pytest-cov>= 2.8.1",
"flake8>= 4.0.0",
"types-python-dateutil>= 2.8.19.14",
"mypy>=1.19, <=1.19.1",
"pyiceberg==0.10.0",
"pre-commit==4.5.1",
# 7.12.0 is the latest version to use due to OpenAPI spec version we are using
"openapi-generator-cli==7.12.0",
"pip-licenses-cli==3.0.1",
]

[tool.hatch.build.targets.sdist]
include = [
{ path = "apache_polaris/cli", format = ["sdist", "wheel"] },
{ path = "apache_polaris/sdk", format = ["sdist", "wheel"] },
{ path = "templates/**", format = "sdist" },
{ path = "spec/**", format = "sdist" },
"generate_clients.py",
"apache_polaris",
"templates/",
".openapi-generator-ignore"
]

[tool.poetry.group.dev.dependencies]
pytest = ">= 7.2.1"
pytest-cov = ">= 2.8.1"
flake8 = ">= 4.0.0"
types-python-dateutil = ">= 2.8.19.14"
mypy = ">=1.19, <=1.19.1"
pyiceberg = "==0.10.0"
pre-commit = "==4.5.1"
# 7.12.0 is the latest version to use due to OpenAPI spec version we are using
openapi-generator-cli = "==7.12.0"
pip-licenses-cli = "==3.0.1"
[tool.hatch.build.targets.sdist.force-include]
"spec" = "spec/"

[tool.pip-licenses]
partial-match = true
allow-only = "Apache;BSD License;BSD-3-Clause;ISC;MIT;Mozilla Public License;PSF-2.0;Python Software Foundation License;The Unlicense"
[tool.hatch.build.targets.wheel]
include = ["apache_polaris"]

[tool.hatch.build.hooks.custom]
path = "hatch_build.py"

[build-system]
# 7.12.0 is the latest version to use due to OpenAPI spec version we are using
requires = ["poetry-core==2.2.1", "openapi-generator-cli==7.12.0"]
build-backend = "poetry.core.masonry.api"
requires = ["hatchling", "openapi-generator-cli==7.12.0"]
build-backend = "hatchling.build"

[tool.uv]
required-version = ">=0.9.0" # keep this as the first item for version parsing
default-groups = [
"dev"
]

[tool.poetry.build]
generate-setup-file = false
script = "generate_clients.py"
[tool.pip-licenses]
partial-match = true
allow-only = "Apache;BSD License;BSD-3-Clause;ISC;MIT;Mozilla Public License;PSF-2.0;Python Software Foundation License;The Unlicense"
Loading