Skip to content

Commit 6935c37

Browse files
chore: Migrate to uv (#538)
- Closes #530
1 parent 65304e8 commit 6935c37

File tree

9 files changed

+1546
-2123
lines changed

9 files changed

+1546
-2123
lines changed

.github/workflows/ci_workflow.yml

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
paths:
77
- docker-compose.yml
88
- pyproject.toml
9-
- poetry.lock
9+
- uv.lock
1010
- target_postgres/**
1111
- .github/workflows/ci_workflow.yml
1212
- .github/workflows/constraints.txt
@@ -15,7 +15,7 @@ on:
1515
paths:
1616
- docker-compose.yml
1717
- pyproject.toml
18-
- poetry.lock
18+
- uv.lock
1919
- target_postgres/**
2020
- .github/workflows/ci_workflow.yml
2121
- .github/workflows/constraints.txt
@@ -82,12 +82,15 @@ jobs:
8282
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
8383
with:
8484
python-version: '${{ matrix.python-version }}'
85-
- name: Install Tox
85+
- name: Set up uv
86+
uses: astral-sh/setup-uv@v6
87+
with:
88+
version: ">=0.7"
89+
- name: Install tools
8690
env:
87-
PIP_CONSTRAINT: ${{ github.workspace }}/.github/workflows/constraints.txt
91+
UV_CONSTRAINT: ${{ github.workspace }}/.github/workflows/constraints.txt
8892
run: |
89-
python -m pip install --upgrade pip
90-
pipx install tox
93+
uv tool install --with tox-uv tox
9194
- name: Run pytest
9295
env:
9396
TARGET_POSTGRES_USE_COPY: ${{ matrix.use-copy }}
@@ -122,12 +125,13 @@ jobs:
122125
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
123126
with:
124127
python-version: 3.x
125-
- name: Install dependencies
126-
env:
127-
PIP_CONSTRAINT: ${{ github.workspace }}/.github/workflows/constraints.txt
128+
- name: Set up uv
129+
uses: astral-sh/setup-uv@v6
130+
with:
131+
version: ">=0.7"
132+
- name: Install Meltano
128133
run: |
129-
python -m pip install --upgrade pip
130-
pipx install meltano
134+
uv tool install meltano
131135
meltano --version
132136
- name: smoke-test-tap
133137
env:

.github/workflows/constraints.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
meltano==3.7.4
22
tox==4.25.0
3+
tox-uv==1.25.0

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,13 @@ tap-carbon-intensity | target-postgres --config /path/to/target-postgres-config.
150150

151151
### Initialize your Development Environment
152152

153+
Prerequisites:
154+
155+
- Python 3.9+
156+
- [uv](https://docs.astral.sh/uv/)
157+
153158
```bash
154-
pipx install poetry
155-
poetry install
156-
pipx install pre-commit
159+
uv tool install pre-commit
157160
pre-commit install
158161
```
159162

@@ -197,13 +200,13 @@ Create tests within the `target_postgres/tests` subfolder and
197200
then run:
198201

199202
```bash
200-
poetry run pytest
203+
uv run pytest
201204
```
202205

203-
You can also test the `target-postgres` CLI interface directly using `poetry run`:
206+
You can also test the `target-postgres` CLI interface directly using `uv run`:
204207

205208
```bash
206-
poetry run target-postgres --help
209+
uv run target-postgres --help
207210
```
208211

209212
### Testing with [Meltano](https://meltano.com/)

poetry.lock

Lines changed: 0 additions & 2043 deletions
This file was deleted.

pyproject.toml

Lines changed: 53 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
[tool.poetry]
1+
[project]
22
name = "meltanolabs-target-postgres"
3-
version = "0.0.0"
3+
dynamic = ["version"]
44
description = "Singer target for Postgres, built with the Meltano SDK for Singer Targets."
5-
authors = ["Meltano Team and Contributors <hello@meltano.com>"]
6-
maintainers = ["Meltano Team and Contributors <hello@meltano.com>"]
7-
license = "MIT"
5+
authors = [{ name = "Meltano Team and Contributors", email = "hello@meltano.com" }]
6+
requires-python = ">=3.9"
87
readme = "README.md"
9-
homepage = "https://meltano.com"
10-
repository = "https://github.com/MeltanoLabs/target-postgres"
11-
documentation = "https://github.com/MeltanoLabs/target-postgres/blob/main/README.md"
8+
license = "MIT"
9+
maintainers = [{ name = "Meltano Team and Contributors", email = "hello@meltano.com" }]
1210
keywords = [
1311
"Postgres",
1412
"Singer",
@@ -27,34 +25,53 @@ classifiers = [
2725
"Programming Language :: Python :: 3.13",
2826
"Programming Language :: Python :: Implementation :: CPython",
2927
]
30-
packages = [
31-
{ include = "target_postgres" }
28+
dependencies = [
29+
"psycopg[binary]==3.2.7",
30+
"psycopg2-binary==2.9.10",
31+
"sqlalchemy~=2.0",
32+
"sshtunnel==0.4.0",
33+
"singer-sdk~=0.45.3",
3234
]
3335

34-
[tool.poetry.dependencies]
35-
python = ">=3.9"
36-
faker = {version = "~=37.1", optional = true}
37-
psycopg = {extras = ["binary"], version = "3.2.7"}
38-
psycopg2-binary = "2.9.10"
39-
sqlalchemy = "~=2.0"
40-
sshtunnel = "0.4.0"
36+
[project.optional-dependencies]
37+
faker = ["faker~=37.1"]
4138

42-
[tool.poetry.dependencies.singer-sdk]
43-
version = "~=0.45.3"
39+
[project.urls]
40+
Homepage = "https://meltano.com"
41+
Repository = "https://github.com/MeltanoLabs/target-postgres"
42+
Documentation = "https://github.com/MeltanoLabs/target-postgres/blob/main/README.md"
4443

45-
[tool.poetry.extras]
46-
faker = ["faker"]
44+
[project.scripts]
45+
target-postgres = "target_postgres.target:TargetPostgres.cli"
46+
47+
[dependency-groups]
48+
dev = [
49+
{ include-group = "testing" },
50+
{ include-group = "typing" },
51+
"remote-pdb>=2.1.0",
52+
]
53+
lint = [
54+
"ruff>=0.1.14",
55+
]
56+
testing = [
57+
"pytest>=7.4.2",
58+
]
59+
typing = [
60+
"mypy>=1.6.1",
61+
"types-paramiko>=3.3.0.0",
62+
"types-simplejson>=3.19.0.2",
63+
"types-sqlalchemy>=1.4.53.38",
64+
"types-jsonschema>=4.19.0.3",
65+
]
4766

48-
[tool.poetry.group.dev.dependencies]
49-
pytest = ">=7.4.2"
50-
mypy = ">=1.6.1"
51-
remote-pdb = ">=2.1.0"
52-
ruff = ">=0.1.14"
53-
tox = ">=4"
54-
types-paramiko = ">=3.3.0.0"
55-
types-simplejson = ">=3.19.0.2"
56-
types-sqlalchemy = ">=1.4.53.38"
57-
types-jsonschema = ">=4.19.0.3"
67+
[tool.hatch.version]
68+
source = "vcs"
69+
70+
[tool.hatch.build.targets.sdist]
71+
include = ["target_postgres"]
72+
73+
[tool.hatch.build.targets.wheel]
74+
include = ["target_postgres"]
5875

5976
[tool.mypy]
6077
exclude = "tests"
@@ -67,26 +84,17 @@ module = ["sshtunnel"]
6784
ignore_missing_imports = true
6885

6986
[build-system]
70-
requires = ["poetry-core==2.1.1", "poetry-dynamic-versioning==1.7.1"]
71-
build-backend = "poetry_dynamic_versioning.backend"
72-
73-
[tool.poetry.scripts]
74-
# CLI declaration
75-
target-postgres = 'target_postgres.target:TargetPostgres.cli'
87+
requires = [
88+
"hatchling==1.27.0",
89+
"hatch-vcs==0.4.0",
90+
]
91+
build-backend = "hatchling.build"
7692

7793
[tool.pytest.ini_options]
7894
pythonpath = [
7995
"."
8096
]
8197

82-
[tool.poetry-dynamic-versioning]
83-
enable = true
84-
vcs = "git"
85-
style = "semver"
86-
87-
[tool.ruff]
88-
target-version = "py39"
89-
9098
[tool.ruff.lint]
9199
select = [
92100
"F", # Pyflakes

target_postgres/tests/samples/aapl/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ This tap sample helps in evaluating the performance of catalog parsing and strea
55
## Execution
66

77
```shell
8-
poetry run python samples/aapl
8+
uv run python samples/aapl
99
```
1010

1111
Or if you want to trace the execution
1212

1313
```shell
14-
poetry run viztracer samples/aapl/__main__.py
15-
poetry run vizviewer result.json
14+
uv run viztracer samples/aapl/__main__.py
15+
uv run vizviewer result.json
1616
```

target_postgres/tests/samples/aapl/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
Run:
44
5-
$ poetry run python samples/aapl
5+
$ uv run python samples/aapl
66
"""
77

88
from aapl import Fundamentals

tox.ini

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,34 @@ envlist =
77
lint
88
isolated_build = true
99
min_version = 4
10+
requires =
11+
tox>=4.22
12+
tox-uv
1013

1114
[testenv]
12-
# Run the python tests.
13-
# To execute, run `tox -e 3.13`
14-
envlist = 3.{9,10,11,12,13}
15+
runner = uv-venv-lock-runner
1516
pass_env =
1617
TARGET_POSTGRES_*
17-
deps =
18-
pytest
18+
dependency_groups =
19+
testing
1920
commands =
2021
pytest
2122

2223
[testenv:format]
2324
# Attempt to auto-resolve lint errors before they are raised.
2425
# To execute, run `tox -e format`
25-
deps =
26-
ruff
26+
dependency_groups =
27+
lint
2728
commands =
2829
ruff check target_postgres/
2930
ruff format target_postgres/
3031

3132
[testenv:lint]
3233
# Raise an error if lint and style standards are not met.
3334
# To execute, run `tox -e lint`
34-
deps =
35-
mypy
36-
ruff
37-
types-paramiko
38-
types-simplejson
39-
types-sqlalchemy
40-
types-jsonschema
35+
dependency_groups =
36+
lint
37+
typing
4138
commands =
4239
ruff check --diff target_postgres/
4340
ruff format --check target_postgres/

0 commit comments

Comments
 (0)