blob: b19958eb82a93364b2fa4eab0d756cdfd98c23c3 [file] [log] [blame]
Imre Kis124f0e32021-02-12 18:03:24 +01001#!/usr/bin/env python3
2# Copyright (c) 2019-2021, Arm Limited. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5
6"""
7Setup file for c-picker.
8"""
9
10import importlib
11import setuptools
12import pkg_resources
13from c_picker import __version__ as CPICKER_VERSION
14from c_picker import __license__ as CPICKER_LICENSE
15
16def 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:
26 pkg_resources.get_distribution("clang")
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:
39 deps.append("clang")
40
41 return deps
42
43setuptools.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)