| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 try: | 6 from setuptools import setup, find_packages |
| 7 from setuptools import setup | |
| 8 except ImportError: | |
| 9 from distutils.core import setup | |
| 10 | 7 |
| 11 import ast | 8 import ast |
| 12 | 9 |
| 13 | 10 |
| 14 def read_vars(path): | 11 def read_vars(path): |
| 15 ret = {} | 12 ret = {} |
| 16 with open(path) as f: | 13 with open(path) as f: |
| 17 for n in ast.walk(ast.parse(f.read())): | 14 for n in ast.walk(ast.parse(f.read())): |
| 18 if isinstance(n, ast.Module): | 15 if isinstance(n, ast.Module): |
| 19 ret['__doc__'] = ast.get_docstring(n) | 16 ret['__doc__'] = ast.get_docstring(n) |
| 20 elif isinstance(n, ast.Assign): | 17 elif isinstance(n, ast.Assign): |
| 21 if isinstance(n.targets[0], ast.Name) and isinstance(n.value, ast.Str): | 18 if isinstance(n.targets[0], ast.Name) and isinstance(n.value, ast.Str): |
| 22 ret[n.targets[0].id] = n.value.s | 19 ret[n.targets[0].id] = n.value.s |
| 23 return ret | 20 return ret |
| 24 | 21 |
| 25 | 22 |
| 26 NAME = 'testing_support' | 23 NAME = 'testing_support' |
| 27 VARS = read_vars(NAME + '/__init__.py') | 24 VARS = read_vars(NAME + '/__init__.py') |
| 28 | 25 |
| 29 | 26 |
| 30 setup( | 27 setup( |
| 31 name=NAME, | 28 name=NAME, |
| 32 version=VARS['__version__'], | 29 version=VARS['__version__'], |
| 33 description=VARS['__doc__'].splitlines()[0], | 30 description=VARS['__doc__'].splitlines()[0], |
| 34 long_description=open('README.md').read(), | 31 long_description=open('README.md').read(), |
| 35 author=VARS['__author__'], | 32 author=VARS['__author__'], |
| 36 author_email=VARS['__email__'], | 33 author_email=VARS['__email__'], |
| 37 url=VARS['__url__'], | 34 url=VARS['__url__'], |
| 38 packages=[NAME], | 35 packages=find_packages() |
| 39 ) | 36 ) |
| OLD | NEW |