diff roundup/i18n.py @ 6527:5ad7fb912227

issue2551167 - update wheel support. New method for finding locale and template files when installed as a wheel. It acts more like existing code for egg support. Add build-arg source=local_pip for building using pip using the local files rather than downloading from pypi. Useful for testing these changes. Since it's developer testing code and still has the downside that man pages aren't accessible, I am not documenting it as an option.
author John Rouillard <rouilj@ieee.org>
date Sun, 07 Nov 2021 12:19:27 -0500
parents f961dbbc3573
children 01216187a167
line wrap: on
line diff
--- a/roundup/i18n.py	Sun Nov 07 01:47:07 2021 -0500
+++ b/roundup/i18n.py	Sun Nov 07 12:19:27 2021 -0500
@@ -58,15 +58,16 @@
     LOCALE_DIRS.append(_mo_path)
 del _mo_path
 
-# find path when locale files are installed as part of a wheel
-# roundup.__path__ should be something like:
-#    /usr/local/lib/python3.10/site-packages/roundup
+import sys
+# __file__ should be something like:
+#    /usr/local/lib/python3.10/site-packages/roundup/i18n.py
 # os.prefix should be /usr, /usr/local or root of virtualenv
 #    strip leading / to make os.path.join work right.
-import roundup, sys
-_ldir = os.path.join(
-    os.path.dirname(roundup.__path__[0]),
-    sys.prefix[1:], 'share', 'locale')
+path = __file__
+for N in 1, 2:
+    path = os.path.dirname(path)
+    # path is /usr/local/lib/python3.10/site-packages
+_ldir = os.path.join(path, sys.prefix[1:], 'share', 'locale')
 if os.path.isdir(_ldir):
     LOCALE_DIRS.append(_ldir)
 del _ldir

Roundup Issue Tracker: http://roundup-tracker.org/