From f04ab2506123aec95487404aadc40b6f570ee62a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Ram=C3=ADrez-Mondrag=C3=B3n?= Date: Fri, 31 Jan 2025 09:31:10 -0600 Subject: [PATCH] fix: Use uv in tap, target and mapper templates --- .github/workflows/cookiecutter-e2e.yml | 9 +-- .../{{cookiecutter.mapper_id}}/pyproject.toml | 51 +++++++------ .../{{cookiecutter.tap_id}}/pyproject.toml | 71 ++++++++++--------- .../{{cookiecutter.target_id}}/pyproject.toml | 57 ++++++++------- noxfile.py | 4 +- 5 files changed, 100 insertions(+), 92 deletions(-) diff --git a/.github/workflows/cookiecutter-e2e.yml b/.github/workflows/cookiecutter-e2e.yml index 21b08bff0..bd3cf756c 100644 --- a/.github/workflows/cookiecutter-e2e.yml +++ b/.github/workflows/cookiecutter-e2e.yml @@ -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: diff --git a/cookiecutter/mapper-template/{{cookiecutter.mapper_id}}/pyproject.toml b/cookiecutter/mapper-template/{{cookiecutter.mapper_id}}/pyproject.toml index b2a7ce578..7567c5ae2 100644 --- a/cookiecutter/mapper-template/{{cookiecutter.mapper_id}}/pyproject.toml +++ b/cookiecutter/mapper-template/{{cookiecutter.mapper_id}}/pyproject.toml @@ -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 = [ @@ -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 @@ -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" diff --git a/cookiecutter/tap-template/{{cookiecutter.tap_id}}/pyproject.toml b/cookiecutter/tap-template/{{cookiecutter.tap_id}}/pyproject.toml index f376111e4..ba30048aa 100644 --- a/cookiecutter/tap-template/{{cookiecutter.tap_id}}/pyproject.toml +++ b/cookiecutter/tap-template/{{cookiecutter.tap_id}}/pyproject.toml @@ -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}}" @@ -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 = [ @@ -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" diff --git a/cookiecutter/target-template/{{cookiecutter.target_id}}/pyproject.toml b/cookiecutter/target-template/{{cookiecutter.target_id}}/pyproject.toml index 8975b9a99..17b5bbea8 100644 --- a/cookiecutter/target-template/{{cookiecutter.target_id}}/pyproject.toml +++ b/cookiecutter/target-template/{{cookiecutter.target_id}}/pyproject.toml @@ -25,36 +25,43 @@ 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 %} + {%- if cookiecutter.serialization_method != "SQL" %} + "requests~=2.32.3", + {%- 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 } -{%- if cookiecutter.serialization_method != "SQL" %} -requests = "~=2.32.3" -{%- endif %} +[project.scripts] +# CLI declaration +{{cookiecutter.target_id}} = '{{cookiecutter.library_name}}.target:Target{{ cookiecutter.destination_name }}.cli' -[tool.poetry.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.mypy] python_version = "3.12" warn_unused_configs = true -[tool.ruff] -target-version = "py39" - [tool.ruff.lint] ignore = [ "COM812", # missing-trailing-comma @@ -68,9 +75,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.target_id}} = '{{cookiecutter.library_name}}.target:Target{{ cookiecutter.destination_name }}.cli' +requires = [ + "hatchling>=1,<2", +] +build-backend = "hatchling.build" diff --git a/noxfile.py b/noxfile.py index ca87ceb3a..30648e131 100644 --- a/noxfile.py +++ b/noxfile.py @@ -241,8 +241,8 @@ def test_cookiecutter(session: nox.Session, replay_file_path: str) -> None: + '", develop = true \\}|', "pyproject.toml", ) - session.run("poetry", "lock", external=True) - session.run("poetry", "install", external=True) + session.run("uv", "lock", external=True) + session.run("uv", "sync", external=True) session.run("git", "init", "-b", "main", external=True) session.run("git", "add", ".", external=True)