From 6e9bf33c6d30365a8356954f8b1dd187bcf08180 Mon Sep 17 00:00:00 2001
From: Jan Mach <jan.mach@cesnet.cz>
Date: Thu, 28 Feb 2019 09:32:37 +0100
Subject: [PATCH] Master makefile targets for message catalog translations now
 use pybabel directly again.

Previous approach, while better in some aspects caused troubles on our automated build system, because it required for the Mentat to be correctly installed for hawat-cli to be available. (Redmine issue: #3387,#4216)
---
 Makefile                           | 65 +++++++++++++++++-------------
 doc/sphinx/_doclib/development.rst |  4 +-
 2 files changed, 39 insertions(+), 30 deletions(-)

diff --git a/Makefile b/Makefile
index 2fd61a6e4..f69e03acc 100644
--- a/Makefile
+++ b/Makefile
@@ -128,10 +128,8 @@ help:
 	@echo "  * ${GREEN}hpybabel-init INIT_LOCALE=lc${NC}: extract and init Hawat translations for given locale $(FAINT)lc$(NC)"
 	@echo "  * $(GREEN)hpybabel-update$(NC): extract and update Hawat translations"
 	@echo "  * $(GREEN)hpybabel-compile$(NC): compile Hawat translations"
-	@echo "  * ${GREEN}mpybabel-init INIT_LOCALE=lc${NC}: init Mentat translations for given locale $(FAINT)lc$(NC)"
-	@echo "  * $(GREEN)mpybabel-pull$(NC): extract and update Mentat translations"
-	@echo "      - $(ORANGE)mpybabel-extract$(NC): extract Mentat translations"
-	@echo "      - $(ORANGE)mpybabel-update$(NC): update Mentat translations"
+	@echo "  * ${GREEN}mpybabel-init INIT_LOCALE=lc${NC}: extract and init Mentat translations for given locale $(FAINT)lc$(NC)"
+	@echo "  * $(GREEN)mpybabel-update$(NC): extract and update Mentat translations"
 	@echo "  * $(GREEN)mpybabel-compile$(NC): compile Mentat translations"
 	@echo "  * $(GREEN)translations-compile$(NC): compile all available translations"
 	@echo ""
@@ -229,6 +227,20 @@ build-whl: clean build-webui build-package-whl
 #
 build-deb: clean build-webui build-package-deb
 
+#
+#
+#
+install-whl: FORCE
+	@echo "\n${GREEN}*** Performing local installation of Python packages ***${NC}\n"
+	@$(PIP) install dist/mentat-ng*.whl --upgrade --force-reinstall
+
+#
+#
+#
+release-whl: FORCE
+	@echo "\n${GREEN}*** Deploying packages to PyPI ***${NC}\n"
+	@$(TWINE) upload dist/* --skip-existing
+
 
 #===============================================================================
 
@@ -455,55 +467,52 @@ pybabel-patch: FORCE
 	@cd / && patch -p0 -i /var/tmp/babel.messages.frontend.py.patch
 
 #
-# Original solution that used the pybabel utility directly:
-#   @echo "\n$(GREEN)*** Initializing translations for new locale for Hawat user interface ***$(NC)\n"
-#   @echo "Locale name: $(INIT_LOCALE)"
-#   @cd $(DIR_LIB_HAWAT) && $(PYBABEL) extract -F babel.cfg -o messages.pot -k lazy_gettext -k tr_ .
-#   @cd $(DIR_LIB_HAWAT) && $(PYBABEL) init -i messages.pot -d translations -l $(INIT_LOCALE)
+# Alternative solution that uses the hawat-cli utility:
+#   APP_ROOT_PATH=$(shell realpath ./chroot) hawat-cli intl init $(INIT_LOCALE)
 #
 hpybabel-init: FORCE
-	APP_ROOT_PATH=$(shell realpath ./chroot) hawat-cli intl init $(INIT_LOCALE)
+	@echo "\n$(GREEN)*** Initializing translations for new locale for Hawat user interface ***$(NC)\n"
+	@echo "Locale name: $(INIT_LOCALE)"
+	@$(PYBABEL) extract -F $(DIR_LIB_HAWAT)/babel.cfg -o $(DIR_LIB_HAWAT)/messages.pot -k lazy_gettext -k tr_ $(DIR_LIB)
+	@$(PYBABEL) init -i $(DIR_LIB_HAWAT)messages.pot -d $(DIR_LIB_HAWAT)/translations -l $(INIT_LOCALE)
 
 #
-# Original solution that used the pybabel utility directly:
-#   @echo "\n$(GREEN)*** Updating translations for Hawat user interface ***$(NC)\n"
-#   @cd $(DIR_LIB_HAWAT) && $(PYBABEL) extract -F babel.cfg -o messages.pot -k lazy_gettext -k tr_ .
-#   @cd $(DIR_LIB_HAWAT) && $(PYBABEL) update -i messages.pot -d translations
+# Alternative solution that uses the hawat-cli utility:
+#   APP_ROOT_PATH=$(shell realpath ./chroot) hawat-cli intl update
 #
 hpybabel-update: FORCE
-	APP_ROOT_PATH=$(shell realpath ./chroot) hawat-cli intl update
+	@echo "\n$(GREEN)*** Updating translations for Hawat user interface ***$(NC)\n"
+	@$(PYBABEL) extract -F $(DIR_LIB_HAWAT)/babel.cfg -o $(DIR_LIB_HAWAT)/messages.pot -k lazy_gettext -k tr_ $(DIR_LIB)
+	@$(PYBABEL) update -i $(DIR_LIB_HAWAT)/messages.pot -d $(DIR_LIB_HAWAT)/translations
 
 #
-# Original solution that used the pybabel utility directly:
-#   @echo "\n$(GREEN)*** Compiling translations for Hawat user interface ***$(NC)\n"
-#   @cd $(DIR_LIB_HAWAT) && $(PYBABEL) compile -d translations
+# Alternative solution that uses the hawat-cli utility:
+#   APP_ROOT_PATH=$(shell realpath ./chroot) hawat-cli intl compile
 #
 hpybabel-compile: FORCE
-	APP_ROOT_PATH=$(shell realpath ./chroot) hawat-cli intl compile
+	@echo "\n$(GREEN)*** Compiling translations for Hawat user interface ***$(NC)\n"
+	@$(PYBABEL) compile -d $(DIR_LIB_HAWAT)/translations
 
 
-mpybabel-extract: FORCE
-	@echo "\n$(GREEN)*** Extracting babel translations for Mentat ***$(NC)\n"
-	@$(PYBABEL) extract -F $(DIR_TEMPLATES_INFORMANT)/babel.cfg -o $(DIR_TEMPLATES_INFORMANT)/messages.pot -k lazy_gettext -k tr_ .
-	@$(PYBABEL) extract -F $(DIR_TEMPLATES_REPORTER)/babel.cfg -o $(DIR_TEMPLATES_REPORTER)/messages.pot -k lazy_gettext -k tr_ .
-	@$(PYBABEL) extract -F $(DIR_TEMPLATES_UTEST)/babel.cfg -o $(DIR_TEMPLATES_UTEST)/messages.pot -k lazy_gettext -k tr_ .
-
 mpybabel-init: FORCE
 	@echo "\n$(GREEN)*** Initializing translations for new locale for Mentat ***$(NC)\n"
 	@echo "Locale name: $(INIT_LOCALE)"
+	@$(PYBABEL) extract -F $(DIR_TEMPLATES_INFORMANT)/babel.cfg -o $(DIR_TEMPLATES_INFORMANT)/messages.pot -k lazy_gettext -k tr_ .
+	@$(PYBABEL) extract -F $(DIR_TEMPLATES_REPORTER)/babel.cfg -o $(DIR_TEMPLATES_REPORTER)/messages.pot -k lazy_gettext -k tr_ .
+	@$(PYBABEL) extract -F $(DIR_TEMPLATES_UTEST)/babel.cfg -o $(DIR_TEMPLATES_UTEST)/messages.pot -k lazy_gettext -k tr_ .
 	@$(PYBABEL) init -i $(DIR_TEMPLATES_INFORMANT)/messages.pot -d $(DIR_TEMPLATES_INFORMANT)/translations -l $(INIT_LOCALE)
 	@$(PYBABEL) init -i $(DIR_TEMPLATES_REPORTER)/messages.pot -d $(DIR_TEMPLATES_REPORTER)/translations -l $(INIT_LOCALE)
 	@$(PYBABEL) init -i $(DIR_TEMPLATES_UTEST)/messages.pot -d $(DIR_TEMPLATES_UTEST)/translations -l $(INIT_LOCALE)
-	@echo ""
 
 mpybabel-update: FORCE
 	@echo "\n$(GREEN)*** Updating translations for Mentat ***$(NC)\n"
+	@$(PYBABEL) extract -F $(DIR_TEMPLATES_INFORMANT)/babel.cfg -o $(DIR_TEMPLATES_INFORMANT)/messages.pot -k lazy_gettext -k tr_ .
+	@$(PYBABEL) extract -F $(DIR_TEMPLATES_REPORTER)/babel.cfg -o $(DIR_TEMPLATES_REPORTER)/messages.pot -k lazy_gettext -k tr_ .
+	@$(PYBABEL) extract -F $(DIR_TEMPLATES_UTEST)/babel.cfg -o $(DIR_TEMPLATES_UTEST)/messages.pot -k lazy_gettext -k tr_ .
 	@$(PYBABEL) update -i $(DIR_TEMPLATES_INFORMANT)/messages.pot -d $(DIR_TEMPLATES_INFORMANT)/translations
 	@$(PYBABEL) update -i $(DIR_TEMPLATES_REPORTER)/messages.pot -d $(DIR_TEMPLATES_REPORTER)/translations
 	@$(PYBABEL) update -i $(DIR_TEMPLATES_UTEST)/messages.pot -d $(DIR_TEMPLATES_UTEST)/translations
 
-mpybabel-pull: mpybabel-extract mpybabel-update
-
 mpybabel-compile: FORCE
 	@echo "\n$(GREEN)*** Compiling translations for Mentat ***$(NC)\n"
 	@$(PYBABEL) compile -d $(DIR_TEMPLATES_INFORMANT)/translations
diff --git a/doc/sphinx/_doclib/development.rst b/doc/sphinx/_doclib/development.rst
index cd9ea919d..3d059e64b 100644
--- a/doc/sphinx/_doclib/development.rst
+++ b/doc/sphinx/_doclib/development.rst
@@ -387,8 +387,8 @@ follow this procedure::
 	# When you are happy with your translations compile the message catalogs with:
 	(venv) $ make hpybabel-compile
 
-Similarly the ``make mpybabel-pull`` and ``make hpybabel-compile`` targets can be
-used to compile translations of various Mentat reports. These are located in
+Similarly the ``make mpybabel-update`` and ``make hpybabel-compile`` targets can be
+used to compile translations of Mentat reporting templates. These are located in
 following directories:
 
 * ``conf/templates/informant/``: Report templates for :ref:`section-bin-mentat-informant`.
-- 
GitLab