Skip to content

Commit 8546d7f

Browse files
committed
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.
1 parent 0d76528 commit 8546d7f

File tree

3 files changed

+28
-16
lines changed

3 files changed

+28
-16
lines changed

roundup/admin.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -295,12 +295,15 @@ def listTemplates(self):
295295
2. <prefix>/share/roundup/templates/*
296296
this should be the standard place to find them when Roundup is
297297
installed
298-
3. <roundup.admin.__file__>/../templates/*
298+
3. <roundup.admin.__file__>/../../<sys.prefix>/share/\
299+
roundup/templates/* which is where they will be found if
300+
roundup is installed as a wheel using pip install
301+
4. <roundup.admin.__file__>/../templates/*
299302
this will be used if Roundup's run in the distro (aka. source)
300303
directory
301-
4. <current working dir>/*
304+
5. <current working dir>/*
302305
this is for when someone unpacks a 3rd-party template
303-
5. <current working dir>
306+
6. <current working dir>
304307
this is for someone who "cd"s to the 3rd-party template dir
305308
"""
306309
# OK, try <prefix>/share/roundup/templates
@@ -329,13 +332,17 @@ def listTemplates(self):
329332
# use roundup.__path__ and go up a level then use sys.prefix
330333
# to create a base path for searching.
331334

332-
import roundup, sys
333-
# roundup.__path__ should be something like:
334-
# /usr/local/lib/python3.10/site-packages/roundup
335+
import sys
336+
# __file__ should be something like:
337+
# /usr/local/lib/python3.10/site-packages/roundup/admin.py
335338
# os.prefix should be /usr, /usr/local or root of virtualenv
336339
# strip leading / to make os.path.join work right.
337-
tdir = os.path.join(os.path.dirname(roundup.__path__[0]),
338-
sys.prefix[1:], 'share', 'roundup', 'templates')
340+
path = __file__
341+
for N in 1, 2:
342+
path = os.path.dirname(path)
343+
# path is /usr/local/lib/python3.10/site-packages
344+
tdir = os.path.join(path, sys.prefix[1:], 'share',
345+
'roundup', 'templates')
339346
if os.path.isdir(tdir):
340347
templates.update(init.listTemplates(tdir))
341348

roundup/i18n.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,16 @@
5858
LOCALE_DIRS.append(_mo_path)
5959
del _mo_path
6060

61-
# find path when locale files are installed as part of a wheel
62-
# roundup.__path__ should be something like:
63-
# /usr/local/lib/python3.10/site-packages/roundup
61+
import sys
62+
# __file__ should be something like:
63+
# /usr/local/lib/python3.10/site-packages/roundup/i18n.py
6464
# os.prefix should be /usr, /usr/local or root of virtualenv
6565
# strip leading / to make os.path.join work right.
66-
import roundup, sys
67-
_ldir = os.path.join(
68-
os.path.dirname(roundup.__path__[0]),
69-
sys.prefix[1:], 'share', 'locale')
66+
path = __file__
67+
for N in 1, 2:
68+
path = os.path.dirname(path)
69+
# path is /usr/local/lib/python3.10/site-packages
70+
_ldir = os.path.join(path, sys.prefix[1:], 'share', 'locale')
7071
if os.path.isdir(_ldir):
7172
LOCALE_DIRS.append(_ldir)
7273
del _ldir

scripts/Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,14 @@ COPY share install/share/
5555
# or install in python3 standard directories from pypi using pip
5656
# import from global/command line
5757
ARG source
58-
RUN set -xv && if [ "$source" = "local" ] || [ "$source" = "pypi" ]; then :; \
58+
RUN set -xv && if [ "$source" = "local" ] || \
59+
[ "$source" = "pypi" ] || \
60+
[ "$source" = "local_pip" ]; then :; \
5961
else echo "invalid value for source: $source"; \
6062
echo "must be local or pypi"; exit 1; fi; \
6163
if [ "$source" = "local" ]; then cd install && ./setup.py install; fi; \
64+
if [ "$source" = "local_pip" ]; then cd install && pip install \
65+
--use-feature=in-tree-build . ; fi; \
6266
if [ "$source" = "pypi" ]; then pip install roundup; \
6367
cp -ril /usr/local/lib/python3.10/site-packages/usr/local/share/* \
6468
/usr/local/share; fi

0 commit comments

Comments
 (0)