Skip to content

Commit 8454112

Browse files
authored
Merge pull request #645 from joshmarkovic/jm/modernize-packaging
Modernize packaging: migrate setup.py to PEP 621 and 735 pyproject.toml Deprecate python 3.9 as officially supported Phase 1 of pyodbc optional backend
2 parents 86bbdc7 + 7fb4612 commit 8454112

11 files changed

Lines changed: 139 additions & 143 deletions

File tree

.devcontainer/setup_env.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ docker compose up -d
99
pip install uv
1010

1111
# Use a workspace-local virtualenv so package installs do not fail on user permissions.
12-
uv pip install -r dev_requirements.txt
12+
uv pip install -e . --group dev
1313
source .venv/bin/activate
1414
pre-commit install

.github/scripts/verify_version.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env python3
2+
"""Verify the packaged version matches the release git tag.
3+
4+
Usage:
5+
python .github/scripts/verify_version.py <tag>
6+
7+
The tag typically comes from ``$GITHUB_REF_NAME`` and may be prefixed with
8+
``v`` (e.g. ``v1.9.1``). The leading ``v`` is stripped before comparison.
9+
10+
Exits 0 on match, 1 on mismatch, 2 on usage error.
11+
"""
12+
from __future__ import annotations
13+
14+
import re
15+
import sys
16+
from pathlib import Path
17+
18+
REPO_ROOT = Path(__file__).resolve().parents[2]
19+
VERSION_FILE = REPO_ROOT / "dbt" / "adapters" / "sqlserver" / "__version__.py"
20+
VERSION_RE = re.compile(r"""version\s*=\s*["'](?P<version>.+?)["']""")
21+
22+
23+
def read_package_version(version_file: Path = VERSION_FILE) -> str:
24+
match = VERSION_RE.search(version_file.read_text())
25+
if not match:
26+
raise ValueError(f"could not find version in {version_file}")
27+
return match.group("version")
28+
29+
30+
def main(argv: list[str]) -> int:
31+
if len(argv) != 2:
32+
print("usage: verify_version.py <tag>", file=sys.stderr)
33+
return 2
34+
tag_version = argv[1].lstrip("v")
35+
pkg_version = read_package_version()
36+
if tag_version != pkg_version:
37+
print(
38+
f"Git tag {tag_version!r} does not match " f"package version {pkg_version!r}",
39+
file=sys.stderr,
40+
)
41+
return 1
42+
return 0
43+
44+
45+
if __name__ == "__main__":
46+
sys.exit(main(sys.argv))

.github/workflows/integration-tests-sqlserver.yml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,9 @@ on: # yamllint disable-line rule:truthy
1111
- 'tests/functional/**'
1212
- 'devops/**'
1313
- 'docker-compose.yml'
14-
- 'dev_requirements.txt'
1514
- '**/*.lock'
1615
- '.locks/**'
1716
- 'pyproject.toml'
18-
- 'setup.cfg'
19-
- 'setup.py'
20-
- 'MANIFEST.in'
2117
- 'pytest.ini'
2218
- '.github/workflows/integration-tests-sqlserver.yml'
2319
pull_request:
@@ -29,13 +25,9 @@ on: # yamllint disable-line rule:truthy
2925
- 'tests/functional/**'
3026
- 'devops/**'
3127
- 'docker-compose.yml'
32-
- 'dev_requirements.txt'
3328
- '**/*.lock'
3429
- '.locks/**'
3530
- 'pyproject.toml'
36-
- 'setup.cfg'
37-
- 'setup.py'
38-
- 'MANIFEST.in'
3931
- 'pytest.ini'
4032
- '.github/workflows/integration-tests-sqlserver.yml'
4133
schedule:
@@ -46,7 +38,7 @@ jobs:
4638
name: Regular
4739
strategy:
4840
matrix:
49-
python_version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
41+
python_version: ["3.10", "3.11", "3.12", "3.13"]
5042
msodbc_version: ["17", "18"]
5143
sqlserver_version: ["2017", "2019", "2022"]
5244
collation: ["SQL_Latin1_General_CP1_CS_AS", "SQL_Latin1_General_CP1_CI_AS"]
@@ -70,7 +62,7 @@ jobs:
7062
run: pip install uv
7163

7264
- name: Install dependencies
73-
run: uv pip install --system -r dev_requirements.txt
65+
run: uv pip install --system -e ".[pyodbc]" --group dev
7466

7567
- name: Run functional tests
7668
run: pytest -ra -v tests/functional --profile "ci_sql_server"

.github/workflows/release-version.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,13 @@ jobs:
1515

1616
- uses: actions/setup-python@v6
1717
with:
18-
python-version: '3.9'
18+
python-version: '3.10'
1919

20-
- name: Install uv
21-
run: pip install uv
20+
- name: Install build tooling
21+
run: pip install build twine
2222

23-
- name: Install dependencies
24-
run: uv pip install --system -r dev_requirements.txt
25-
26-
- name: Verify version match
27-
run: python setup.py verify
23+
- name: Verify version matches tag
24+
run: python .github/scripts/verify_version.py "${{ github.ref_name }}"
2825

2926
- name: Initialize .pypirc
3027
run: |
@@ -34,5 +31,5 @@ jobs:
3431
3532
- name: Build and publish package
3633
run: |
37-
python setup.py sdist bdist_wheel
34+
python -m build
3835
twine upload dist/*

.github/workflows/unit-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
name: Unit tests
1919
strategy:
2020
matrix:
21-
python_version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
21+
python_version: ["3.10", "3.11", "3.12", "3.13"]
2222
runs-on: ubuntu-latest
2323
permissions:
2424
contents: read
@@ -36,7 +36,7 @@ jobs:
3636
run: pip install uv
3737

3838
- name: Install dependencies
39-
run: uv pip install --system -r dev_requirements.txt
39+
run: uv pip install --system -e ".[pyodbc]" --group dev
4040

4141
- name: Run unit tests
4242
run: pytest -n auto -ra -v tests/unit

MANIFEST.in

Lines changed: 0 additions & 1 deletion
This file was deleted.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ THREADS ?= auto
44
.PHONY: dev
55
dev: ## Installs adapter in develop mode along with development dependencies
66
@\
7-
uv pip install -r dev_requirements.txt && pre-commit install
7+
uv pip install -e . --group dev && pre-commit install
88

99
.PHONY: mypy
1010
mypy: ## Runs mypy against staged changes for static type checking.

dbt/adapters/sqlserver/py.typed

Whitespace-only changes.

dev_requirements.txt

Lines changed: 0 additions & 24 deletions
This file was deleted.

pyproject.toml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
[build-system]
2+
requires = ["setuptools>=68", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "dbt-sqlserver"
7+
description = "A Microsoft SQL Server adapter plugin for dbt"
8+
readme = "README.md"
9+
license = { text = "MIT" }
10+
authors = [
11+
{ name = "Mikael Ene" },
12+
{ name = "Anders Swanson" },
13+
{ name = "Sam Debruyn" },
14+
{ name = "Cor Zuurmond" },
15+
{ name = "Cody Scott" },
16+
]
17+
requires-python = ">=3.10"
18+
classifiers = [
19+
"Development Status :: 5 - Production/Stable",
20+
"License :: OSI Approved :: MIT License",
21+
"Operating System :: Microsoft :: Windows",
22+
"Operating System :: MacOS :: MacOS X",
23+
"Operating System :: POSIX :: Linux",
24+
"Programming Language :: Python :: 3.10",
25+
"Programming Language :: Python :: 3.11",
26+
"Programming Language :: Python :: 3.12",
27+
"Programming Language :: Python :: 3.13",
28+
]
29+
dependencies = [
30+
"dbt-core>=1.9.0,<2.0",
31+
"dbt-common>=1.0,<2.0",
32+
"dbt-adapters>=1.11.0,<2.0",
33+
]
34+
dynamic = ["version"]
35+
36+
[project.optional-dependencies]
37+
azure = [
38+
"azure-identity>=1.12.0",
39+
]
40+
pyodbc = [
41+
"pyodbc>=5.2.0",
42+
]
43+
44+
[dependency-groups]
45+
dev = [
46+
"dbt-tests-adapter>=1.9.0,<2.0",
47+
"azure-identity>=1.12.0",
48+
"build",
49+
"bumpversion",
50+
"flaky",
51+
"freezegun==1.4.0",
52+
"ipdb",
53+
"mypy==1.11.2",
54+
"pre-commit",
55+
"pytest",
56+
"pytest-csv",
57+
"pytest-dotenv",
58+
"pytest-xdist",
59+
"pytz",
60+
"ruff",
61+
"tox>=3.13",
62+
"twine",
63+
]
64+
65+
[project.urls]
66+
"Setup & configuration" = "https://docs.getdbt.com/reference/warehouse-profiles/mssql-profile"
67+
"Documentation & usage" = "https://docs.getdbt.com/reference/resource-configs/mssql-configs"
68+
"Changelog" = "https://github.com/dbt-msft/dbt-sqlserver/blob/master/CHANGELOG.md"
69+
"Issue Tracker" = "https://github.com/dbt-msft/dbt-sqlserver/issues"
70+
"Source" = "https://github.com/dbt-msft/dbt-sqlserver"
71+
72+
[tool.setuptools.dynamic]
73+
version = { attr = "dbt.adapters.sqlserver.__version__.version" }
74+
75+
[tool.setuptools.packages.find]
76+
include = ["dbt", "dbt.*"]
77+
namespaces = true
78+
79+
[tool.setuptools.package-data]
80+
"dbt" = ["include/**/*.sql", "include/**/*.yml", "include/**/*.md"]
81+
"dbt.adapters.sqlserver" = ["py.typed"]

0 commit comments

Comments
 (0)