Imre Kis | 124f0e3 | 2021-02-12 18:03:24 +0100 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | # Copyright (c) 2019-2021, Arm Limited. All rights reserved. |
| 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | |
| 6 | """ |
| 7 | Setup file for c-picker. |
| 8 | """ |
| 9 | |
| 10 | import importlib |
| 11 | import setuptools |
| 12 | import pkg_resources |
| 13 | from c_picker import __version__ as CPICKER_VERSION |
| 14 | from c_picker import __license__ as CPICKER_LICENSE |
| 15 | |
| 16 | def get_install_requires(): |
| 17 | """ |
| 18 | Collecting dependencies on install. |
| 19 | clang module can be part of the distro's package and it should not be |
| 20 | overwritten by the clang pip package. |
| 21 | """ |
| 22 | |
| 23 | deps = ["pyyaml>5"] |
| 24 | |
| 25 | try: |
Imre Kis | 7735f75 | 2021-02-19 18:12:05 +0100 | [diff] [blame] | 26 | pkg_resources.get_distribution("libclang") |
Imre Kis | 124f0e3 | 2021-02-12 18:03:24 +0100 | [diff] [blame] | 27 | has_clang_pip = True |
| 28 | except pkg_resources.DistributionNotFound: |
| 29 | has_clang_pip = False |
| 30 | |
| 31 | clang_spec = importlib.util.find_spec("clang") |
| 32 | has_clang_module = clang_spec is not None |
| 33 | |
| 34 | # Install clang Python bindings from pip if it has not been install |
| 35 | # any other way. This condition prevents overwriting clang Python |
| 36 | # modules if they were installed without pip (i.e. using the system's |
| 37 | # package manager instead of pip). |
| 38 | if not has_clang_module or has_clang_pip: |
Imre Kis | 7735f75 | 2021-02-19 18:12:05 +0100 | [diff] [blame] | 39 | deps.append("libclang") |
Imre Kis | 124f0e3 | 2021-02-12 18:03:24 +0100 | [diff] [blame] | 40 | |
| 41 | return deps |
| 42 | |
| 43 | setuptools.setup( |
| 44 | name="c-picker", |
| 45 | version=CPICKER_VERSION, |
| 46 | author="Arm Limited", |
| 47 | author_email="imre.kis@arm.com", |
| 48 | license=CPICKER_LICENSE, |
| 49 | description="C source code picker", |
| 50 | platforms=["any"], |
| 51 | packages=[ |
| 52 | "c_picker" |
| 53 | ], |
| 54 | install_requires=get_install_requires(), |
| 55 | entry_points={ |
| 56 | "console_scripts": [ |
| 57 | 'c-picker=c_picker.runner:main', |
| 58 | 'c-picker-coverage-mapper=c_picker.coverage:main' |
| 59 | ], |
| 60 | }, |
| 61 | classifiers=[ |
| 62 | "Programming Language :: Python :: 3", |
| 63 | "License :: OSI Approved :: BSD License", |
| 64 | "Operating System :: OS Independent", |
| 65 | ], |
| 66 | ) |