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

Migrate from setup.py to pyproject toml in preparation for Python 3.12 support #835

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ first_value = 1

[bumpversion:part:nightly]

[bumpversion:file:setup.py]
[bumpversion:file:pyproject.toml]

[bumpversion:file:dbt/adapters/snowflake/__version__.py]
6 changes: 6 additions & 0 deletions .changes/unreleased/Under the Hood-20231118-221826.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Under the Hood
body: Migrate from setup.py to pyproject.toml
time: 2023-11-18T22:18:26.160046-05:00
custom:
Author: mikealfare
Issue: "9999"
5 changes: 1 addition & 4 deletions .github/scripts/update_dbt_core_branch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@
set -e

git_branch=$1
target_req_file="dev-requirements.txt"
target_req_file="pyproject.toml"
core_req_sed_pattern="s|dbt-core.git.*#egg=dbt-core|dbt-core.git@${git_branch}#egg=dbt-core|g"
postgres_req_sed_pattern="s|dbt-core.git.*#egg=dbt-postgres|dbt-core.git@${git_branch}#egg=dbt-postgres|g"
tests_req_sed_pattern="s|dbt-core.git.*#egg=dbt-tests|dbt-core.git@${git_branch}#egg=dbt-tests|g"
if [[ "$OSTYPE" == darwin* ]]; then
# mac ships with a different version of sed that requires a delimiter arg
sed -i "" "$core_req_sed_pattern" $target_req_file
sed -i "" "$postgres_req_sed_pattern" $target_req_file
sed -i "" "$tests_req_sed_pattern" $target_req_file
else
sed -i "$core_req_sed_pattern" $target_req_file
sed -i "$postgres_req_sed_pattern" $target_req_file
sed -i "$tests_req_sed_pattern" $target_req_file
fi
core_version=$(curl "https://raw.githubusercontent.com/dbt-labs/dbt-core/${git_branch}/core/dbt/version.py" | grep "__version__ = *"|cut -d'=' -f2)
Expand Down
2 changes: 1 addition & 1 deletion .github/scripts/update_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -e

git_branch=$1
target_req_file="dev-requirements.txt"
target_req_file="pyproject.toml"
core_req_sed_pattern="s|dbt-core.git.*#egg=dbt-core|dbt-core.git@${git_branch}#egg=dbt-core|g"
tests_req_sed_pattern="s|dbt-core.git.*#egg=dbt-tests|dbt-core.git@${git_branch}#egg=dbt-tests|g"
if [[ "$OSTYPE" == darwin* ]]; then
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ jobs:
snowflake:
- 'dbt/**'
- 'tests/**'
- 'dev-requirements.txt'
- name: Generate integration test matrix
id: generate-matrix
uses: actions/github-script@v6
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
- name: Install python dependencies
run: |
python -m pip install --user --upgrade pip
python -m pip install -r dev-requirements.txt
python -m pip install .[dev]
python -m pip --version
pre-commit --version
mypy --version
Expand Down Expand Up @@ -132,7 +132,7 @@ jobs:
- name: Install python dependencies
run: |
python -m pip install --user --upgrade pip
python -m pip install --upgrade setuptools wheel twine check-wheel-contents
python -m pip install --upgrade setuptools wheel twine check-wheel-contents build
python -m pip --version

- name: Build distributions
Expand Down
11 changes: 1 addition & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

.PHONY: dev
dev: ## Installs adapter in develop mode along with development dependencies
@\
pip install -e . -r dev-requirements.txt && pre-commit install
pip install -e .[dev,test] && pre-commit install

.PHONY: dev-uninstall
dev-uninstall: ## Uninstalls all packages while maintaining the virtual environment
Expand All @@ -13,46 +12,38 @@ dev-uninstall: ## Uninstalls all packages while maintaining the virtual environm

.PHONY: mypy
mypy: ## Runs mypy against staged changes for static type checking.
@\
pre-commit run --hook-stage manual mypy-check | grep -v "INFO"

.PHONY: flake8
flake8: ## Runs flake8 against staged changes to enforce style guide.
@\
pre-commit run --hook-stage manual flake8-check | grep -v "INFO"

.PHONY: black
black: ## Runs black against staged changes to enforce style guide.
@\
pre-commit run --hook-stage manual black-check -v | grep -v "INFO"

.PHONY: lint
lint: ## Runs flake8 and mypy code checks against staged changes.
@\
pre-commit run flake8-check --hook-stage manual | grep -v "INFO"; \
pre-commit run mypy-check --hook-stage manual | grep -v "INFO"

.PHONY: linecheck
linecheck: ## Checks for all Python lines 100 characters or more
@\
find dbt -type f -name "*.py" -exec grep -I -r -n '.\{100\}' {} \;

.PHONY: unit
unit: ## Runs unit tests with py38.
@\
tox -e py38

.PHONY: test
test: ## Runs unit tests with py38 and code checks against staged changes.
@\
tox -p -e py38; \
pre-commit run black-check --hook-stage manual | grep -v "INFO"; \
pre-commit run flake8-check --hook-stage manual | grep -v "INFO"; \
pre-commit run mypy-check --hook-stage manual | grep -v "INFO"

.PHONY: integration
integration: ## Runs snowflake integration tests with py38.
@\
tox -e py38-snowflake --

.PHONY: clean
Expand Down
30 changes: 0 additions & 30 deletions dev-requirements.txt

This file was deleted.

2 changes: 0 additions & 2 deletions mypy.ini

This file was deleted.

89 changes: 89 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
[build-system]
requires = [
"build",
"check-wheel-contents",
"setuptools",
"twine",
"wheel",
]
build-backend = "setuptools.build_meta"

[project]
name = "dbt-snowflake"
version = "1.8.0a1"
description = "The Snowflake adapter plugin for dbt"
readme = "README.md"
license = {file = "LICENSE.md"}
requires-python = ">=3.8"
authors = [{name = "dbt Labs", email = "[email protected]"}]
classifiers = [ # Optional
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: Apache Software License",
"Operating System :: Microsoft :: Windows",
"Operating System :: MacOS :: MacOS X",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
]
urls.Homepage = "https://github.com/dbt-labs/dbt-snowflake"
urls."Bug Reports" = "https://github.com/dbt-labs/dbt-snowflake/issues"
urls.Docs = "https://docs.getdbt.com/docs/core/connect-data-platform/snowflake-setup"
dependencies = [
"dbt-core@git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-core&subdirectory=core",
"snowflake-connector-python[secure-local-storage]~=3.0",
# installed via dbt-core but referenced directly; don't pin to avoid version conflicts with dbt-core
"agate",
]
optional-dependencies.dev = [
"black~=23.0",
"flake8",
"flaky",
"ipdb",
"mypy~=1.0",
"pip-tools",
"pre-commit",
"pre-commit-hooks",
"tox~=4.0",
"types-pytz",
"types-requests",
]
optional-dependencies.test = [
"dbt-tests-adapter@git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-tests-adapter&subdirectory=tests/adapter",
"ddtrace",
"freezegun",
"pytest",
"pytest-csv",
"pytest-dotenv",
"pytest-logbook",
"pytest-xdist",
"pytz",
"tox~=4.0",
]

[tool.black]
line-length = 99
target-version = ["py38"]

[tool.mypy]
explicit_package_bases = true
ignore_missing_imports = true
namespace_packages = true
pretty = true
show_error_codes = true

[tool.pytest]
filterwarnings = [
"ignore:.*'soft_unicode' has been renamed to 'soft_str'*:DeprecationWarning",
"ignore:unclosed file .*:ResourceWarning",
]
env_files = "test.env"
testpaths = ["tests/unit", "tests/functional"]
addopts = "-v -n4 --color=yes"

[tool.setuptools]
include-package-data = true

[tool.setuptools.packages.find]
include = ["dbt", "dbt.*"]
10 changes: 0 additions & 10 deletions pytest.ini

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/build-dist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ rm -rf "$DBT_PATH"/build
mkdir -p "$DBT_PATH"/dist

cd "$DBT_PATH"
$PYTHON_BIN setup.py sdist bdist_wheel
$PYTHON_BIN -m build

set +x
89 changes: 0 additions & 89 deletions setup.py

This file was deleted.

23 changes: 7 additions & 16 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
skipsdist = True
skipsdist = true
envlist = py38,py39,py310,py311

[testenv:{unit,py38,py39,py310,py311,py}]
Expand All @@ -9,24 +9,15 @@ passenv =
DBT_*
PYTEST_ADDOPTS
commands = {envpython} -m pytest {posargs} tests/unit
deps =
-rdev-requirements.txt
-e.
deps = -e.[test]

[testenv:{integration,py38,py39,py310,py311,py}-{snowflake}]
description = adapter plugin integration testing
description = integration testing
skip_install = true
passenv =
DBT_*
SNOWFLAKE_TEST_*
PYTEST_ADDOPTS
DD_CIVISIBILITY_AGENTLESS_ENABLED
DD_API_KEY
DD_SITE
DD_ENV
DD_SERVICE
commands =
snowflake: {envpython} -m pytest {posargs} tests/functional
deps =
-rdev-requirements.txt
-e.
SNOWFLAKE_TEST_*
DD_*
commands = {envpython} -m pytest {posargs} tests/functional
deps = -e.[test]