-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsetup.py
More file actions
100 lines (95 loc) · 3.98 KB
/
setup.py
File metadata and controls
100 lines (95 loc) · 3.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (c) 2021 LG Electronics Inc.
# SPDX-License-Identifier: Apache-2.0
from codecs import open
import os
import shutil
from setuptools import setup, find_packages
with open('README.md', 'r', 'utf-8') as f:
readme = f.read()
with open('requirements.txt', 'r', 'utf-8') as f:
install_requires = f.read().splitlines()
_PACKAEG_NAME = 'fosslight_binary'
_TEMP_DC_DIR = os.path.join('src', _PACKAEG_NAME, 'third_party', 'dependency-check')
_LICENSE_FILE = 'LICENSE'
_LICENSE_DIR = 'LICENSES'
if __name__ == "__main__":
dest_path = os.path.join('src', _PACKAEG_NAME, _LICENSE_DIR)
# Temporarily copy dependency-check bundle inside package for wheel build
try:
if os.path.isdir('third_party/dependency-check'):
if os.path.exists(_TEMP_DC_DIR):
shutil.rmtree(_TEMP_DC_DIR)
os.makedirs(_TEMP_DC_DIR, exist_ok=True)
# Copy tree (shallow manual to preserve permissions)
for root, dirs, files in os.walk('third_party/dependency-check'):
rel_root = os.path.relpath(root, 'third_party/dependency-check')
target_root = os.path.join(_TEMP_DC_DIR, rel_root) if rel_root != '.' else _TEMP_DC_DIR
os.makedirs(target_root, exist_ok=True)
for f in files:
shutil.copy2(os.path.join(root, f), os.path.join(target_root, f))
except Exception as e:
print(f'Warning: Fail to stage dependency-check bundle: {e}')
try:
if not os.path.exists(dest_path):
os.mkdir(dest_path)
if os.path.isfile(_LICENSE_FILE):
shutil.copy(_LICENSE_FILE, dest_path)
if os.path.isdir(_LICENSE_DIR):
license_f = [f_name for f_name in os.listdir(_LICENSE_DIR) if f_name.upper().startswith(_LICENSE_FILE)]
for lic_f in license_f:
shutil.copy(os.path.join(_LICENSE_DIR, lic_f), dest_path)
except Exception as e:
print(f'Warning: Fail to copy the license text: {e}')
setup(
name=_PACKAEG_NAME,
version='5.1.21',
package_dir={"": "src"},
packages=find_packages(where='src'),
description='FOSSLight Binary Scanner',
long_description=readme,
long_description_content_type='text/markdown',
license='Apache-2.0',
author='LG Electronics',
url='https://github.com/fosslight/fosslight_binary_scanner',
download_url='https://github.com/fosslight/fosslight_binary_scanner',
classifiers=['License :: OSI Approved :: Apache Software License',
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12"],
python_requires='>=3.10,<3.13',
install_requires=install_requires,
extras_require={
':sys_platform == "win32"': [
'python-magic-bin'
],
':"darwin" in sys_platform': [
'python-magic'
],
':"linux" in sys_platform': [
'python-magic'
],
},
package_data={
_PACKAEG_NAME: [
os.path.join(_LICENSE_DIR, '*'),
'third_party/dependency-check/bin/*',
'third_party/dependency-check/lib/*',
'third_party/dependency-check/licenses/*',
'third_party/dependency-check/*.txt',
'third_party/dependency-check/*.md',
]
},
include_package_data=True,
entry_points={
"console_scripts": [
"binary_analysis = fosslight_binary.cli:main",
"fosslight_bin = fosslight_binary.cli:main",
"fosslight_binary = fosslight_binary.cli:main",
]
}
)
shutil.rmtree(dest_path, ignore_errors=True)
shutil.rmtree(_TEMP_DC_DIR, ignore_errors=True)