comparison roundup/admin.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 8687c096a945
comparison
equal deleted inserted replaced
6526:3c8322e3fe25 6527:5ad7fb912227
293 1. <roundup.admin.__file__>/../../share/roundup/templates/* 293 1. <roundup.admin.__file__>/../../share/roundup/templates/*
294 this is where they will be if we installed an egg via easy_install 294 this is where they will be if we installed an egg via easy_install
295 2. <prefix>/share/roundup/templates/* 295 2. <prefix>/share/roundup/templates/*
296 this should be the standard place to find them when Roundup is 296 this should be the standard place to find them when Roundup is
297 installed 297 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/*
299 this will be used if Roundup's run in the distro (aka. source) 302 this will be used if Roundup's run in the distro (aka. source)
300 directory 303 directory
301 4. <current working dir>/* 304 5. <current working dir>/*
302 this is for when someone unpacks a 3rd-party template 305 this is for when someone unpacks a 3rd-party template
303 5. <current working dir> 306 6. <current working dir>
304 this is for someone who "cd"s to the 3rd-party template dir 307 this is for someone who "cd"s to the 3rd-party template dir
305 """ 308 """
306 # OK, try <prefix>/share/roundup/templates 309 # OK, try <prefix>/share/roundup/templates
307 # and <egg-directory>/share/roundup/templates 310 # and <egg-directory>/share/roundup/templates
308 # -- this module (roundup.admin) will be installed in something 311 # -- this module (roundup.admin) will be installed in something
327 # search for data files parallel to the roundup 330 # search for data files parallel to the roundup
328 # install dir. E.G. a wheel install 331 # install dir. E.G. a wheel install
329 # use roundup.__path__ and go up a level then use sys.prefix 332 # use roundup.__path__ and go up a level then use sys.prefix
330 # to create a base path for searching. 333 # to create a base path for searching.
331 334
332 import roundup, sys 335 import sys
333 # roundup.__path__ should be something like: 336 # __file__ should be something like:
334 # /usr/local/lib/python3.10/site-packages/roundup 337 # /usr/local/lib/python3.10/site-packages/roundup/admin.py
335 # os.prefix should be /usr, /usr/local or root of virtualenv 338 # os.prefix should be /usr, /usr/local or root of virtualenv
336 # strip leading / to make os.path.join work right. 339 # strip leading / to make os.path.join work right.
337 tdir = os.path.join(os.path.dirname(roundup.__path__[0]), 340 path = __file__
338 sys.prefix[1:], 'share', 'roundup', 'templates') 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')
339 if os.path.isdir(tdir): 346 if os.path.isdir(tdir):
340 templates.update(init.listTemplates(tdir)) 347 templates.update(init.listTemplates(tdir))
341 348
342 # OK, now try as if we're in the roundup source distribution 349 # OK, now try as if we're in the roundup source distribution
343 # directory, so this module will be in .../roundup-*/roundup/admin.py 350 # directory, so this module will be in .../roundup-*/roundup/admin.py

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