From 6d496eee9145fb38eb9138b211c90704328f09cb Mon Sep 17 00:00:00 2001 From: Nokome Bentley Date: Fri, 16 Nov 2018 11:37:30 +1300 Subject: [PATCH] Ensure Python3 before reading README with encoding arg If you accidently try to install using Python 2 you get the error Complete output from command python setup.py egg_info: Traceback (most recent call last): File "", line 1, in File "/home/nokome/nokome/repo2docker/setup.py", line 5, in with open('README.md', encoding="utf8") as f: TypeError: 'encoding' is an invalid keyword argument for this function Ideally the user would be aked to use Python 3 as `python_requires` tells us, but which isn't reached yet. This implements that behaviour. --- setup.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/setup.py b/setup.py index 2608529f..f46b17b5 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,10 @@ from setuptools import setup, find_packages import versioneer +import sys +if sys.version_info[0] < 3: + sys.stderr.write('jupyter-repo2docker requires Python 3 but the running Python is %s.%s.%s' % sys.version_info[:3]) + sys.exit(1) with open('README.md', encoding="utf8") as f: readme = f.read()