Skip to content

Commit

Permalink
packaging: Use uv to manage this project
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Jan 31, 2025
1 parent b0effe8 commit 86773f1
Show file tree
Hide file tree
Showing 7 changed files with 3,208 additions and 109 deletions.
23 changes: 11 additions & 12 deletions .github/workflows/codspeed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ on:
- "singer_sdk/**"
- "tests/**"
- "noxfile.py"
- "poetry.lock"
- "pyproject.toml"
- "uv.lock"
- ".github/workflows/codspeed.yml"
pull_request:
paths:
- "singer_sdk/**"
- "tests/**"
- "noxfile.py"
- "poetry.lock"
- "pyproject.toml"
- "uv.lock"
- ".github/workflows/codspeed.yml"
# `workflow_dispatch` allows CodSpeed to trigger backtest
# performance analysis in order to generate initial data.
Expand All @@ -41,19 +41,18 @@ jobs:
python-version: 3.x
architecture: x64

- name: Install poetry
run: |
curl -fsS https://install.python-poetry.org | python - -y
- name: Configure poetry
run: poetry config virtualenvs.create false
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: ">=0.5.19"

- name: Install project
run: >
poetry install
-vvv
--with dev
--with benchmark
uv sync
-v
--frozen
--python-preference only-system
--group benchmark
--all-extras
- uses: CodSpeedHQ/action@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ on:
- "singer_sdk/**"
- "tests/**"
- "noxfile.py"
- "poetry.lock"
- "pyproject.toml"
- "uv.lock"
- ".github/workflows/test.yml"
- ".github/workflows/resources/requirements.txt"
push:
Expand All @@ -21,8 +21,8 @@ on:
- "singer_sdk/**"
- "tests/**"
- "noxfile.py"
- "poetry.lock"
- "pyproject.toml"
- "uv.lock"
- ".github/workflows/test.yml"
- ".github/workflows/resources/requirements.txt"
workflow_dispatch:
Expand Down
9 changes: 6 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ ci:
autofix_prs: true
autoupdate_schedule: weekly
autoupdate_commit_msg: 'chore: pre-commit autoupdate'
skip:
- uv-lock

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down Expand Up @@ -58,7 +60,8 @@ repos:
cookiecutter/.*
)$
- repo: https://github.com/python-poetry/poetry
rev: 2.0.1
- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.5.26
hooks:
- id: poetry-check
- id: uv-lock
- id: uv-sync
33 changes: 10 additions & 23 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,45 +14,32 @@ Contributors are expected to follow our [Code of Conduct](https://docs.meltano.c

## Setting up Prereqs

Make sure [`poetry`](https://python-poetry.org/docs/),
Make sure [`uv`](hhttps://docs.astral.sh/uv/),
[`pre-commit`](https://pre-commit.com/) and [`nox`](https://nox.thea.codes/en/stable/)
are installed. You can use [`pipx`](https://pypa.github.io/pipx/) to install
all of them. To install `pipx`:
are installed. Once you have installed `uv`, you can it to install other tools:

```bash
pip3 install pipx
pipx ensurepath
uv tool install pre-commit
uv tool install nox
```

With `pipx` installed, you globally add the required tools:

```bash
pipx install poetry
pipx install pre-commit
pipx install nox
```

Now you can use Poetry to install package dependencies:
Now you can use `uv` to install package dependencies:

```bash
cd sdk
```

```bash
# Install package and dependencies:
poetry install
# OR install in editable mode:
poetry install --no-root
uv sync --all-groups --all-extras
```

## Local Developer Setup

First clone, then...

1. Ensure you have the correct test library, formatters, and linters installed:
- `poetry install`
1. If you are going to update documentation, install the `docs` extras:
- `poetry install -E docs`
- `uv sync --all-groups --all-extras`
1. The project has `pre-commit` hooks. Install them with:
- `pre-commit install`
1. Most development tasks you might need should be covered by `nox` sessions. You can use `nox -l` to list all available tasks.
Expand All @@ -77,8 +64,8 @@ For example:
### If you are using VSCode

1. Make sure you have also installed the `Python` extension.
1. Set interpreter to match poetry's virtualenv: run
`Python: Select interpreter` and select the poetry interpreter.
1. Set interpreter to match uv's managed virtualenv: run
`Python: Select interpreter` and select the interpreter.
1. The [pre-commit extension](https://marketplace.visualstudio.com/items?itemName=MarkLarah.pre-commit-vscode)
will allow to run pre-commit hooks on the current file from the VSCode command palette.

Expand Down Expand Up @@ -151,7 +138,7 @@ nox -rs update_snapshots
or use the `--snapshot-update` flag

```bash
poetry run pytest --snapshot-update -m 'snapshot'
uv run pytest --snapshot-update -m 'snapshot'
```

This will run all tests with the `snapshot` marker and update any snapshots that have changed.
Expand Down
20 changes: 0 additions & 20 deletions docs/Makefile

This file was deleted.

88 changes: 39 additions & 49 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,8 @@ s3 = [
]

# Parquet file dependencies installed as optional 'parquet' extras
# We add Python constraints to force Poetry to add the latest supported Numpy version
# for all Python versions to 'poetry.lock'. If we don't do this, Poetry will add only
# the version of Numpy that is compatible with the earliest Python version supported
# by this project, but that may not be compatible with the latest Python version.
parquet = [
"numpy>=1.22,<2.1; python_version=='3.9'",
"numpy>=1.22; python_version>='3.10'",
"numpy>=1.22",
"pyarrow>=13",
]

Expand Down Expand Up @@ -120,42 +115,38 @@ Documentation = "https://sdk.meltano.com/en/latest/"
"Slack" = "https://meltano.com/slack"
"Youtube" = "https://www.youtube.com/meltano"

[tool.poetry]
requires-poetry = ">=2.0"
version = "0.0.0"

[tool.poetry.requires-plugins]
poetry-dynamic-versioning = { version = ">=1.0.0,<2.0.0", extras = ["plugin"] }

[tool.poetry.group.dev.dependencies]
coverage = {extras = ["toml"], version = ">=7.4"}
deptry = ">=0.15.0"

duckdb = ">=0.8.0"
duckdb-engine = { version = ">=0.9.4", python = "<4" }

fastjsonschema = ">=2.19.1"
moto = ">=5.0.14"
pytest-benchmark = ">=4.0.0"
pytest-snapshot = ">=0.9.0"
pytest-subtests = ">=0.13.1"
pytz = ">=2022.2.1"
requests-cache = ">=1.2.1"
requests-mock = ">=1.10.0"
rfc3339-validator = ">=0.1.4"
time-machine = ">=2.10.0"
xdoctest = ">=1.1.1"

[tool.poetry.group.typing.dependencies]
mypy = ">=1.9"
types-jsonschema = ">=4.17.0.6"
types-pytz = ">=2022.7.1.2"
types-requests = ">=2.28.11"
types-simplejson = ">=3.18.0"
types-PyYAML = ">=6.0.12"

[tool.poetry.group.benchmark.dependencies]
pytest-codspeed = ">=2.2.0"
[dependency-groups]
dev = [
"coverage[toml]>=7.4",
"deptry>=0.15.0",
"duckdb>=0.8.0",
"duckdb-engine>=0.9.4; python_version<'4'",
"fastjsonschema>=2.19.1",
"moto>=5.0.14",
"pytest-benchmark>=4.0.0",
"pytest-snapshot>=0.9.0",
"pytest-subtests>=0.13.1",
"pytz>=2022.2.1",
"requests-cache>=1.2.1",
"requests-mock>=1.10.0",
"rfc3339-validator>=0.1.4",
"time-machine>=2.10.0",
"xdoctest>=1.1.1",
]
typing = [
"mypy>=1.9",
"types-jsonschema>=4.17.0.6",
"types-pytz>=2022.7.1.2",
"types-requests>=2.28.11",
"types-simplejson>=3.18.0",
"types-PyYAML>=6.0.12",
]
benchmark = [
"pytest-codspeed>=2.2.0",
]

[tool.hatch.version]
source = "vcs"

[tool.pytest.ini_options]
addopts = [
Expand Down Expand Up @@ -284,16 +275,12 @@ module = [
"pyarrow.*", # TODO: Remove when https://github.com/apache/arrow/issues/32609 if implemented and released
]

[tool.poetry-dynamic-versioning]
enable = true
style = "pep440"

[build-system]
requires = [
"poetry-core>=2,<3",
"poetry-dynamic-versioning",
"hatchling==1.27",
"hatch-vcs==0.4",
]
build-backend = "poetry_dynamic_versioning.backend"
build-backend = "hatchling.build"

[project.entry-points."pytest11"]
singer_testing = "singer_sdk.testing.pytest_plugin"
Expand Down Expand Up @@ -432,3 +419,6 @@ convention = "google"

[tool.ruff.lint.pylint]
max-args = 9

[tool.uv]
required-version = ">=0.5.19"
Loading

0 comments on commit 86773f1

Please sign in to comment.