aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWojtek Kosior <koszko@koszko.org>2022-06-14 10:46:17 +0200
committerWojtek Kosior <koszko@koszko.org>2022-06-14 10:46:17 +0200
commit36996331c8fa55707a0f2e3c6c51acc5603e92c4 (patch)
treea6f4d91bedd1c8b1ebf3043f1f2374ad8f1e6f6a
parent27a179424cbba002a65393eb92c247866b5bda99 (diff)
downloadhaketilo-hydrilla-36996331c8fa55707a0f2e3c6c51acc5603e92c4.tar.gz
haketilo-hydrilla-36996331c8fa55707a0f2e3c6c51acc5603e92c4.zip
improve packaging of data files
This commit stops setuptools from presenting a depracetion warning. This commit ensures .mo files will not be included in source distributions.
-rw-r--r--setup.cfg2
-rwxr-xr-xsetup.py37
2 files changed, 34 insertions, 5 deletions
diff --git a/setup.cfg b/setup.cfg
index e18c8ae..8bdce93 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -31,7 +31,7 @@ classifiers =
zip_safe = False
package_dir =
= src
-packages = find:
+packages = find_namespace:
include_package_data=True
python_requires = >= 3.7
install_requires =
diff --git a/setup.py b/setup.py
index 345febc..3aa9f74 100755
--- a/setup.py
+++ b/setup.py
@@ -8,13 +8,42 @@
import setuptools
from setuptools.command.build_py import build_py
+from setuptools.command.sdist import sdist
+
+from pathlib import Path
+
+here = Path(__file__).resolve().parent
class CustomBuildCommand(build_py):
- '''
- The build command but runs babel before build.
- '''
+ """The build command but runs babel before build."""
def run(self, *args, **kwargs):
+ """Wrapper around build_py's original run() method."""
self.run_command('compile_catalog')
+
+ super().run(*args, **kwargs)
+
+class CustomSdistCommand(sdist):
+ """
+ The sdist command but prevents compiled message catalogs from being included
+ in the archive.
+ """
+ def run(self, *args, **kwargs):
+ """Wrapper around sdist's original run() method."""
+ locales_dir = here / 'src/hydrilla/server/locales'
+ locale_files = {}
+
+ for path in locales_dir.rglob('*.mo'):
+ locale_files[path] = path.read_bytes()
+
+ for path in locale_files:
+ path.unlink()
+
super().run(*args, **kwargs)
-setuptools.setup(cmdclass={'build_py': CustomBuildCommand})
+ for path, contents in locale_files.items():
+ path.write_bytes(contents)
+
+setuptools.setup(cmdclass = {
+ 'build_py': CustomBuildCommand,
+ 'sdist': CustomSdistCommand
+})