From b5aa8a131d4c11520f8b4ffe810663a051409e67 Mon Sep 17 00:00:00 2001 From: Federico Bond Date: Sat, 20 Jan 2024 01:05:47 -0300 Subject: [PATCH] chore: continue migrating to hatch Signed-off-by: Federico Bond --- .github/workflows/build.yml | 16 +++--- .../pyproject.toml | 43 ++++++++++++---- .../contrib/hooks/opentelemetry/__init__.py | 0 .../openfeature-provider-flagd/pyproject.toml | 49 ++++++++++++++----- .../scripts/gen_protos.sh | 10 ++++ .../contrib/provider/flagd/__init__.py | 0 .../contrib/provider/flagd/defaults.py | 0 .../contrib/provider/flagd/flag_type.py | 0 .../contrib/provider/flagd/provider.py | 0 9 files changed, 91 insertions(+), 27 deletions(-) rename hooks/openfeature-hooks-opentelemetry/{ => src}/openfeature/contrib/hooks/opentelemetry/__init__.py (100%) create mode 100755 providers/openfeature-provider-flagd/scripts/gen_protos.sh rename providers/openfeature-provider-flagd/{ => src}/openfeature/contrib/provider/flagd/__init__.py (100%) rename providers/openfeature-provider-flagd/{ => src}/openfeature/contrib/provider/flagd/defaults.py (100%) rename providers/openfeature-provider-flagd/{ => src}/openfeature/contrib/provider/flagd/flag_type.py (100%) rename providers/openfeature-provider-flagd/{ => src}/openfeature/contrib/provider/flagd/provider.py (100%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a6cbfeef..79688937 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,6 +22,9 @@ jobs: strategy: matrix: python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + package: + - "hooks/openfeature-hooks-opentelemetry" + - "providers/openfeature-provider-flagd" steps: - uses: actions/checkout@v4 @@ -38,20 +41,19 @@ jobs: with: github_token: ${{ github.token }} - - name: Install dependencies - run: make venv - - - name: Generate flagd protobuf files - run: make grpc + - name: Install hatch + run: pip install hatch - name: Test with pytest - run: make testcov + run: hatch run cov + working-directory: ${{ matrix.package }} - name: Upload coverage to Codecov - uses: codecov/codecov-action@e0fbd592d323cb2991fb586fdd260734fcb41fcb + uses: codecov/codecov-action@v3 with: flags: unittests # optional name: coverage # optional + directory: ${{ matrix.package }} fail_ci_if_error: true # optional (default = false) verbose: true # optional (default = false) diff --git a/hooks/openfeature-hooks-opentelemetry/pyproject.toml b/hooks/openfeature-hooks-opentelemetry/pyproject.toml index b1d127ba..79a0556f 100644 --- a/hooks/openfeature-hooks-opentelemetry/pyproject.toml +++ b/hooks/openfeature-hooks-opentelemetry/pyproject.toml @@ -1,13 +1,13 @@ # pyproject.toml [build-system] -requires = ["setuptools>=61.0.0", "wheel"] -build-backend = "setuptools.build_meta" +requires = ["hatchling"] +build-backend = "hatchling.build" [project] name = "openfeature-hooks-opentelemetry" version = "0.1.0" description = "OpenTelemetry hooks for the OpenFeature Python SDK" -readme = "readme.md" +readme = "README.md" authors = [{ name = "OpenFeature", email = "openfeature-core@groups.io" }] license = { file = "LICENSE" } classifiers = [ @@ -16,13 +16,38 @@ classifiers = [ "Programming Language :: Python :: 3", ] keywords = [] -dependencies = [] -requires-python = ">=3.8" - -[project.optional-dependencies] -tests = [ - 'pytest', +dependencies = [ + "openfeature-sdk>=0.4.0", + "opentelemetry-api", ] +requires-python = ">=3.8" [project.urls] Homepage = "https://github.com/open-feature/python-sdk-contrib" + +[tool.hatch] + +[tool.hatch.envs.default] +dependencies = [ + "coverage[toml]>=6.5", + "pytest", +] + +[tool.hatch.envs.default.scripts] +test = "pytest {args:tests}" +test-cov = "coverage run -m pytest {args:tests}" +cov-report = [ + "coverage report", +] +cov = [ + "test-cov", + "cov-report", +] + +[tool.hatch.build.targets.sdist] +exclude = [ + ".gitignore", +] + +[tool.hatch.build.targets.wheel] +packages = ["src/openfeature"] diff --git a/hooks/openfeature-hooks-opentelemetry/openfeature/contrib/hooks/opentelemetry/__init__.py b/hooks/openfeature-hooks-opentelemetry/src/openfeature/contrib/hooks/opentelemetry/__init__.py similarity index 100% rename from hooks/openfeature-hooks-opentelemetry/openfeature/contrib/hooks/opentelemetry/__init__.py rename to hooks/openfeature-hooks-opentelemetry/src/openfeature/contrib/hooks/opentelemetry/__init__.py diff --git a/providers/openfeature-provider-flagd/pyproject.toml b/providers/openfeature-provider-flagd/pyproject.toml index c1a720f6..caaba98b 100644 --- a/providers/openfeature-provider-flagd/pyproject.toml +++ b/providers/openfeature-provider-flagd/pyproject.toml @@ -1,13 +1,13 @@ # pyproject.toml [build-system] -requires = ["setuptools>=61.0.0", "wheel"] -build-backend = "setuptools.build_meta" +requires = ["hatchling"] +build-backend = "hatchling.build" [project] name = "openfeature-provider-flagd" version = "0.1.0" description = "OpenFeature provider for the flagd flag evaluation engine" -readme = "readme.md" +readme = "README.md" authors = [{ name = "OpenFeature", email = "openfeature-core@groups.io" }] license = { file = "LICENSE" } classifiers = [ @@ -16,16 +16,43 @@ classifiers = [ "Programming Language :: Python :: 3", ] keywords = [] -dependencies = [] -requires-python = ">=3.8" - -[project.optional-dependencies] -tests = [ - 'pytest', +dependencies = [ + "openfeature-sdk>=0.4.0", + "grpcio>=1.60.0", + "protobuf>=4.25.2", ] +requires-python = ">=3.8" [project.urls] Homepage = "https://github.com/open-feature/python-sdk-contrib" -[tool.setuptools.packages.find] -exclude = ["schemas"] +[tool.hatch] + +[tool.hatch.envs.default] +dependencies = [ + "coverage[toml]>=6.5", + "pytest", +] +post-install-commands = [ + "./scripts/gen_protos.sh" +] + +[tool.hatch.envs.default.scripts] +test = "pytest {args:tests}" +test-cov = "coverage run -m pytest {args:tests}" +cov-report = [ + "coverage report", +] +cov = [ + "test-cov", + "cov-report", +] + +[tool.hatch.build.targets.sdist] +exclude = [ + ".gitignore", + "schemas", +] + +[tool.hatch.build.targets.wheel] +packages = ["src/openfeature"] diff --git a/providers/openfeature-provider-flagd/scripts/gen_protos.sh b/providers/openfeature-provider-flagd/scripts/gen_protos.sh new file mode 100755 index 00000000..5c7c5fb2 --- /dev/null +++ b/providers/openfeature-provider-flagd/scripts/gen_protos.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +set -e + +buf generate buf.build/open-feature/flagd --template schemas/protobuf/buf.gen.python.yaml --output schemas +rm -rf openfeature/contrib/provider/flagd/proto +sed -i.bak 's/^from schema.v1 import/from . import/' proto/python/schema/v1/*.py +rm proto/python/schema/v1/*.bak +mv proto/python src/openfeature/contrib/provider/flagd/proto +rmdir proto diff --git a/providers/openfeature-provider-flagd/openfeature/contrib/provider/flagd/__init__.py b/providers/openfeature-provider-flagd/src/openfeature/contrib/provider/flagd/__init__.py similarity index 100% rename from providers/openfeature-provider-flagd/openfeature/contrib/provider/flagd/__init__.py rename to providers/openfeature-provider-flagd/src/openfeature/contrib/provider/flagd/__init__.py diff --git a/providers/openfeature-provider-flagd/openfeature/contrib/provider/flagd/defaults.py b/providers/openfeature-provider-flagd/src/openfeature/contrib/provider/flagd/defaults.py similarity index 100% rename from providers/openfeature-provider-flagd/openfeature/contrib/provider/flagd/defaults.py rename to providers/openfeature-provider-flagd/src/openfeature/contrib/provider/flagd/defaults.py diff --git a/providers/openfeature-provider-flagd/openfeature/contrib/provider/flagd/flag_type.py b/providers/openfeature-provider-flagd/src/openfeature/contrib/provider/flagd/flag_type.py similarity index 100% rename from providers/openfeature-provider-flagd/openfeature/contrib/provider/flagd/flag_type.py rename to providers/openfeature-provider-flagd/src/openfeature/contrib/provider/flagd/flag_type.py diff --git a/providers/openfeature-provider-flagd/openfeature/contrib/provider/flagd/provider.py b/providers/openfeature-provider-flagd/src/openfeature/contrib/provider/flagd/provider.py similarity index 100% rename from providers/openfeature-provider-flagd/openfeature/contrib/provider/flagd/provider.py rename to providers/openfeature-provider-flagd/src/openfeature/contrib/provider/flagd/provider.py