Edgewall Software
Modify

Opened 15 years ago

Closed 14 years ago

Last modified 14 years ago

#8062 closed defect (fixed)

Trac can't be installed as zip-safe egg

Reported by: Christian Boos Owned by: Christian Boos
Priority: normal Milestone: 0.12
Component: general Version: 0.12dev
Severity: normal Keywords: setuptools egg i18n
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

This comes as a follow-up to #7877, which was about a problem in the TracMercurial plugin, where the line:

pkg_resources.resource_filename(__name__, '../locale')

would fail when the plugin was installed as an egg.

Now Trac itself has the same construction in trac/util/text.py, and it seems to have exactly the same issue:

  • when Trac egg is flagged zip-unsafe, it gets extracted in site-packages when easy_installed, then the pkg_resources.resource_filename(__name__, '../locale') call works fine
  • when Trac egg is as zip-safe, easy_install simply copies the egg in site-packages , and then Trac fails with a KeyError:
    Traceback (most recent call last):
      File "build\bdist.win32\egg\trac\web\api.py", line 372, in send_error
        translation.activate(self.locale, env.path)
      File "build\bdist.win32\egg\trac\util\translation.py", line 250, in activate
        translations.activate(locale, env_path)
      File "build\bdist.win32\egg\trac\util\translation.py", line 114, in activate
        locale_dir = pkg_resources.resource_filename(__name__, '../locale')
      File "C:\Workspace\src\trac\dependencies\setuptools\pkg_resources.py", line 841, in resource_filename
        self, resource_name
      File "C:\Workspace\src\trac\dependencies\setuptools\pkg_resources.py", line 1311, in get_resource_filename
        return self._extract_resource(manager, zip_path)
      File "C:\Workspace\src\trac\dependencies\setuptools\pkg_resources.py", line 1322, in _extract_resource
        zip_stat = self.zipinfo[zip_path]
    KeyError: 'trac\\util\\..\\locale'
    

Attachments (1)

t8062-zip_safe-install-r7886.diff (1.4 KB ) - added by Christian Boos 15 years ago.
make Trac installable as zip_safe

Download all attachments as: .zip

Change History (5)

by Christian Boos, 15 years ago

make Trac installable as zip_safe

comment:1 by Christian Boos, 15 years ago

Now I wonder, the zip_safe=False setting dates back from the SetupTools branch integration, so maybe there are other reasons why the Trac can't be made zip_safe? But in my tests with tracd, everything seemed to work fine after that change.

Well, everything but an issue with the locale selector being None, cascading in several bad effects. That was fixed by the change:

t = Translations.load(locale_dir, locale or 'en_US') 

which you can find commented out in the patch. Once I re-selected explicitly a language in the preference, the need for that change went away. Anyway, this seems to be a different issue.

comment:2 by Christian Boos, 15 years ago

Parts of the patch committed in r8494.

zip_safe was still left to False in setup.py though, as I don't know if changing that wouldn't introduce some unexpected issue…

comment:3 by Christian Boos, 14 years ago

Keywords: setuptools added
Resolution: fixed
Status: newclosed

Well, if there's any problem found with Trac installed as a zipped .egg, please let us know and reopen ;-)

Zip-safe flag enabled in [8787].

comment:4 by Christian Boos, 14 years ago

Owner: set to Christian Boos

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christian Boos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Christian Boos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.