Skip to content

Commit 77fc134

Browse files
committed
migrate to uv
Signed-off-by: gruebel <[email protected]>
1 parent bfc0070 commit 77fc134

File tree

19 files changed

+3431
-304
lines changed

19 files changed

+3431
-304
lines changed

.github/workflows/build.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,27 +56,27 @@ jobs:
5656
with:
5757
submodules: recursive
5858

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

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

6868
- name: Building first to generate files
69-
run: hatch build
7069
working-directory: ${{ matrix.package }}
70+
run: uv build
7171

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

7777
- name: Test with pytest
78-
run: hatch test -c
7978
working-directory: ${{ matrix.package }}
79+
run: uv run cov --frozen
8080

8181
- if: matrix.python-version == '3.13'
8282
name: Upload coverage to Codecov
@@ -93,10 +93,10 @@ jobs:
9393

9494
steps:
9595
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
96-
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
96+
- name: Install uv and set the python version
97+
uses: astral-sh/setup-uv@7edac99f961f18b581bbd960d59d049f04c0002f # v6
9798
with:
9899
python-version: "3.13"
99-
cache: "pip"
100100

101101
- name: Run pre-commit
102102
uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1

.github/workflows/release.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,18 @@ jobs:
5151
with:
5252
submodules: recursive
5353

54-
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
54+
- name: Install uv and set the python version
55+
uses: astral-sh/setup-uv@7edac99f961f18b581bbd960d59d049f04c0002f # v6
5556
with:
56-
python-version: '3.13'
57+
python-version: "3.13"
5758

58-
- name: Upgrade pip
59-
run: pip install --upgrade pip
60-
61-
- name: Install hatch
62-
run: pip install hatch
59+
- name: Install dependencies
60+
working-directory: ${{ matrix.path }}
61+
run: uv sync --frozen
6362

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

6867
- name: Publish a Python distribution to PyPI
6968
uses: pypa/gh-action-pypi-publish@release/v1

CONTRIBUTING.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ Python 3.9 and above are supported by the SDK.
1212

1313
### Installation and Dependencies
1414

15-
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.
15+
We use [uv](https://github.com/astral-sh/uv) for fast Python package management and dependency resolution.
16+
uv does have built-in support for monorepos via workspace, but it is not supported by release-please yet.
1617

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

1920
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`.
2021

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

3738
```bash
38-
hatch run test
39+
uv run test --frozen
3940
```
4041

4142
### Type checking
4243

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

4546
## Pull Request
4647

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

7677
```bash
7778
cd <package>
78-
hatch build
79-
hatch test
79+
uv build
80+
uv run test --frozen
8081
```
8182

8283
To start working on a new feature or bugfix, create a new branch and start working on it.
Lines changed: 23 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
# pyproject.toml
21
[build-system]
3-
requires = ["hatchling"]
4-
build-backend = "hatchling.build"
2+
requires = ["uv_build~=0.8.0"]
3+
build-backend = "uv_build"
54

65
[project]
76
name = "openfeature-hooks-opentelemetry"
@@ -25,46 +24,20 @@ requires-python = ">=3.9"
2524
[project.urls]
2625
Homepage = "https://github.com/open-feature/python-sdk-contrib"
2726

28-
[tool.hatch]
29-
30-
[tool.hatch.envs.hatch-test]
31-
dependencies = [
32-
"coverage[toml]>=6.5",
33-
"pytest",
34-
]
35-
pre-install-commands = [
36-
"hatch build",
37-
]
38-
39-
[tool.hatch.envs.hatch-test.scripts]
40-
run = "pytest {args:tests}"
41-
run-cov = "coverage run -m pytest {args:tests}"
42-
cov-combine = "coverage combine"
43-
cov-report = [
44-
"coverage xml",
45-
"coverage html",
46-
"coverage report",
47-
]
48-
cov = [
49-
"test-cov",
50-
"cov-report",
27+
[dependency-groups]
28+
dev = [
29+
"coverage[toml]>=7.10.0,<8.0.0",
30+
"mypy[faster-cache]>=1.17.0,<2.0.0",
31+
"pytest>=8.4.0,<9.0.0",
5132
]
5233

53-
[tool.hatch.envs.mypy]
54-
dependencies = [
55-
"mypy[faster-cache]>=1.13.0",
56-
]
57-
58-
[tool.hatch.envs.mypy.scripts]
59-
run = "mypy"
34+
[tool.uv]
35+
required-version = "~=0.8.0"
6036

61-
[tool.hatch.build.targets.sdist]
62-
exclude = [
63-
".gitignore",
64-
]
65-
66-
[tool.hatch.build.targets.wheel]
67-
packages = ["src/openfeature"]
37+
[tool.uv.build-backend]
38+
module-name = "openfeature"
39+
module-root = "src"
40+
namespace = true
6841

6942
[tool.mypy]
7043
mypy_path = "src"
@@ -78,3 +51,13 @@ pretty = true
7851

7952
strict = true
8053
disallow_any_generics = false
54+
55+
[project.scripts]
56+
# workaround while UV doesn't support scripts directly in the pyproject.toml
57+
# see: https://github.com/astral-sh/uv/issues/5903
58+
cov-report = "scripts.scripts:cov_report"
59+
cov = "scripts.scripts:cov"
60+
# don't name it `mypy` otherwise `uv` will override the actual binary
61+
mypy-check = "scripts.scripts:mypy"
62+
test = "scripts.scripts:test"
63+
test-cov = "scripts.scripts:test_cov"
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# ruff: noqa: S602, S607
2+
import subprocess
3+
4+
5+
def test() -> None:
6+
"""Run pytest tests."""
7+
subprocess.run("pytest tests", shell=True, check=True)
8+
9+
10+
def test_cov() -> None:
11+
"""Run tests with coverage."""
12+
subprocess.run("coverage run -m pytest tests", shell=True, check=True)
13+
14+
15+
def cov_report() -> None:
16+
"""Generate coverage report."""
17+
subprocess.run("coverage xml", shell=True, check=True)
18+
19+
20+
def cov() -> None:
21+
"""Run tests with coverage and generate report."""
22+
test_cov()
23+
cov_report()
24+
25+
26+
def mypy() -> None:
27+
"""Run mypy."""
28+
subprocess.run("mypy", shell=True, check=True)

0 commit comments

Comments
 (0)