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
21 changes: 11 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,27 +56,27 @@ jobs:
with:
submodules: recursive

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
- name: Install uv and set the python version ${{ matrix.python-version }}
uses: astral-sh/setup-uv@7edac99f961f18b581bbd960d59d049f04c0002f # v6
with:
python-version: ${{ matrix.python-version }}
cache: "pip"

- name: Install hatch
run: pip install hatch
- name: Install dependencies
working-directory: ${{ matrix.package }}
run: uv sync --frozen

- name: Building first to generate files
run: hatch build
working-directory: ${{ matrix.package }}
run: uv build

- name: Type checking
if: matrix.python-version == '3.13'
working-directory: ${{ matrix.package }}
run: hatch run mypy:run
run: uv run mypy-check --frozen

- name: Test with pytest
run: hatch test -c
working-directory: ${{ matrix.package }}
run: uv run cov --frozen

- if: matrix.python-version == '3.13'
name: Upload coverage to Codecov
Expand All @@ -93,10 +93,11 @@ jobs:

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
- name: Install uv and set the python version
uses: astral-sh/setup-uv@7edac99f961f18b581bbd960d59d049f04c0002f # v6
with:
python-version: "3.13"
cache: "pip"
enable-cache: false # caching is done automatically in `pre-commit/action`

- name: Run pre-commit
uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,21 @@ jobs:
with:
submodules: recursive

- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
- name: Install uv and set the python version
uses: astral-sh/setup-uv@7edac99f961f18b581bbd960d59d049f04c0002f # v6
with:
python-version: '3.13'
python-version: "3.13"

- name: Upgrade pip
run: pip install --upgrade pip

- name: Install hatch
run: pip install hatch
- name: Install dependencies
working-directory: ${{ matrix.path }}
run: uv sync --frozen

- name: Build a binary wheel and a source tarball
run: hatch build
working-directory: ${{ matrix.path }}
run: uv build

- name: Publish a Python distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: ${{ matrix.path }}/dist
# `uv` stores the build packages in the root `dist` folder
packages-dir: dist
13 changes: 7 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ Python 3.9 and above are supported by the SDK.

### Installation and Dependencies

We use [Hatch](https://hatch.pypa.io/) to manage the project. Hatch does not have built-in support for monorepos yet, so you must run it inside each package directory.
We use [uv](https://github.com/astral-sh/uv) for fast Python package management and dependency resolution.
uv does have built-in support for monorepos via workspace, but it is not supported by release-please yet.

To install Hatch, just run `pip install hatch`.
To install uv, follow the [installation guide](https://docs.astral.sh/uv/getting-started/installation/).

You will also need to setup the `pre-commit` hooks. Run `pre-commit install` in the root directory of the repository. If you don't have `pre-commit` installed, you can install it with `pip install pre-commit`.

Expand All @@ -35,12 +36,12 @@ The Flagd provider utilizes the [gherkin integration tests](https://github.com/o
To run the integration tests you need to have a container runtime, like docker, ranger, etc. installed.

```bash
hatch run test
uv run test --frozen
```

### Type checking

Run `mypy` by entering the package directory and running `hatch run mypy:run`.
Run `mypy` by entering the package directory and running `uv run mypy-check --frozen`.

## Pull Request

Expand Down Expand Up @@ -75,8 +76,8 @@ Ensure your development environment is all set up by building and testing

```bash
cd <package>
hatch build
hatch test
uv build
uv run test --frozen
```

To start working on a new feature or bugfix, create a new branch and start working on it.
Expand Down
62 changes: 21 additions & 41 deletions hooks/openfeature-hooks-opentelemetry/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# pyproject.toml
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
requires = ["uv_build~=0.8.0"]
build-backend = "uv_build"

[project]
name = "openfeature-hooks-opentelemetry"
Expand All @@ -25,46 +24,17 @@ requires-python = ">=3.9"
[project.urls]
Homepage = "https://github.com/open-feature/python-sdk-contrib"

[tool.hatch]

[tool.hatch.envs.hatch-test]
dependencies = [
"coverage[toml]>=6.5",
"pytest",
]
pre-install-commands = [
"hatch build",
[dependency-groups]
dev = [
"coverage[toml]>=7.10.0,<8.0.0",
"mypy[faster-cache]>=1.17.0,<2.0.0",
"pytest>=8.4.0,<9.0.0",
]

[tool.hatch.envs.hatch-test.scripts]
run = "pytest {args:tests}"
run-cov = "coverage run -m pytest {args:tests}"
cov-combine = "coverage combine"
cov-report = [
"coverage xml",
"coverage html",
"coverage report",
]
cov = [
"test-cov",
"cov-report",
]

[tool.hatch.envs.mypy]
dependencies = [
"mypy[faster-cache]>=1.13.0",
]

[tool.hatch.envs.mypy.scripts]
run = "mypy"

[tool.hatch.build.targets.sdist]
exclude = [
".gitignore",
]

[tool.hatch.build.targets.wheel]
packages = ["src/openfeature"]
[tool.uv.build-backend]
module-name = "openfeature"
module-root = "src"
namespace = true

[tool.mypy]
mypy_path = "src"
Expand All @@ -78,3 +48,13 @@ pretty = true

strict = true
disallow_any_generics = false

[project.scripts]
# workaround while UV doesn't support scripts directly in the pyproject.toml
# see: https://github.com/astral-sh/uv/issues/5903
cov-report = "scripts.scripts:cov_report"
cov = "scripts.scripts:cov"
# don't name it `mypy` otherwise `uv` will override the actual binary
mypy-check = "scripts.scripts:mypy"
test = "scripts.scripts:test"
test-cov = "scripts.scripts:test_cov"
28 changes: 28 additions & 0 deletions hooks/openfeature-hooks-opentelemetry/src/scripts/scripts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# ruff: noqa: S602, S607
import subprocess


def test() -> None:
"""Run pytest tests."""
subprocess.run("pytest tests", shell=True, check=True)


def test_cov() -> None:
"""Run tests with coverage."""
subprocess.run("coverage run -m pytest tests", shell=True, check=True)


def cov_report() -> None:
"""Generate coverage report."""
subprocess.run("coverage xml", shell=True, check=True)


def cov() -> None:
"""Run tests with coverage and generate report."""
test_cov()
cov_report()


def mypy() -> None:
"""Run mypy."""
subprocess.run("mypy", shell=True, check=True)
17 changes: 0 additions & 17 deletions mypy.ini

This file was deleted.

78 changes: 41 additions & 37 deletions providers/openfeature-provider-env-var/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,46 +1,53 @@
[build-system]
requires = ["uv_build~=0.8.0"]
build-backend = "uv_build"

[project]
name = "openfeature-provider-env-var"
version = "0.1.0"
description = "OpenFeature Python Environment Variable Provider"
readme = "README.md"
requires-python = ">=3.9"
authors = [{ name = "OpenFeature", email = "[email protected]" }]
license = { file = "LICENSE" }
classifiers = [
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
]
keywords = []
dependencies = [
"openfeature-sdk>=0.8.2",
]
authors = [{ name = "OpenFeature", email = "[email protected]" }]
requires-python = ">=3.9"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project.urls]
Homepage = "https://github.com/open-feature/python-sdk-contrib"

[dependency-groups]
dev = [
"pytest>=8.3.5",
"pytest-cov>=6.1.1",
"coverage[toml]>=7.10.0,<8.0.0",
"mypy[faster-cache]>=1.17.0,<2.0.0",
"pytest>=8.4.0,<9.0.0",
]

[tool.hatch.build.targets.wheel]
packages = ["src/openfeature"]

[tool.hatch]

pre-install-commands = [
"hatch build",
]

[tool.hatch.envs.mypy.scripts]
run = "mypy"

[tool.hatch.envs.mypy]
dependencies = ["mypy"]

[tool.uv]
required-version = "~=0.8.0"
[tool.uv.build-backend]
module-name = "openfeature"
module-root = "src"
namespace = true

[tool.mypy]
mypy_path = "src"
files = "src"

python_version = "3.9" # should be identical to the minimum supported version
namespace_packages = true
explicit_package_bases = true
local_partial_types = true
pretty = true

strict = true
disallow_any_generics = false

[tool.hatch.envs.hatch-test]
dependencies = [
"pytest>=8.3.5",
Expand All @@ -53,16 +60,13 @@ omit = [
"tests/**",
]

[tool.hatch.envs.hatch-test.scripts]
run = "uv run pytest"
run-cov = "uv run pytest --cov --cov-report xml --cov-report html --junit-xml=tests-results.xml"
cov-combine = "."
cov-report = [
"coverage xml",
"coverage html",
"coverage report",
]
cov = [
".coverage",
"tests-results.xml",
]
[project.scripts]
# workaround while UV doesn't support scripts directly in the pyproject.toml
# see: https://github.com/astral-sh/uv/issues/5903
cov-report = "scripts.scripts:cov_report"
cov = "scripts.scripts:cov"
# don't name it `mypy` otherwise `uv` will override the actual binary
mypy-check = "scripts.scripts:mypy"
test = "scripts.scripts:test"
test-cov = "scripts.scripts:test_cov"

28 changes: 28 additions & 0 deletions providers/openfeature-provider-env-var/src/scripts/scripts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# ruff: noqa: S602, S607
import subprocess


def test() -> None:
"""Run pytest tests."""
subprocess.run("pytest tests", shell=True, check=True)


def test_cov() -> None:
"""Run tests with coverage."""
subprocess.run("coverage run -m pytest tests", shell=True, check=True)


def cov_report() -> None:
"""Generate coverage report."""
subprocess.run("coverage xml", shell=True, check=True)


def cov() -> None:
"""Run tests with coverage and generate report."""
test_cov()
cov_report()


def mypy() -> None:
"""Run mypy."""
subprocess.run("mypy", shell=True, check=True)
Loading