Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print license text through notice parameter #112

Merged
merged 2 commits into from
Oct 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 4 additions & 14 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,18 @@ jobs:
- os: windows-latest
TARGET: windows
CMD_BUILD: >
pyinstaller --onefile cli.py -n cli --additional-hooks-dir=hooks &&
pyinstaller --onefile cli.py -n cli --additional-hooks-dir=hooks --add-binary "LICENSE;LICENSES" --add-binary "LICENSES\LicenseRef-3rd_party_licenses.txt;LICENSES" &&
move dist/cli.exe fosslight_prechecker_windows.exe
OUT_FILE_NAME: fosslight_prechecker_windows.exe
ASSET_MIME: application/vnd.microsoft.portable-executable
steps:
- uses: actions/checkout@v2
with:
ref: main
- name: Set up Python 3.6
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.6
python-version: '3.8'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down Expand Up @@ -100,7 +100,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.7'
python-version: '3.8'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -112,13 +112,3 @@ jobs:
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
- name: Upload Release 3rd Party License text
id: upload-release-license
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./LICENSES/LicenseRef-3rd_party_licenses.txt
asset_name: LicenseRef-3rd_party_licenses.txt
asset_content_type: text/plain
4 changes: 2 additions & 2 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ jobs:
ASSET_MIME: application/vnd.microsoft.portable-executable
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.6
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.6
python-version: '3.8'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
22 changes: 21 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# Copyright (c) 2021 LG Electronics
# SPDX-License-Identifier: GPL-3.0-only
from codecs import open
import os
import shutil
from setuptools import setup, find_packages

with open('README.md', 'r', 'utf-8') as f:
Expand All @@ -11,7 +13,24 @@
with open('requirements.txt', 'r', 'utf-8') as f:
required = f.read().splitlines()

_PACKAEG_NAME = 'fosslight_prechecker'
_LICENSE_FILE = 'LICENSE'
_LICENSE_DIR = 'LICENSES'

if __name__ == "__main__":
dest_path = os.path.join('src', _PACKAEG_NAME, _LICENSE_DIR)
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='fosslight_prechecker',
version='3.0.7',
Expand All @@ -32,7 +51,7 @@
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9"],
install_requires=required,
package_data={'fosslight_prechecker': ['resources/convert_license.json']},
package_data={_PACKAEG_NAME: ['resources/convert_license.json', os.path.join(_LICENSE_DIR, '*')]},
include_package_data=True,
entry_points={
"console_scripts": [
Expand All @@ -41,3 +60,4 @@
]
}
)
shutil.rmtree(dest_path, ignore_errors=True)
1 change: 1 addition & 0 deletions src/fosslight_prechecker/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
-o <file_name>\t Output file name
-n\t\t\t Don't exclude venv*, node_modules, and .*/ from the analysis
-i\t\t\t Don't both write log file and show progress bar
--notice\t\t Print the open source license notice text.

Options for only 'add' mode
-l <license>\t License name(SPDX format) to add
Expand Down
12 changes: 12 additions & 0 deletions src/fosslight_prechecker/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def main():
parser.add_argument('-o', '--output', help='Output file name', type=str, dest='output', default="")
parser.add_argument('-l', '--license', help='License name to add', type=str, dest='license', default="")
parser.add_argument('-c', '--copyright', help='Copyright to add', type=str, dest='copyright', default="")
parser.add_argument('--notice', action='store_true', required=False)
try:
args = parser.parse_args()
except SystemExit:
Expand All @@ -48,6 +49,17 @@ def main():
print_help_msg()
elif args.version:
print_package_version(PKG_NAME, "FOSSLight Prechecker Version")
elif args.notice:
try:
base_path = sys._MEIPASS
except Exception:
base_path = os.path.dirname(__file__)

data_path = os.path.join(base_path, 'LICENSES')
print(f"*** {PKG_NAME} open source license notice ***")
for ff in os.listdir(data_path):
f = open(os.path.join(data_path, ff), 'r', encoding='utf8')
print(f.read())
else:
run_main(args.mode, args.path, args.output, args.format,
args.log, args.disable, args.copyright, args.license)
Expand Down
1 change: 0 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ skipdist = true

[testenv]
install_command = pip install {opts} {packages}
basepython= python3.6
whitelist_externals = cat
cp
rm
Expand Down