Skip to content

Commit 45d0f4e

Browse files
authored
Merge pull request #112 from fosslight/develop
Print license text through notice parameter
2 parents a249cbd + 71d89f6 commit 45d0f4e

File tree

6 files changed

+40
-18
lines changed

6 files changed

+40
-18
lines changed

.github/workflows/publish-release.yml

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,18 @@ jobs:
6060
- os: windows-latest
6161
TARGET: windows
6262
CMD_BUILD: >
63-
pyinstaller --onefile cli.py -n cli --additional-hooks-dir=hooks &&
63+
pyinstaller --onefile cli.py -n cli --additional-hooks-dir=hooks --add-binary "LICENSE;LICENSES" --add-binary "LICENSES\LicenseRef-3rd_party_licenses.txt;LICENSES" &&
6464
move dist/cli.exe fosslight_prechecker_windows.exe
6565
OUT_FILE_NAME: fosslight_prechecker_windows.exe
6666
ASSET_MIME: application/vnd.microsoft.portable-executable
6767
steps:
6868
- uses: actions/checkout@v2
6969
with:
7070
ref: main
71-
- name: Set up Python 3.6
71+
- name: Set up Python 3.8
7272
uses: actions/setup-python@v2
7373
with:
74-
python-version: 3.6
74+
python-version: '3.8'
7575
- name: Install dependencies
7676
run: |
7777
python -m pip install --upgrade pip
@@ -100,7 +100,7 @@ jobs:
100100
- name: Set up Python
101101
uses: actions/setup-python@v2
102102
with:
103-
python-version: '3.7'
103+
python-version: '3.8'
104104
- name: Install dependencies
105105
run: |
106106
python -m pip install --upgrade pip
@@ -112,13 +112,3 @@ jobs:
112112
run: |
113113
python setup.py sdist bdist_wheel
114114
twine upload dist/*
115-
- name: Upload Release 3rd Party License text
116-
id: upload-release-license
117-
uses: actions/[email protected]
118-
env:
119-
GITHUB_TOKEN: ${{ secrets.TOKEN }}
120-
with:
121-
upload_url: ${{ github.event.release.upload_url }}
122-
asset_path: ./LICENSES/LicenseRef-3rd_party_licenses.txt
123-
asset_name: LicenseRef-3rd_party_licenses.txt
124-
asset_content_type: text/plain

.github/workflows/pull-request.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ jobs:
5353
ASSET_MIME: application/vnd.microsoft.portable-executable
5454
steps:
5555
- uses: actions/checkout@v2
56-
- name: Set up Python 3.6
56+
- name: Set up Python 3.8
5757
uses: actions/setup-python@v2
5858
with:
59-
python-version: 3.6
59+
python-version: '3.8'
6060
- name: Install dependencies
6161
run: |
6262
python -m pip install --upgrade pip

setup.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# Copyright (c) 2021 LG Electronics
44
# SPDX-License-Identifier: GPL-3.0-only
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,7 +13,24 @@
1113
with open('requirements.txt', 'r', 'utf-8') as f:
1214
required = f.read().splitlines()
1315

16+
_PACKAEG_NAME = 'fosslight_prechecker'
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(
1635
name='fosslight_prechecker',
1736
version='3.0.9',
@@ -32,7 +51,7 @@
3251
"Programming Language :: Python :: 3.8",
3352
"Programming Language :: Python :: 3.9"],
3453
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, '*')]},
3655
include_package_data=True,
3756
entry_points={
3857
"console_scripts": [
@@ -41,3 +60,4 @@
4160
]
4261
}
4362
)
63+
shutil.rmtree(dest_path, ignore_errors=True)

src/fosslight_prechecker/_help.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
-o <file_name>\t Output file name
2828
-n\t\t\t Don't exclude venv*, node_modules, and .*/ from the analysis
2929
-i\t\t\t Don't both write log file and show progress bar
30+
--notice\t\t Print the open source license notice text.
3031
3132
Options for only 'add' mode
3233
-l <license>\t License name(SPDX format) to add

src/fosslight_prechecker/cli.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def main():
3636
parser.add_argument('-o', '--output', help='Output file name', type=str, dest='output', default="")
3737
parser.add_argument('-l', '--license', help='License name to add', type=str, dest='license', default="")
3838
parser.add_argument('-c', '--copyright', help='Copyright to add', type=str, dest='copyright', default="")
39+
parser.add_argument('--notice', action='store_true', required=False)
3940
try:
4041
args = parser.parse_args()
4142
except SystemExit:
@@ -48,6 +49,17 @@ def main():
4849
print_help_msg()
4950
elif args.version:
5051
print_package_version(PKG_NAME, "FOSSLight Prechecker Version")
52+
elif args.notice:
53+
try:
54+
base_path = sys._MEIPASS
55+
except Exception:
56+
base_path = os.path.dirname(__file__)
57+
58+
data_path = os.path.join(base_path, 'LICENSES')
59+
print(f"*** {PKG_NAME} open source license notice ***")
60+
for ff in os.listdir(data_path):
61+
f = open(os.path.join(data_path, ff), 'r', encoding='utf8')
62+
print(f.read())
5163
else:
5264
run_main(args.mode, args.path, args.output, args.format,
5365
args.log, args.disable, args.copyright, args.license)

tox.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ skipdist = true
66

77
[testenv]
88
install_command = pip install {opts} {packages}
9-
basepython= python3.6
109
whitelist_externals = cat
1110
cp
1211
rm

0 commit comments

Comments
 (0)