aboutsummaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorWojtek Kosior <koszko@koszko.org>2022-11-16 18:52:53 +0100
committerWojtek Kosior <koszko@koszko.org>2022-11-16 21:43:50 +0100
commit08f4d63f450ccd96f5077bc60774d8f1fecec92c (patch)
tree7f09941d62ca23737bc0b1f616d2d50eb7dd14af /setup.py
downloadkoszko-org-website-08f4d63f450ccd96f5077bc60774d8f1fecec92c.tar.gz
koszko-org-website-08f4d63f450ccd96f5077bc60774d8f1fecec92c.zip
initial commitv2022.11.16
Diffstat (limited to 'setup.py')
-rwxr-xr-xsetup.py64
1 files changed, 64 insertions, 0 deletions
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 <koszko@koszko.org>
+#
+# 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
+})