diff options
| author | untodesu <kirill@untode.su> | 2025-06-28 01:59:49 +0500 |
|---|---|---|
| committer | untodesu <kirill@untode.su> | 2025-06-28 01:59:49 +0500 |
| commit | 61e5bcef2629e2d68b805a956a96fff264d4f74d (patch) | |
| tree | bca3a94bac79d34e3c0db57c77604f5a823ecbda /thirdpartylegalnotices.py | |
| parent | 88c01588aa0830e219eaa62588839e4d1e2883ce (diff) | |
| download | voxelius-61e5bcef2629e2d68b805a956a96fff264d4f74d.tar.bz2 voxelius-61e5bcef2629e2d68b805a956a96fff264d4f74d.zip | |
Restructure dependencies and update to C++20
- Nuked static_assert from almost everywhere in the project
- Nuked binary dependency support. Might add one later though
- Separated dependency headers into a separate include subdirectory
- Grafted a thirdpartylegalnotices.txt generator from RITEG
- Pushed development snapshot version to 2126 (26th week of 2025)
Diffstat (limited to 'thirdpartylegalnotices.py')
| -rw-r--r-- | thirdpartylegalnotices.py | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/thirdpartylegalnotices.py b/thirdpartylegalnotices.py new file mode 100644 index 0000000..64bb03b --- /dev/null +++ b/thirdpartylegalnotices.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python3 + +import os + +# It is quite annoying to have to write all the dependency notices +# by hand, so this script goes through the dependency list and generates +# a file with all the licenses automatically during the build process + +def read_description_file(subdirectory): + description_filename = "DESCRIPTION" + description_extensions = [ "", ".txt", ".md", ".rst" ] + for extension in description_extensions: + fill_path = os.path.join(subdirectory, description_filename + extension) + if os.path.exists(fill_path): + with open(fill_path, 'r', encoding='utf-8') as file: + return file.read().rstrip().splitlines()[0] + return None + +def read_license_file(subdirectory): + license_filenames = [ "LICENSE", "COPYING", "NOTICE" ] + license_extensions = [ "", ".txt", ".md", ".rst" ] + for filename in license_filenames: + for extension in license_extensions: + fill_path = os.path.join(subdirectory, filename + extension) + if os.path.exists(fill_path): + with open(fill_path, 'r', encoding='utf-8') as file: + return file.read().rstrip() + return None + +def get_dependencies(directory): + dependencies = [] + for subdirectory in os.listdir(directory): + subdirectory_path = os.path.join(directory, subdirectory) + if os.path.isdir(subdirectory_path): + license = read_license_file(subdirectory_path) + description = read_description_file(subdirectory_path) + if description and len(description) > 80: + description = description[:77] + "..." + if license: + dependencies.append((subdirectory, license, description)) + return dependencies + +assert len(os.sys.argv) > 1, "Please provide the path to the dependencies directory." +dependencies_dir = os.sys.argv[1] +dependencies = get_dependencies(dependencies_dir) +assert len(dependencies) > 0, "No licenses found in the dependencies directory." + +with open("thirdpartylegalnotices.txt", 'w', encoding='utf-8') as out_file: + out_file.write("Voxelius uses third-party code for certain functions. All the\n") + out_file.write("license texts are included below using an automated script; this generated\n") + out_file.write("file is to be included in binary distributions of the project.\n\n") + + for name, license, description in dependencies: + out_file.write(f"{'=' * 80}\n") + if description and len(description) > 0: + out_file.write(f"{name} - {description}\n") + else: + out_file.write(f"{name}\n") + out_file.write(f"{'=' * 80}\n") + out_file.write(f"{license}\n\n\n") |
