From 9b8b82a56c26839fdbd703fae19908b8c0c83b49 Mon Sep 17 00:00:00 2001 From: Josh Markovic Date: Thu, 14 May 2026 13:56:01 +0000 Subject: [PATCH 1/5] Modernize packaging: migrate setup.py to PEP 621 pyproject.toml - Replace setup.py with pyproject.toml (setuptools backend), reading version dynamically from dbt/adapters/sqlserver/__version__.py. - Restore pyodbc>=4.0.35,<5.2.0 as a direct dependency. It was previously pulled in transitively via dbt-fabric; that dep was dropped in 1.9.1rc1 but the runtime `import pyodbc` was not, leaving fresh installs broken. - Move azure-identity to an `azure` extra. The code already guards azure imports with try/except ModuleNotFoundError, so this makes the optionality first-class: pip install dbt-sqlserver[azure]. - Move dev tooling to a `dev` extra; retire dev_requirements.txt. Use pip install -e .[dev]. - Drop MANIFEST.in in favor of [tool.setuptools.package-data]. - Ship dbt/adapters/sqlserver/py.typed. - requires-python = ">=3.10"; drop the Python 3.9 classifier (3.9 reached EOL in October 2025). - Update unit/integration/release workflows + Makefile accordingly. The release workflow now uses `python -m build` and an inline tag/version match instead of `python setup.py sdist bdist_wheel` and the old VerifyVersionCommand. --- .../workflows/integration-tests-sqlserver.yml | 4 +- .github/workflows/release-version.yml | 28 ++++-- .github/workflows/unit-tests.yml | 4 +- MANIFEST.in | 1 - Makefile | 2 +- dbt/adapters/sqlserver/py.typed | 0 dev_requirements.txt | 24 ----- pyproject.toml | 77 +++++++++++++++ setup.py | 94 ------------------- 9 files changed, 104 insertions(+), 130 deletions(-) delete mode 100644 MANIFEST.in create mode 100644 dbt/adapters/sqlserver/py.typed delete mode 100644 dev_requirements.txt create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/.github/workflows/integration-tests-sqlserver.yml b/.github/workflows/integration-tests-sqlserver.yml index d74274b48..c51f6c930 100644 --- a/.github/workflows/integration-tests-sqlserver.yml +++ b/.github/workflows/integration-tests-sqlserver.yml @@ -18,7 +18,7 @@ jobs: name: Regular strategy: matrix: - python_version: ["3.9", "3.10", "3.11", "3.12", "3.13"] + python_version: ["3.10", "3.11", "3.12", "3.13"] msodbc_version: ["17", "18"] sqlserver_version: ["2017", "2019", "2022"] collation: ["SQL_Latin1_General_CP1_CS_AS", "SQL_Latin1_General_CP1_CI_AS"] @@ -39,7 +39,7 @@ jobs: - uses: actions/checkout@v4 - name: Install dependencies - run: pip install -r dev_requirements.txt + run: pip install -e ".[dev]" - name: Run functional tests run: pytest -ra -v tests/functional --profile "ci_sql_server" diff --git a/.github/workflows/release-version.yml b/.github/workflows/release-version.yml index faff1ea25..18cb33256 100644 --- a/.github/workflows/release-version.yml +++ b/.github/workflows/release-version.yml @@ -15,13 +15,29 @@ jobs: - uses: actions/setup-python@v5 with: - python-version: '3.9' + python-version: '3.10' - - name: Install dependencies - run: pip install -r dev_requirements.txt + - name: Install build tooling + run: pip install build twine - - name: Verify version match - run: python setup.py verify + - name: Verify version matches tag + env: + GITHUB_REF_NAME: ${{ github.ref_name }} + run: | + python - <<'PY' + import os, re, sys + tag = os.environ["GITHUB_REF_NAME"] + tag_version = tag.lstrip("v") + with open("dbt/adapters/sqlserver/__version__.py") as f: + match = re.search(r"""version\s*=\s*["'](.+)["']""", f.read()) + if not match: + sys.exit("could not find version in __version__.py") + pkg_version = match.group(1) + if tag_version != pkg_version: + sys.exit( + f"Git tag {tag_version!r} does not match package version {pkg_version!r}" + ) + PY - name: Initialize .pypirc run: | @@ -31,5 +47,5 @@ jobs: - name: Build and publish package run: | - python setup.py sdist bdist_wheel + python -m build twine upload dist/* diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index a2f098044..b6a68e89c 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -18,7 +18,7 @@ jobs: name: Unit tests strategy: matrix: - python_version: ["3.9", "3.10", "3.11", "3.12", "3.13"] + python_version: ["3.10", "3.11", "3.12", "3.13"] runs-on: ubuntu-latest permissions: contents: read @@ -33,7 +33,7 @@ jobs: - uses: actions/checkout@v4 - name: Install dependencies - run: pip install -r dev_requirements.txt + run: pip install -e ".[dev]" - name: Run unit tests run: pytest -n auto -ra -v tests/unit diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index cfbc714ed..000000000 --- a/MANIFEST.in +++ /dev/null @@ -1 +0,0 @@ -recursive-include dbt/include *.sql *.yml *.md diff --git a/Makefile b/Makefile index cac2581f7..b71e01865 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ THREADS ?= auto .PHONY: dev dev: ## Installs adapter in develop mode along with development dependencies @\ - pip install -r dev_requirements.txt && pre-commit install + pip install -e ".[dev]" && pre-commit install .PHONY: mypy mypy: ## Runs mypy against staged changes for static type checking. diff --git a/dbt/adapters/sqlserver/py.typed b/dbt/adapters/sqlserver/py.typed new file mode 100644 index 000000000..e69de29bb diff --git a/dev_requirements.txt b/dev_requirements.txt deleted file mode 100644 index 239825e67..000000000 --- a/dev_requirements.txt +++ /dev/null @@ -1,24 +0,0 @@ - -dbt-tests-adapter>=1.9.0,<2.0 - -ruff -black==24.8.0 -bumpversion -flake8 -flaky -freezegun==1.4.0 -ipdb -mypy==1.11.2 -pip-tools -pre-commit -pytest -pytest-dotenv -pytest-csv -pytest-xdist -pytz -tox>=3.13 -twine -wheel -pyodbc -azure-identity --e . diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..6e826f476 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,77 @@ +[build-system] +requires = ["setuptools>=68", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "dbt-sqlserver" +description = "A Microsoft SQL Server adapter plugin for dbt" +readme = "README.md" +license = { text = "MIT" } +authors = [ + { name = "Mikael Ene" }, + { name = "Anders Swanson" }, + { name = "Sam Debruyn" }, + { name = "Cor Zuurmond" }, + { name = "Cody Scott" }, +] +requires-python = ">=3.10" +classifiers = [ + "Development Status :: 5 - Production/Stable", + "License :: OSI Approved :: MIT License", + "Operating System :: Microsoft :: Windows", + "Operating System :: MacOS :: MacOS X", + "Operating System :: POSIX :: Linux", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] +dependencies = [ + "dbt-core>=1.9.0,<2.0", + "dbt-common>=1.0,<2.0", + "dbt-adapters>=1.11.0,<2.0", + "pyodbc>=4.0.35,<5.2.0", +] +dynamic = ["version"] + +[project.optional-dependencies] +azure = [ + "azure-identity>=1.12.0", +] +dev = [ + "dbt-tests-adapter>=1.9.0,<2.0", + "azure-identity>=1.12.0", + "build", + "bumpversion", + "flaky", + "freezegun==1.4.0", + "ipdb", + "mypy==1.11.2", + "pre-commit", + "pytest", + "pytest-csv", + "pytest-dotenv", + "pytest-xdist", + "pytz", + "ruff", + "tox>=3.13", + "twine", +] + +[project.urls] +"Setup & configuration" = "https://docs.getdbt.com/reference/warehouse-profiles/mssql-profile" +"Documentation & usage" = "https://docs.getdbt.com/reference/resource-configs/mssql-configs" +"Changelog" = "https://github.com/dbt-msft/dbt-sqlserver/blob/master/CHANGELOG.md" +"Issue Tracker" = "https://github.com/dbt-msft/dbt-sqlserver/issues" +"Source" = "https://github.com/dbt-msft/dbt-sqlserver" + +[tool.setuptools.dynamic] +version = { attr = "dbt.adapters.sqlserver.__version__.version" } + +[tool.setuptools.packages.find] +include = ["dbt", "dbt.*"] +namespaces = true + +[tool.setuptools.package-data] +"dbt" = ["include/**/*.sql", "include/**/*.yml", "include/**/*.md"] +"dbt.adapters.sqlserver" = ["py.typed"] diff --git a/setup.py b/setup.py deleted file mode 100644 index e15e6ccfa..000000000 --- a/setup.py +++ /dev/null @@ -1,94 +0,0 @@ -#!/usr/bin/env python -import os -import re -import sys - -from setuptools import find_namespace_packages, setup -from setuptools.command.install import install - -package_name = "dbt-sqlserver" -authors_list = ["Mikael Ene", "Anders Swanson", "Sam Debruyn", "Cor Zuurmond", "Cody Scott"] -dbt_version = "1.9" -description = """A Microsoft SQL Server adapter plugin for dbt""" - -this_directory = os.path.abspath(os.path.dirname(__file__)) -with open(os.path.join(this_directory, "README.md")) as f: - long_description = f.read() - - -# get this from a separate file -def _dbt_sqlserver_version(): - _version_path = os.path.join(this_directory, "dbt", "adapters", "sqlserver", "__version__.py") - _version_pattern = r"""version\s*=\s*["'](.+)["']""" - with open(_version_path) as f: - match = re.search(_version_pattern, f.read().strip()) - if match is None: - raise ValueError(f"invalid version at {_version_path}") - return match.group(1) - - -package_version = _dbt_sqlserver_version() - -# the package version should be the dbt version, with maybe some things on the -# ends of it. (0.18.1 vs 0.18.1a1, 0.18.1.1, ...) -if not package_version.startswith(dbt_version): - raise ValueError( - f"Invalid setup.py: package_version={package_version} must start with " - f"dbt_version={dbt_version}" - ) - - -class VerifyVersionCommand(install): - """Custom command to verify that the git tag matches our version""" - - description = "Verify that the git tag matches our version" - - def run(self): - tag = os.getenv("GITHUB_REF_NAME") - tag_without_prefix = tag[1:] - - if tag_without_prefix != package_version: - info = "Git tag: {0} does not match the version of this app: {1}".format( - tag_without_prefix, package_version - ) - sys.exit(info) - - -setup( - name=package_name, - version=package_version, - description=description, - long_description=long_description, - long_description_content_type="text/markdown", - license="MIT", - author=", ".join(authors_list), - url="https://github.com/dbt-msft/dbt-sqlserver", - packages=find_namespace_packages(include=["dbt", "dbt.*"]), - include_package_data=True, - install_requires=[ - "dbt-core>=1.9.0,<2.0", - "dbt-common>=1.0,<2.0", - "dbt-adapters>=1.11.0,<2.0", - ], - cmdclass={ - "verify": VerifyVersionCommand, - }, - classifiers=[ - "Development Status :: 5 - Production/Stable", - "License :: OSI Approved :: MIT License", - "Operating System :: Microsoft :: Windows", - "Operating System :: MacOS :: MacOS X", - "Operating System :: POSIX :: Linux", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Programming Language :: Python :: 3.13", - ], - project_urls={ - "Setup & configuration": "https://docs.getdbt.com/reference/warehouse-profiles/mssql-profile", # noqa: E501 - "Documentation & usage": "https://docs.getdbt.com/reference/resource-configs/mssql-configs", # noqa: E501 - "Changelog": "https://github.com/dbt-msft/dbt-sqlserver/blob/master/CHANGELOG.md", # noqa: E501 - "Issue Tracker": "https://github.com/dbt-msft/dbt-sqlserver/issues", # noqa: E501 - }, -) From b0d114773471c9b1b21cbf70b7567fe8d1354da3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 19 May 2026 02:51:24 +0000 Subject: [PATCH 2/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .github/scripts/verify_version.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/scripts/verify_version.py b/.github/scripts/verify_version.py index fcb13caa6..5d39fb4b5 100755 --- a/.github/scripts/verify_version.py +++ b/.github/scripts/verify_version.py @@ -35,8 +35,7 @@ def main(argv: list[str]) -> int: pkg_version = read_package_version() if tag_version != pkg_version: print( - f"Git tag {tag_version!r} does not match " - f"package version {pkg_version!r}", + f"Git tag {tag_version!r} does not match " f"package version {pkg_version!r}", file=sys.stderr, ) return 1 From 1c0766e5cf86501b11d15cee1441b91b63498221 Mon Sep 17 00:00:00 2001 From: Josh Markovic Date: Tue, 19 May 2026 17:54:35 +0000 Subject: [PATCH 3/5] Move pyodbc to optional --- pyproject.toml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 995508726..069a684c8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,7 +30,6 @@ dependencies = [ "dbt-core>=1.9.0,<2.0", "dbt-common>=1.0,<2.0", "dbt-adapters>=1.11.0,<2.0", - "pyodbc>=4.0.35,<5.2.0", ] dynamic = ["version"] @@ -38,6 +37,9 @@ dynamic = ["version"] azure = [ "azure-identity>=1.12.0", ] +pyodbc = [ + "pyodbc>=5.2.0", +] [dependency-groups] dev = [ From 428bf17003a3e05baa6b834e8535a53e6c2d3ba3 Mon Sep 17 00:00:00 2001 From: Axell Padilla <68310020+axellpadilla@users.noreply.github.com> Date: Tue, 19 May 2026 22:34:08 -0600 Subject: [PATCH 4/5] Update pip install command for SQL Server integration --- .github/workflows/integration-tests-sqlserver.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration-tests-sqlserver.yml b/.github/workflows/integration-tests-sqlserver.yml index c2e438ba8..8094b0b44 100644 --- a/.github/workflows/integration-tests-sqlserver.yml +++ b/.github/workflows/integration-tests-sqlserver.yml @@ -62,7 +62,7 @@ jobs: run: pip install uv - name: Install dependencies - run: uv pip install --system -e . --group dev + run: uv pip install --system -e ".[pyodbc]" --group dev - name: Run functional tests run: pytest -ra -v tests/functional --profile "ci_sql_server" From 7fb4612045da8703202fc6813742286d299582cf Mon Sep 17 00:00:00 2001 From: Axell Padilla <68310020+axellpadilla@users.noreply.github.com> Date: Tue, 19 May 2026 22:44:54 -0600 Subject: [PATCH 5/5] Update pip install command to include pyodbc --- .github/workflows/unit-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 332c9df7f..a461bac2a 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -36,7 +36,7 @@ jobs: run: pip install uv - name: Install dependencies - run: uv pip install --system -e . --group dev + run: uv pip install --system -e ".[pyodbc]" --group dev - name: Run unit tests run: pytest -n auto -ra -v tests/unit