|
3 | 3 | # Copyright (c) 2021 LG Electronics |
4 | 4 | # SPDX-License-Identifier: GPL-3.0-only |
5 | 5 | from codecs import open |
| 6 | +import os |
| 7 | +import shutil |
6 | 8 | from setuptools import setup, find_packages |
7 | 9 |
|
8 | 10 | with open('README.md', 'r', 'utf-8') as f: |
|
11 | 13 | with open('requirements.txt', 'r', 'utf-8') as f: |
12 | 14 | required = f.read().splitlines() |
13 | 15 |
|
| 16 | +_PACKAEG_NAME = 'fosslight_prechecker' |
| 17 | +_LICENSE_FILE = 'LICENSE' |
| 18 | +_LICENSE_DIR = 'LICENSES' |
| 19 | + |
14 | 20 | if __name__ == "__main__": |
| 21 | + dest_path = os.path.join('src', _PACKAEG_NAME, _LICENSE_DIR) |
| 22 | + try: |
| 23 | + if not os.path.exists(dest_path): |
| 24 | + os.mkdir(dest_path) |
| 25 | + if os.path.isfile(_LICENSE_FILE): |
| 26 | + shutil.copy(_LICENSE_FILE, dest_path) |
| 27 | + if os.path.isdir(_LICENSE_DIR): |
| 28 | + license_f = [f_name for f_name in os.listdir(_LICENSE_DIR) if f_name.upper().startswith(_LICENSE_FILE)] |
| 29 | + for lic_f in license_f: |
| 30 | + shutil.copy(os.path.join(_LICENSE_DIR, lic_f), dest_path) |
| 31 | + except Exception as e: |
| 32 | + print(f'Warning: Fail to copy the license text: {e}') |
| 33 | + |
15 | 34 | setup( |
16 | 35 | name='fosslight_prechecker', |
17 | 36 | version='3.0.9', |
|
32 | 51 | "Programming Language :: Python :: 3.8", |
33 | 52 | "Programming Language :: Python :: 3.9"], |
34 | 53 | install_requires=required, |
35 | | - package_data={'fosslight_prechecker': ['resources/convert_license.json']}, |
| 54 | + package_data={_PACKAEG_NAME: ['resources/convert_license.json', os.path.join(_LICENSE_DIR, '*')]}, |
36 | 55 | include_package_data=True, |
37 | 56 | entry_points={ |
38 | 57 | "console_scripts": [ |
|
41 | 60 | ] |
42 | 61 | } |
43 | 62 | ) |
| 63 | + shutil.rmtree(dest_path, ignore_errors=True) |
0 commit comments