Skip to content

chore: Migrate to uv #538

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 5, 2025
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
26 changes: 15 additions & 11 deletions .github/workflows/ci_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
paths:
- docker-compose.yml
- pyproject.toml
- poetry.lock
- uv.lock
- target_postgres/**
- .github/workflows/ci_workflow.yml
- .github/workflows/constraints.txt
Expand All @@ -15,7 +15,7 @@ on:
paths:
- docker-compose.yml
- pyproject.toml
- poetry.lock
- uv.lock
- target_postgres/**
- .github/workflows/ci_workflow.yml
- .github/workflows/constraints.txt
Expand Down Expand Up @@ -82,12 +82,15 @@ jobs:
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: '${{ matrix.python-version }}'
- name: Install Tox
- name: Set up uv
uses: astral-sh/setup-uv@v6
with:
version: ">=0.7"
- name: Install tools
env:
PIP_CONSTRAINT: ${{ github.workspace }}/.github/workflows/constraints.txt
UV_CONSTRAINT: ${{ github.workspace }}/.github/workflows/constraints.txt
run: |
python -m pip install --upgrade pip
pipx install tox
uv tool install --with tox-uv tox
- name: Run pytest
env:
TARGET_POSTGRES_USE_COPY: ${{ matrix.use-copy }}
Expand Down Expand Up @@ -122,12 +125,13 @@ jobs:
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: 3.x
- name: Install dependencies
env:
PIP_CONSTRAINT: ${{ github.workspace }}/.github/workflows/constraints.txt
- name: Set up uv
uses: astral-sh/setup-uv@v6
with:
version: ">=0.7"
- name: Install Meltano
run: |
python -m pip install --upgrade pip
pipx install meltano
uv tool install meltano
meltano --version
- name: smoke-test-tap
env:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/constraints.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
meltano==3.7.4
tox==4.25.0
tox-uv==1.25.0
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,13 @@ tap-carbon-intensity | target-postgres --config /path/to/target-postgres-config.

### Initialize your Development Environment

Prerequisites:

- Python 3.9+
- [uv](https://docs.astral.sh/uv/)

```bash
pipx install poetry
poetry install
pipx install pre-commit
uv tool install pre-commit
pre-commit install
```

Expand Down Expand Up @@ -197,13 +200,13 @@ Create tests within the `target_postgres/tests` subfolder and
then run:

```bash
poetry run pytest
uv run pytest
```

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

```bash
poetry run target-postgres --help
uv run target-postgres --help
```

### Testing with [Meltano](https://meltano.com/)
Expand Down
2,043 changes: 0 additions & 2,043 deletions poetry.lock

This file was deleted.

98 changes: 53 additions & 45 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
[tool.poetry]
[project]
name = "meltanolabs-target-postgres"
version = "0.0.0"
dynamic = ["version"]
description = "Singer target for Postgres, built with the Meltano SDK for Singer Targets."
authors = ["Meltano Team and Contributors <hello@meltano.com>"]
maintainers = ["Meltano Team and Contributors <hello@meltano.com>"]
license = "MIT"
authors = [{ name = "Meltano Team and Contributors", email = "hello@meltano.com" }]
requires-python = ">=3.9"
readme = "README.md"
homepage = "https://meltano.com"
repository = "https://github.com/MeltanoLabs/target-postgres"
documentation = "https://github.com/MeltanoLabs/target-postgres/blob/main/README.md"
license = "MIT"
maintainers = [{ name = "Meltano Team and Contributors", email = "hello@meltano.com" }]
keywords = [
"Postgres",
"Singer",
Expand All @@ -27,34 +25,53 @@ classifiers = [
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: Implementation :: CPython",
]
packages = [
{ include = "target_postgres" }
dependencies = [
"psycopg[binary]==3.2.7",
"psycopg2-binary==2.9.10",
"sqlalchemy~=2.0",
"sshtunnel==0.4.0",
"singer-sdk~=0.45.3",
]

[tool.poetry.dependencies]
python = ">=3.9"
faker = {version = "~=37.1", optional = true}
psycopg = {extras = ["binary"], version = "3.2.7"}
psycopg2-binary = "2.9.10"
sqlalchemy = "~=2.0"
sshtunnel = "0.4.0"
[project.optional-dependencies]
faker = ["faker~=37.1"]

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

[tool.poetry.extras]
faker = ["faker"]
[project.scripts]
target-postgres = "target_postgres.target:TargetPostgres.cli"

[dependency-groups]
dev = [
{ include-group = "testing" },
{ include-group = "typing" },
"remote-pdb>=2.1.0",
]
lint = [
"ruff>=0.1.14",
]
testing = [
"pytest>=7.4.2",
]
typing = [
"mypy>=1.6.1",
"types-paramiko>=3.3.0.0",
"types-simplejson>=3.19.0.2",
"types-sqlalchemy>=1.4.53.38",
"types-jsonschema>=4.19.0.3",
]

[tool.poetry.group.dev.dependencies]
pytest = ">=7.4.2"
mypy = ">=1.6.1"
remote-pdb = ">=2.1.0"
ruff = ">=0.1.14"
tox = ">=4"
types-paramiko = ">=3.3.0.0"
types-simplejson = ">=3.19.0.2"
types-sqlalchemy = ">=1.4.53.38"
types-jsonschema = ">=4.19.0.3"
[tool.hatch.version]
source = "vcs"

[tool.hatch.build.targets.sdist]
include = ["target_postgres"]

[tool.hatch.build.targets.wheel]
include = ["target_postgres"]

[tool.mypy]
exclude = "tests"
Expand All @@ -67,26 +84,17 @@ module = ["sshtunnel"]
ignore_missing_imports = true

[build-system]
requires = ["poetry-core==2.1.1", "poetry-dynamic-versioning==1.7.1"]
build-backend = "poetry_dynamic_versioning.backend"

[tool.poetry.scripts]
# CLI declaration
target-postgres = 'target_postgres.target:TargetPostgres.cli'
requires = [
"hatchling==1.27.0",
"hatch-vcs==0.4.0",
]
build-backend = "hatchling.build"

[tool.pytest.ini_options]
pythonpath = [
"."
]

[tool.poetry-dynamic-versioning]
enable = true
vcs = "git"
style = "semver"

[tool.ruff]
target-version = "py39"

[tool.ruff.lint]
select = [
"F", # Pyflakes
Expand Down
6 changes: 3 additions & 3 deletions target_postgres/tests/samples/aapl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ This tap sample helps in evaluating the performance of catalog parsing and strea
## Execution

```shell
poetry run python samples/aapl
uv run python samples/aapl
```

Or if you want to trace the execution

```shell
poetry run viztracer samples/aapl/__main__.py
poetry run vizviewer result.json
uv run viztracer samples/aapl/__main__.py
uv run vizviewer result.json
```
2 changes: 1 addition & 1 deletion target_postgres/tests/samples/aapl/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Run:

$ poetry run python samples/aapl
$ uv run python samples/aapl
"""

from aapl import Fundamentals
Expand Down
25 changes: 11 additions & 14 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,34 @@ envlist =
lint
isolated_build = true
min_version = 4
requires =
tox>=4.22
tox-uv

[testenv]
# Run the python tests.
# To execute, run `tox -e 3.13`
envlist = 3.{9,10,11,12,13}
runner = uv-venv-lock-runner
pass_env =
TARGET_POSTGRES_*
deps =
pytest
dependency_groups =
testing
commands =
pytest

[testenv:format]
# Attempt to auto-resolve lint errors before they are raised.
# To execute, run `tox -e format`
deps =
ruff
dependency_groups =
lint
commands =
ruff check target_postgres/
ruff format target_postgres/

[testenv:lint]
# Raise an error if lint and style standards are not met.
# To execute, run `tox -e lint`
deps =
mypy
ruff
types-paramiko
types-simplejson
types-sqlalchemy
types-jsonschema
dependency_groups =
lint
typing
commands =
ruff check --diff target_postgres/
ruff format --check target_postgres/
Expand Down
Loading