Skip to content

Commit

Permalink
Fix for #2347
Browse files Browse the repository at this point in the history
**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](#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
```
  • Loading branch information
genos committed Aug 23, 2020
1 parent fe46138 commit 59bf43d
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 0 deletions.
6 changes: 6 additions & 0 deletions core/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions plugins/bigquery/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions plugins/postgres/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions plugins/redshift/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions plugins/snowflake/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 59bf43d

Please sign in to comment.