From 59bf43dc1f1595ef3e0b137873d80ad529a13734 Mon Sep 17 00:00:00 2001 From: genos Date: Sun, 23 Aug 2020 17:13:36 -0400 Subject: [PATCH 1/3] Fix for #2347 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Introduction** This PR attempts to fix #2347, wherein we wish `dbt` to complain about trying to install with a Python version < 3.6. **Changes** Per [the issue's suggestion](https://github.com/fishtown-analytics/dbt/issues/2347), I found every `setup.py` file I could: ``` -# If you have the fantastic `fd` utility installed: fd setup.py -# This also works find . -name setup.py -print ``` Then to each of these, I added the following after the `import sys`: ``` if sys.version_info < (3, 6): print('Error: dbt does not support this version of Python.') print('Please upgrade to Python 3.6 or higher.') sys.exit(1) ``` **Testing** I used the [`nix` package manager](https://nixos.org) to attempt installing this branch with both Python 2.7 and Python 3.8. _Python 2.7_ fails as expected: ``` ~/github/test2 ∃ cat default.nix let pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/20.03.tar.gz") { }; py = pkgs.python27Full.withPackages (p: [ p.setuptools ]); in pkgs.mkShell { name = "python-2-env"; buildInputs = [ py ]; } ~/github/test2 ∃ nix-shell --pure [nix-shell:~/github/test2]$ python ../dbt/setup.py build Error: dbt does not support this version of Python. Please upgrade to Python 3.6 or higher. [nix-shell:~/github/test2]$ echo $? 1 ``` _Python 3.8_ still works: ``` ~/github/test3 ∃ cat default.nix let pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/20.03.tar.gz") { }; py = pkgs.python38Full.withPackages (p: [ p.setuptools ]); in pkgs.mkShell { name = "python-3-env"; buildInputs = [ py ]; } ~/github/test3 ∃ nix-shell --pure [nix-shell:~/github/test3]$ python ../dbt/setup.py build running build [nix-shell:~/github/test3]$ echo $? 0 ``` --- core/setup.py | 6 ++++++ plugins/bigquery/setup.py | 6 ++++++ plugins/postgres/setup.py | 6 ++++++ plugins/redshift/setup.py | 6 ++++++ plugins/snowflake/setup.py | 6 ++++++ setup.py | 6 ++++++ 6 files changed, 36 insertions(+) diff --git a/core/setup.py b/core/setup.py index 8e2b09acbc7..ce071a3ff5f 100644 --- a/core/setup.py +++ b/core/setup.py @@ -2,6 +2,12 @@ import os import sys +if sys.version_info < (3, 6): + print('Error: dbt does not support this version of Python.') + print('Please upgrade to Python 3.6 or higher.') + sys.exit(1) + + from setuptools import setup try: from setuptools import find_namespace_packages diff --git a/plugins/bigquery/setup.py b/plugins/bigquery/setup.py index 5ffa04f5f8f..b0f429cac8c 100644 --- a/plugins/bigquery/setup.py +++ b/plugins/bigquery/setup.py @@ -2,6 +2,12 @@ import os import sys +if sys.version_info < (3, 6): + print('Error: dbt does not support this version of Python.') + print('Please upgrade to Python 3.6 or higher.') + sys.exit(1) + + from setuptools import setup try: from setuptools import find_namespace_packages diff --git a/plugins/postgres/setup.py b/plugins/postgres/setup.py index acabd563943..fc0bf2f25e1 100644 --- a/plugins/postgres/setup.py +++ b/plugins/postgres/setup.py @@ -2,6 +2,12 @@ import os import sys +if sys.version_info < (3, 6): + print('Error: dbt does not support this version of Python.') + print('Please upgrade to Python 3.6 or higher.') + sys.exit(1) + + from setuptools import setup try: from setuptools import find_namespace_packages diff --git a/plugins/redshift/setup.py b/plugins/redshift/setup.py index 537ee87addb..28b145ca4fa 100644 --- a/plugins/redshift/setup.py +++ b/plugins/redshift/setup.py @@ -2,6 +2,12 @@ import os import sys +if sys.version_info < (3, 6): + print('Error: dbt does not support this version of Python.') + print('Please upgrade to Python 3.6 or higher.') + sys.exit(1) + + from setuptools import setup try: from setuptools import find_namespace_packages diff --git a/plugins/snowflake/setup.py b/plugins/snowflake/setup.py index b89be4e4e74..b4d363923e8 100644 --- a/plugins/snowflake/setup.py +++ b/plugins/snowflake/setup.py @@ -2,6 +2,12 @@ import os import sys +if sys.version_info < (3, 6): + print('Error: dbt does not support this version of Python.') + print('Please upgrade to Python 3.6 or higher.') + sys.exit(1) + + from setuptools import setup try: from setuptools import find_namespace_packages diff --git a/setup.py b/setup.py index 476afeca069..1afee2f8e05 100644 --- a/setup.py +++ b/setup.py @@ -2,6 +2,12 @@ import os import sys +if sys.version_info < (3, 6): + print('Error: dbt does not support this version of Python.') + print('Please upgrade to Python 3.6 or higher.') + sys.exit(1) + + from setuptools import setup try: from setuptools import find_namespace_packages From 707310db64fba3fed301dd0d418b06ac46bd29f4 Mon Sep 17 00:00:00 2001 From: genos Date: Sun, 23 Aug 2020 17:40:36 -0400 Subject: [PATCH 2/3] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ea8db2d870..3024c810bb2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### Under the hood - Added 3 more adapter methods that the new dbt-adapter-test suite can use for testing. ([#2492](https://github.com/fishtown-analytics/dbt/issues/2492), [#2721](https://github.com/fishtown-analytics/dbt/pull/2721)) +- It is now an error to attempt installing `dbt` with a Python version less than 3.6. (resolves [#2347](https://github.com/fishtown-analytics/dbt/issues/2347)) ## dbt 0.18.0rc1 (August 19, 2020) From 81bf3dae5c7327c8a0644051d7c2a195c535a5fa Mon Sep 17 00:00:00 2001 From: genos Date: Mon, 31 Aug 2020 23:48:49 -0400 Subject: [PATCH 3/3] add contributors to changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9eb17a759a7..f01b0dc67dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,9 @@ ### Fixes - dbt now validates the require-dbt-version field before it validates the dbt_project.yml schema ([#2638](https://github.com/fishtown-analytics/dbt/issues/2638), [#2726](https://github.com/fishtown-analytics/dbt/pull/2726)) +Contributors: +- [@genos](https://github.com/genos) ([#2722](https://github.com/fishtown-analytics/dbt/pull/2722)) + ## dbt 0.18.0rc1 (August 19, 2020)