Mercurial > p > roundup > code
changeset 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 | 3c8322e3fe25 |
| children | 6cf050b43eaf |
| files | roundup/admin.py roundup/i18n.py scripts/Dockerfile |
| diffstat | 3 files changed, 28 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/roundup/admin.py Sun Nov 07 01:47:07 2021 -0500 +++ b/roundup/admin.py Sun Nov 07 12:19:27 2021 -0500 @@ -295,12 +295,15 @@ 2. <prefix>/share/roundup/templates/* this should be the standard place to find them when Roundup is installed - 3. <roundup.admin.__file__>/../templates/* + 3. <roundup.admin.__file__>/../../<sys.prefix>/share/\ + roundup/templates/* which is where they will be found if + roundup is installed as a wheel using pip install + 4. <roundup.admin.__file__>/../templates/* this will be used if Roundup's run in the distro (aka. source) directory - 4. <current working dir>/* + 5. <current working dir>/* this is for when someone unpacks a 3rd-party template - 5. <current working dir> + 6. <current working dir> this is for someone who "cd"s to the 3rd-party template dir """ # OK, try <prefix>/share/roundup/templates @@ -329,13 +332,17 @@ # use roundup.__path__ and go up a level then use sys.prefix # to create a base path for searching. - import roundup, sys - # 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/admin.py # os.prefix should be /usr, /usr/local or root of virtualenv # strip leading / to make os.path.join work right. - tdir = os.path.join(os.path.dirname(roundup.__path__[0]), - sys.prefix[1:], 'share', 'roundup', 'templates') + path = __file__ + for N in 1, 2: + path = os.path.dirname(path) + # path is /usr/local/lib/python3.10/site-packages + tdir = os.path.join(path, sys.prefix[1:], 'share', + 'roundup', 'templates') if os.path.isdir(tdir): templates.update(init.listTemplates(tdir))
--- 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
--- a/scripts/Dockerfile Sun Nov 07 01:47:07 2021 -0500 +++ b/scripts/Dockerfile Sun Nov 07 12:19:27 2021 -0500 @@ -55,10 +55,14 @@ # or install in python3 standard directories from pypi using pip # import from global/command line ARG source -RUN set -xv && if [ "$source" = "local" ] || [ "$source" = "pypi" ]; then :; \ +RUN set -xv && if [ "$source" = "local" ] || \ + [ "$source" = "pypi" ] || \ + [ "$source" = "local_pip" ]; then :; \ else echo "invalid value for source: $source"; \ echo "must be local or pypi"; exit 1; fi; \ if [ "$source" = "local" ]; then cd install && ./setup.py install; fi; \ + if [ "$source" = "local_pip" ]; then cd install && pip install \ + --use-feature=in-tree-build . ; fi; \ if [ "$source" = "pypi" ]; then pip install roundup; \ cp -ril /usr/local/lib/python3.10/site-packages/usr/local/share/* \ /usr/local/share; fi
