xref: /aosp_15_r20/external/yapf/setup.py (revision 7249d1a64f4850ccf838e62a46276f891f72998e)
1#!/usr/bin/env python
2# Copyright 2015 Google Inc. All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#     http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16import codecs
17import sys
18import unittest
19
20from setuptools import find_packages, setup, Command
21
22import yapf
23
24
25class RunTests(Command):
26  user_options = []
27
28  def initialize_options(self):
29    pass
30
31  def finalize_options(self):
32    pass
33
34  def run(self):
35    loader = unittest.TestLoader()
36    tests = loader.discover('yapftests', pattern='*_test.py', top_level_dir='.')
37    runner = unittest.TextTestRunner()
38    results = runner.run(tests)
39    sys.exit(0 if results.wasSuccessful() else 1)
40
41
42with codecs.open('README.rst', 'r', 'utf-8') as fd:
43  setup(
44      name='yapf',
45      version=yapf.__version__,
46      description='A formatter for Python code.',
47      long_description=fd.read(),
48      license='Apache License, Version 2.0',
49      author='Google Inc.',
50      maintainer='Bill Wendling',
51      maintainer_email='[email protected]',
52      packages=find_packages('.'),
53      classifiers=[
54          'Development Status :: 4 - Beta',
55          'Environment :: Console',
56          'Intended Audience :: Developers',
57          'License :: OSI Approved :: Apache Software License',
58          'Operating System :: OS Independent',
59          'Programming Language :: Python',
60          'Programming Language :: Python :: 2',
61          'Programming Language :: Python :: 2.7',
62          'Programming Language :: Python :: 3',
63          'Programming Language :: Python :: 3.6',
64          'Topic :: Software Development :: Libraries :: Python Modules',
65          'Topic :: Software Development :: Quality Assurance',
66      ],
67      entry_points={
68          'console_scripts': [
69              'yapf = yapf:run_main',
70              'yapf-diff = yapf.third_party.yapf_diff.yapf_diff:main',
71          ],
72      },
73      cmdclass={
74          'test': RunTests,
75      },
76  )
77