Skip to content

Commit 23e58fd

Browse files
authored
Merge pull request #75 from fosslight/develop
Print license text through notice parameter
2 parents 0ad62c8 + 591644c commit 23e58fd

File tree

5 files changed

+49
-22
lines changed

5 files changed

+49
-22
lines changed

.github/workflows/publish-release.yml

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -59,32 +59,32 @@ jobs:
5959
- os: ubuntu-18.04
6060
TARGET: ubuntu
6161
CMD_BUILD: >
62-
pyinstaller --onefile cli.py -n cli --additional-hooks-dir=hooks &&
62+
pyinstaller --onefile cli.py -n cli --additional-hooks-dir=hooks --add-binary "LICENSE:LICENSES" --add-binary "LICENSES/LicenseRef-3rd_party_licenses.txt:LICENSES" &&
6363
mv dist/cli fosslight_bin_ubuntu18
6464
OUT_FILE_NAME: fosslight_bin_ubuntu18
6565
ASSET_MIME: application/octet-stream
6666
- os: macos-latest
6767
TARGET: macos
6868
CMD_BUILD: >
69-
pyinstaller --onefile cli.py -n cli --additional-hooks-dir=hooks &&
69+
pyinstaller --onefile cli.py -n cli --additional-hooks-dir=hooks --add-binary "LICENSE:LICENSES" --add-binary "LICENSES/LicenseRef-3rd_party_licenses.txt:LICENSES" &&
7070
mv dist/cli fosslight_bin_macos
7171
OUT_FILE_NAME: fosslight_bin_macos
7272
ASSET_MIME: aapplication/x-mach-binary
7373
- os: windows-latest
7474
TARGET: windows
7575
CMD_BUILD: >
76-
pyinstaller --onefile cli.py -n cli --additional-hooks-dir=hooks &&
76+
pyinstaller --onefile cli.py -n cli --additional-hooks-dir=hooks --add-binary "LICENSE;LICENSES" --add-binary "LICENSES\LicenseRef-3rd_party_licenses.txt;LICENSES" &&
7777
move dist/cli.exe fosslight_bin_windows.exe
7878
OUT_FILE_NAME: fosslight_bin_windows.exe
7979
ASSET_MIME: application/vnd.microsoft.portable-executable
8080
steps:
8181
- uses: actions/checkout@v2
8282
with:
8383
ref: main
84-
- name: Set up Python 3.6
84+
- name: Set up Python 3.8
8585
uses: actions/setup-python@v2
8686
with:
87-
python-version: 3.6
87+
python-version: '3.8'
8888
- name: Install dependencies
8989
run: |
9090
python -m pip install --upgrade pip
@@ -112,7 +112,7 @@ jobs:
112112
- name: Set up Python
113113
uses: actions/setup-python@v2
114114
with:
115-
python-version: '3.7'
115+
python-version: '3.8'
116116
- name: Install dependencies
117117
run: |
118118
python -m pip install --upgrade pip
@@ -124,13 +124,3 @@ jobs:
124124
run: |
125125
python setup.py sdist bdist_wheel
126126
twine upload dist/*
127-
- name: Upload Release 3rd Party License text
128-
id: upload-release-license
129-
uses: actions/[email protected]
130-
env:
131-
GITHUB_TOKEN: ${{ secrets.TOKEN }}
132-
with:
133-
upload_url: ${{ github.event.release.upload_url }}
134-
asset_path: ./LICENSES/LicenseRef-3rd_party_licenses.txt
135-
asset_name: LicenseRef-3rd_party_licenses.txt
136-
asset_content_type: text/plain

.github/workflows/pull-request.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
runs-on: ubuntu-latest
3535
strategy:
3636
matrix:
37-
python-version: [3.6]
37+
python-version: [3.8]
3838

3939
steps:
4040
- uses: actions/checkout@v2
@@ -55,13 +55,13 @@ jobs:
5555
runs-on: windows-latest
5656
strategy:
5757
matrix:
58-
python-version: [3.6]
58+
python-version: [3.8]
5959
steps:
6060
- uses: actions/checkout@v2
61-
- name: Set up Python 3.6
61+
- name: Set up Python 3.8
6262
uses: actions/setup-python@v2
6363
with:
64-
python-version: 3.6
64+
python-version: '3.8'
6565
- name: Install & Run
6666
run: |
6767
python -m pip install --upgrade pip

setup.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# Copyright (c) 2021 LG Electronics Inc.
44
# SPDX-License-Identifier: Apache-2.0
55
from codecs import open
6+
import os
7+
import shutil
68
from setuptools import setup, find_packages
79

810
with open('README.md', 'r', 'utf-8') as f:
@@ -11,9 +13,26 @@
1113
with open('requirements.txt', 'r', 'utf-8') as f:
1214
install_requires = f.read().splitlines()
1315

16+
_PACKAEG_NAME = 'fosslight_binary'
17+
_LICENSE_FILE = 'LICENSE'
18+
_LICENSE_DIR = 'LICENSES'
19+
1420
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+
1534
setup(
16-
name='fosslight_binary',
35+
name=_PACKAEG_NAME,
1736
version='4.1.12',
1837
package_dir={"": "src"},
1938
packages=find_packages(where='src'),
@@ -42,6 +61,8 @@
4261
'python-magic'
4362
],
4463
},
64+
package_data={_PACKAEG_NAME: [os.path.join(_LICENSE_DIR, '*')]},
65+
include_package_data=True,
4566
entry_points={
4667
"console_scripts": [
4768
"binary_analysis = fosslight_binary.cli:main",
@@ -50,3 +71,4 @@
5071
]
5172
}
5273
)
74+
shutil.rmtree(dest_path, ignore_errors=True)

src/fosslight_binary/_help.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
-o <output_path>\t\t Output path
1818
\t\t\t\t (If you want to generate the specific file name, add the output path with file name.)
1919
-f <format>\t\t\t Output file format (excel, csv, opossum, yaml)
20-
-d <db_url>\t\t\t DB Connection(format :'postgresql://username:password@host:port/database_name')"""
20+
-d <db_url>\t\t\t DB Connection(format :'postgresql://username:password@host:port/database_name')
21+
--notice\t\t\t Print the open source license notice text."""
2122

2223

2324
def print_help_msg():

src/fosslight_binary/cli.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def main():
2727
parser.add_argument('-o', '--output', type=str, required=False)
2828
parser.add_argument('-d', '--dburl', type=str, default='', required=False)
2929
parser.add_argument('-f', '--format', type=str, required=False)
30+
parser.add_argument('--notice', action='store_true', required=False)
3031

3132
try:
3233
args = parser.parse_args()
@@ -55,6 +56,19 @@ def main():
5556
if args.format: # -f option
5657
format = args.format
5758

59+
if args.notice: # --notice option
60+
try:
61+
base_path = sys._MEIPASS
62+
except Exception:
63+
base_path = os.path.dirname(__file__)
64+
65+
data_path = os.path.join(base_path, 'LICENSES')
66+
print(f"*** {_PKG_NAME} open source license notice ***")
67+
for ff in os.listdir(data_path):
68+
f = open(os.path.join(data_path, ff), 'r', encoding='utf8')
69+
print(f.read())
70+
sys.exit(0)
71+
5872
timer = TimerThread()
5973
timer.setDaemon(True)
6074
timer.start()

0 commit comments

Comments
 (0)