Skip to content

Commit f511b68

Browse files
committed
starting migration to uv
Signed-off-by: leohoare <leo@insight.co>
1 parent d21d9db commit f511b68

5 files changed

Lines changed: 368 additions & 52 deletions

File tree

.github/workflows/build.yml

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,29 @@ jobs:
2828
with:
2929
submodules: recursive
3030

31-
- name: Set up Python ${{ matrix.python-version }}
32-
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
31+
- name: Install uv and set the python version
32+
uses: astral-sh/setup-uv@v5
3333
with:
3434
python-version: ${{ matrix.python-version }}
35-
cache: "pip"
36-
allow-prereleases: true
3735

38-
- name: Install hatch
39-
run: pip install hatch
36+
- name: Install dependencies
37+
run: uv sync --extra dev
4038

4139
- name: Test with pytest
42-
run: hatch run cov
40+
run: uv run pytest tests
41+
42+
- name: Run coverage
43+
run: uv run coverage run -m pytest tests
44+
45+
- name: Coverage report
46+
run: uv run coverage xml
4347

4448
- name: Run E2E tests with behave
45-
run: hatch run e2e
49+
run: |
50+
git submodule update --init --recursive
51+
cp spec/specification/assets/gherkin/* tests/features/
52+
uv run behave tests/features/
53+
rm tests/features/*.feature
4654
4755
- if: matrix.python-version == '3.13'
4856
name: Upload coverage to Codecov
@@ -59,10 +67,13 @@ jobs:
5967

6068
steps:
6169
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
62-
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
70+
- name: Install uv and set the python version
71+
uses: astral-sh/setup-uv@v5
6372
with:
6473
python-version: "3.13"
65-
cache: "pip"
74+
75+
- name: Install dependencies
76+
run: uv sync --extra dev
6677

6778
- name: Run pre-commit
6879
uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
@@ -75,7 +86,8 @@ jobs:
7586
security-events: write
7687
steps:
7788
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
78-
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
89+
- name: Install uv and set the python version
90+
uses: astral-sh/setup-uv@v5
7991
with:
8092
python-version: "3.13"
8193

.github/workflows/release.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,16 @@ jobs:
4444
steps:
4545
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
4646

47-
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
47+
- name: Install uv and set the python version
48+
uses: astral-sh/setup-uv@v5
4849
with:
4950
python-version: '3.13'
5051

51-
- name: Upgrade pip
52-
run: pip install --upgrade pip
53-
54-
- name: Install hatch
55-
run: pip install hatch
52+
- name: Install dependencies
53+
run: uv sync
5654

5755
- name: Build a binary wheel and a source tarball
58-
run: hatch build
56+
run: uv run python -m build
5957

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

CONTRIBUTING.md

Lines changed: 51 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,66 @@ 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.
15+
We use [uv](https://github.com/astral-sh/uv) for fast Python package management and dependency resolution.
1616

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

1919
You will also need to set up the `pre-commit` hooks.
2020
Run `pre-commit install` in the root directory of the repository.
21-
If you don't have `pre-commit` installed, you can install it with `pip install pre-commit`.
21+
If you don't have `pre-commit` installed, you can install it with `uv run pip install pre-commit`.
22+
23+
### Setup Development Environment
24+
25+
1. **Clone the repository:**
26+
```bash
27+
git clone https://github.com/open-feature/python-sdk.git
28+
cd python-sdk
29+
```
30+
31+
2. **Install dependencies:**
32+
```bash
33+
uv sync --extra dev
34+
```
2235

2336
### Testing
2437

25-
Run tests with `hatch run test`.
38+
Run tests with `uv run pytest tests`.
2639

2740
We use `pytest` for our unit testing, making use of `parametrized` to inject cases at scale.
2841

42+
### Coverage
43+
44+
Run coverage tests with:
45+
```bash
46+
uv run coverage run -m pytest tests/
47+
# Generate coverage report
48+
```
49+
50+
### End-to-End Tests
51+
52+
Run e2e tests with behave:
53+
```bash
54+
# Update git submodules and run behave tests
55+
git submodule update --init --recursive
56+
cp spec/specification/assets/gherkin/* tests/features/
57+
uv run behave tests/features/
58+
rm tests/features/*.feature
59+
```
60+
61+
### Code Quality
62+
63+
**Linting and Formatting:**
64+
```bash
65+
uv run ruff check . # Lint code
66+
uv run ruff format . # Format code
67+
```
68+
69+
**Type Checking:**
70+
```bash
71+
uv run mypy openfeature/
72+
```
73+
74+
2975
### Integration tests
3076

3177
These are planned once the SDK has been stabilized and a Flagd provider implemented. At that point, we will utilize the [gherkin integration tests](https://github.com/open-feature/test-harness/blob/main/features/evaluation.feature) to validate against a live, seeded Flagd instance.
@@ -59,7 +105,7 @@ git remote add fork https://github.com/YOUR_GITHUB_USERNAME/python-sdk.git
59105
Ensure your development environment is all set up by building and testing
60106

61107
```bash
62-
hatch run test
108+
uv run pytest tests/
63109
```
64110

65111
To start working on a new feature or bugfix, create a new branch and start working on it.

pyproject.toml

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -27,42 +27,17 @@ requires-python = ">=3.9"
2727
[project.urls]
2828
Homepage = "https://github.com/open-feature/python-sdk"
2929

30-
[tool.hatch]
30+
[tool.hatch.build.targets.wheel]
31+
packages = ["openfeature"]
3132

32-
[tool.hatch.envs.default]
33-
dependencies = [
33+
[project.optional-dependencies]
34+
dev = [
3435
"behave",
3536
"coverage[toml]>=6.5",
3637
"pytest",
3738
"pytest-asyncio"
3839
]
3940

40-
[tool.hatch.envs.default.scripts]
41-
test = "pytest {args:tests}"
42-
test-cov = "coverage run -m pytest {args:tests}"
43-
cov-report = [
44-
"coverage xml",
45-
]
46-
cov = [
47-
"test-cov",
48-
"cov-report",
49-
]
50-
e2e = [
51-
"git submodule update --init --recursive",
52-
"cp spec/specification/assets/gherkin/* tests/features/",
53-
"behave tests/features/",
54-
"rm tests/features/*.feature",
55-
]
56-
57-
[tool.hatch.build.targets.sdist]
58-
exclude = [
59-
".gitignore",
60-
"test-harness",
61-
"venv",
62-
]
63-
64-
[tool.hatch.build.targets.wheel]
65-
packages = ["openfeature"]
6641

6742
[tool.mypy]
6843
files = "openfeature"

0 commit comments

Comments
 (0)