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 - }, -)