From 08f4d63f450ccd96f5077bc60774d8f1fecec92c Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Wed, 16 Nov 2022 18:52:53 +0100 Subject: initial commit --- setup.py | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100755 setup.py (limited to 'setup.py') diff --git a/setup.py b/setup.py new file mode 100755 index 0000000..35683fe --- /dev/null +++ b/setup.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: CC0-1.0 + +# Copyright (C) 2022 Wojtek Kosior +# +# Available under the terms of Creative Commons Zero v1.0 Universal. + +import setuptools + +from setuptools.command.build_py import build_py +from setuptools.command.sdist import sdist +from setuptools import Command + +from pathlib import Path + + +here = Path(__file__).resolve().parent + + +class CustomBuildCommand(build_py): + """The build command but performs some important tasks before the build.""" + def run(self, *args, **kwargs): + """Wrapper around build_py's original run() method.""" + self.run_command('compile_catalog') + self.run_command('copy_licenses') + + super().run(*args, **kwargs) + + +class CopyLicenseFilesCommand(Command): + """ + Command to copy some resources from beneath `LICENSES/` so that they get + included in the wheel and are accessible to Flask. + """ + user_options = [] + + def run (self, *args, **kwargs): + """Copy the relevant license files""" + import shutil + + static_dir = here / 'src' / 'koszko_org_website' / 'static' + licenses_dir = here / 'LICENSES' + + for in_name, out_name in [ + ('LicenseRef-Yahoo-BSD-3', 'yahoo-bsd-license'), + ('LicenseRef-Normalize-CSS-MIT', 'normalize-mit-license'), + ('CC0-1.0', 'cc0-1.0'), + ('CC-BY-3.0', 'cc-by-3.0') + ]: + shutil.copy( + licenses_dir / f'{in_name}.txt', + static_dir / f'{out_name}.txt' + ) + + def initialize_options(self): + pass + + def finalize_options(self): + pass + +setuptools.setup(cmdclass = { + 'build_py': CustomBuildCommand, + 'copy_licenses': CopyLicenseFilesCommand +}) -- cgit v1.2.3