From 821af46583e83008d9a483e46bb52f33d3d8bc52 Mon Sep 17 00:00:00 2001
From: Thomas A Caswell <tcaswell@gmail.com>
Date: Sun, 22 Oct 2017 22:30:26 -0400
Subject: [PATCH] FIX: install on python 3.7

https://github.com/python/cpython/pull/46 /
https://bugs.python.org/issue29463 move the module comment into the
AST node and hence out of the tree which means the 2nd entry in the
tree is now the import rather than the `__version__` string.

Adds nightly on travis.
---
 .travis.yml | 4 +++-
 setup.py    | 7 +++++--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 8bd67fff7..d8fe58da4 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,11 +8,14 @@ python:
   - 3.5
   - 3.6
   - pypy
+  - nightly
+
 matrix:
   allow_failures:
     - python: pypy
     - env: TOXENV=cov
     - env: TOXENV=sith
+    - python: nightly
   include:
     - python: 3.5
       env: TOXENV=cov
@@ -27,4 +30,3 @@ after_script:
       pip install --quiet coveralls;
       coveralls;
       fi
-
diff --git a/setup.py b/setup.py
index 21db855a0..454e5fbda 100755
--- a/setup.py
+++ b/setup.py
@@ -3,7 +3,7 @@
 from setuptools import setup, find_packages
 
 import ast
-
+import sys
 
 __AUTHOR__ = 'David Halter'
 __AUTHOR_EMAIL__ = 'davidhalter88@gmail.com'
@@ -11,7 +11,10 @@
 # Get the version from within jedi. It's defined in exactly one place now.
 with open('jedi/__init__.py') as f:
     tree = ast.parse(f.read())
-version = tree.body[1].value.s
+if sys.version_info > (3, 7):
+    version = tree.body[0].value.s
+else:
+    version = tree.body[1].value.s
 
 readme = open('README.rst').read() + '\n\n' + open('CHANGELOG.rst').read()
 with open('requirements.txt') as f: