Skip to content
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

fix: Use uv in tap, target and mapper templates #2859

Merged
merged 1 commit into from
Jan 31, 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
16 changes: 8 additions & 8 deletions .github/workflows/cookiecutter-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,7 @@ jobs:

- uses: astral-sh/setup-uv@v5
with:
version: ">=0.4.30"

- name: Install Poetry
env:
UV_CONSTRAINT: ${{ github.workspace }}/.github/workflows/resources/requirements.txt
run: |
uv tool install poetry
poetry --version
version: ">=0.5.19"

- uses: actions/setup-python@v5
with:
Expand All @@ -53,6 +46,13 @@ jobs:
uv tool install --with=pre-commit-uv pre-commit
pre-commit --version

- name: Install twine
env:
UV_CONSTRAINT: ${{ github.workspace }}/.github/workflows/resources/requirements.txt
run: |
uv tool install twine
twine --version

- name: Install Nox
env:
UV_CONSTRAINT: ${{ github.workspace }}/.github/workflows/resources/requirements.txt
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/resources/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
griffe~=1.5
nox==2024.10.9
pip==25.0
poetry==2.0.1
pre-commit==4.1.0
nox==2024.10.9
twine==6.1.0
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ on:
- .github/workflows/test.yml
- {{ cookiecutter.library_name }}/**
- tests/**
- poetry.lock
- pyproject.toml
- uv.lock
- tox.ini
pull_request:
branches: [main]
paths:
- .github/workflows/test.yml
- {{ cookiecutter.library_name }}/**
- tests/**
- poetry.lock
- pyproject.toml
- uv.lock
- tox.ini
workflow_dispatch:

Expand Down
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 @@ -34,3 +36,9 @@ repos:
rev: v1.14.1
hooks:
- id: mypy

- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.5.26
hooks:
- id: uv-lock
- id: uv-sync
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,13 @@ Follow these instructions to contribute to this project.

### Initialize your Development Environment

Prerequisites:

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

```bash
pipx install poetry
poetry install
uv sync
```

### Create and Run Tests
Expand All @@ -85,13 +89,13 @@ Create tests within the `tests` subfolder and
then run:

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

You can also test the `{{cookiecutter.mapper_id}}` CLI interface directly using `poetry run`:
You can also test the `{{cookiecutter.mapper_id}}` CLI interface directly using `uv run`:

```bash
poetry run {{cookiecutter.mapper_id}} --help
uv run {{cookiecutter.mapper_id}} --help
```

### Testing with [Meltano](https://www.meltano.com)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,35 @@ classifiers = [
license = "Apache-2.0"
license-files = [ "LICENSE" ]
requires-python = ">=3.9"
dynamic = ["dependencies"]
dependencies = [
{%- if cookiecutter.faker_extra %}
"singer-sdk[faker]~=0.44.1",
{%- else %}
"singer-sdk~=0.44.1",
{%- endif %}
]

[tool.poetry]
{%- if cookiecutter.variant != "None (Skip)" %}
packages = [
{ include = "{{cookiecutter.library_name}}" },
[project.optional-dependencies]
s3 = [
"fs-s3fs~=1.1.1",
]
{%- endif %}

[tool.poetry.dependencies]
singer-sdk = { version="~=0.44.1"{{ ', extras = ["faker"]' if cookiecutter.faker_extra }} }
fs-s3fs = { version = "~=1.1.1", optional = true }
[project.scripts]
# CLI declaration
{{cookiecutter.mapper_id}} = '{{cookiecutter.library_name}}.mapper:{{cookiecutter.name}}Mapper.cli'

[tool.poetry.group.dev.dependencies]
pytest = ">=8"
singer-sdk = { version="~=0.44.1", extras = ["testing"] }
[dependency-groups]
dev = [
"pytest>=8",
"singer-sdk[testing]~=0.44.1",
]

[tool.poetry.extras]
s3 = ["fs-s3fs"]
{%- if cookiecutter.variant != "None (Skip)" %}
[tool.hatch.build.targets.wheel]
packages = [
"{{cookiecutter.library_name}}",
]
{%- endif %}

[tool.pytest.ini_options]
addopts = [
Expand All @@ -55,9 +65,6 @@ addopts = [
python_version = "3.12"
warn_unused_configs = true

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

[tool.ruff.lint]
ignore = [
"COM812", # missing-trailing-comma
Expand All @@ -71,9 +78,7 @@ allow-star-arg-any = true
convention = "google"

[build-system]
requires = ["poetry-core>=2,<3"]
build-backend = "poetry.core.masonry.api"

[tool.poetry.scripts]
# CLI declaration
{{cookiecutter.mapper_id}} = '{{cookiecutter.library_name}}.mapper:{{cookiecutter.name}}Mapper.cli'
requires = [
"hatchling>=1,<2",
]
build-backend = "hatchling.build"
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ on:
- .github/workflows/test.yml
- {{ cookiecutter.library_name }}/**
- tests/**
- poetry.lock
- pyproject.toml
- uv.lock
- tox.ini
pull_request:
branches: [main]
paths:
- .github/workflows/test.yml
- {{ cookiecutter.library_name }}/**
- tests/**
- poetry.lock
- pyproject.toml
- uv.lock
- tox.ini
workflow_dispatch:

Expand Down
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 @@ -40,3 +42,9 @@ repos:
{%- else %}
- types-requests
{%- endif %}

- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.5.26
hooks:
- id: uv-lock
- id: uv-sync
14 changes: 9 additions & 5 deletions cookiecutter/tap-template/{{cookiecutter.tap_id}}/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,13 @@ Follow these instructions to contribute to this project.

### Initialize your Development Environment

Prerequisites:

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

```bash
pipx install poetry
poetry install
uv sync
```

### Create and Run Tests
Expand All @@ -86,13 +90,13 @@ Create tests within the `tests` subfolder and
then run:

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

You can also test the `{{cookiecutter.tap_id}}` CLI interface directly using `poetry run`:
You can also test the `{{cookiecutter.tap_id}}` CLI interface directly using `uv run`:

```bash
poetry run {{cookiecutter.tap_id}} --help
uv run {{cookiecutter.tap_id}} --help
```

### Testing with [Meltano](https://www.meltano.com)
Expand Down
71 changes: 38 additions & 33 deletions cookiecutter/tap-template/{{cookiecutter.tap_id}}/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{%- set extras = [] -%}
{%- if cookiecutter.faker_extra -%}{%- set extras = extras + ["faker"] -%}{%- endif -%}
{%- if cookiecutter.auth_method == "JWT" -%}{%- set extras = extras + ["jwt"] -%}{%- endif -%}

[project]
{%- if cookiecutter.variant != "None (Skip)" %}
name = "{{cookiecutter.variant}}-{{cookiecutter.tap_id}}"
Expand Down Expand Up @@ -25,38 +29,41 @@ classifiers = [
license = "Apache-2.0"
license-files = [ "LICENSE" ]
requires-python = ">=3.9"
dynamic = ["dependencies"]
dependencies = [
{%- if extras %}
"singer-sdk[{{ extras|join(',') }}]~=0.44.1",
{%- else %}
"singer-sdk~=0.44.1",
{%- endif %}
{%- if cookiecutter.stream_type in ["REST", "GraphQL"] %}
"requests~=2.32.3",
{%- endif %}
{%- if cookiecutter.stream_type == "SQL" %}
"sqlalchemy~=2.0.36",
{%- endif %}
]

[tool.poetry]
{%- if cookiecutter.variant != "None (Skip)" %}
packages = [
{ include = "{{cookiecutter.library_name}}" },
[project.optional-dependencies]
s3 = [
"fs-s3fs~=1.1.1",
]
{%- endif %}

[tool.poetry.dependencies]
singer-sdk = { version="~=0.44.1", extras = [
{%- if cookiecutter.auth_method == "JWT" -%}"jwt", {% endif -%}
{%- if cookiecutter.faker_extra -%}"faker",{%- endif -%}
] }
fs-s3fs = { version = "~=1.1.1", optional = true }
{%- if cookiecutter.stream_type in ["REST", "GraphQL"] %}
requests = "~=2.32.3"
{%- endif %}
{%- if cookiecutter.stream_type == "SQL" %}
sqlalchemy = "~=2.0.36"
{%- endif %}
[project.scripts]
# CLI declaration
{{cookiecutter.tap_id}} = '{{cookiecutter.library_name}}.tap:Tap{{cookiecutter.source_name}}.cli'

[tool.poetry.group.dev.dependencies]
pytest = ">=8"
{%- if cookiecutter.auth_method == "JWT" %}
singer-sdk = { version="~=0.44.1", extras = ["jwt", "testing"] }
{%- else %}
singer-sdk = { version="~=0.44.1", extras = ["testing"] }
{%- endif %}
[dependency-groups]
dev = [
"pytest>=8",
"singer-sdk[testing]~=0.44.1",
]

[tool.poetry.extras]
s3 = ["fs-s3fs"]
{%- if cookiecutter.variant != "None (Skip)" %}
[tool.hatch.build.targets.wheel]
packages = [
"{{cookiecutter.library_name}}",
]
{%- endif %}

[tool.pytest.ini_options]
addopts = [
Expand Down Expand Up @@ -88,9 +95,7 @@ allow-star-arg-any = true
convention = "google"

[build-system]
requires = ["poetry-core>=2,<3"]
build-backend = "poetry.core.masonry.api"

[tool.poetry.scripts]
# CLI declaration
{{cookiecutter.tap_id}} = '{{cookiecutter.library_name}}.tap:Tap{{cookiecutter.source_name}}.cli'
requires = [
"hatchling>=1,<2",
]
build-backend = "hatchling.build"
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ on:
- .github/workflows/test.yml
- {{ cookiecutter.library_name }}/**
- tests/**
- poetry.lock
- pyproject.toml
- uv.lock
- tox.ini
pull_request:
branches: [main]
paths:
- .github/workflows/test.yml
- {{ cookiecutter.library_name }}/**
- tests/**
- poetry.lock
- pyproject.toml
- uv.lock
- tox.ini
workflow_dispatch:

Expand Down
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 @@ -40,3 +42,9 @@ repos:
{%- else %}
- types-requests
{%- endif %}

- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.5.26
hooks:
- id: uv-lock
- id: uv-sync
Loading