Edgewall Software
Modify

Ticket #7877 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

KeyError: 'tracext/hg/../locale'

Reported by: adoleo@… Owned by: cboos
Priority: high Milestone: not applicable
Component: plugin/mercurial Version: 0.12dev
Severity: major Keywords: mercurial
Cc:
Release Notes:
API Changes:

Description

Good evening! I switched to Mercurial from SVN over the weekend, and tonight I set about the task of updating Trac to support my new multirepo environment. After checking out the latest Trac-multirepo and TracMercurial versions from SVN, installing them, and restarting Apache2, I am greeted by the KeyError? reproduced in the summary line above.

I think the problem is at line 173 of backend.py:

locale_dir = pkg_resources.resource_filename(name, '../locale')

I don't seem to have a tracext/locale directory anywhere. Let me know if I can provide more info.

Trac Version: 0.12multirepos-r7684-py2.5
TracMercurial Version: 0.12.0.6dev_r7745-py2.5

Platform: Ubuntu 8.10-server amd64

Thanks!

Attachments

Change History

comment:1 Changed 3 years ago by cboos

  • Milestone set to not applicable
  • Priority changed from normal to high

Ah yes, forgot to include this in the package_data. In the meantime you can use the plugin in development mode, i.e. from the checkout you do python setup.py develop.

comment:2 Changed 3 years ago by cboos

Here's the modified setup.py file

#!/usr/bin/env python

from setuptools import setup, find_packages

extra = {}

try:
    import babel
    extra['message_extractors'] = {
        'tracext': [
            ('**.py',                'python', None),
        ],
    }
except ImportError:
    pass
    
TracMercurial = 'http://trac.edgewall.org/wiki/TracMercurial'

setup(name='TracMercurial',
      install_requires='Trac >=0.12dev',
      description='Mercurial plugin for Trac 0.12',
      keywords='trac scm plugin mercurial hg',
      version='0.12.0.6',
      url=TracMercurial,
      license='GPL',
      author='Christian Boos',
      author_email='cboos@neuf.fr',
      long_description="""
      This plugin for Trac 0.12 provides support for the Mercurial SCM.

      '''Actually, to take full benefit of this version of the plugin,
      the http://trac.edgewall.org/browser/sandbox/multirepos branch is
      required.'''
      
      See %s for more details.
      """ % TracMercurial,
      namespace_packages=['tracext'],
      packages=['tracext', 'tracext.hg'],
      package_data={
          '': ['COPYING', 'README'],
          'tracext': ['locale/*.*', 'locale/*/LC_MESSAGES/*.*'],
          },
      zip_safe=False,
      entry_points={'trac.plugins': 'hg = tracext.hg.backend'},
      **extra)

This produces an .egg which contains the translation files. When installed as unzipped, it works fine. But when installed as zipped, despite the zip_safe=False, it doesn't get unzipped automatically and therefore one still get the KeyError.

As I'm no setuptools expert, maybe someone could point me to what I missed?
I have other zipped eggs which correctly get unzipped automatically (e.g. the sandbox/spam-filter-captcha one).

comment:3 Changed 3 years ago by adoleo@…

Wow, thanks for the quick response! Installing the plugin in development mode did the trick for now - thanks for the tip! I'm not very experienced in setuptools, so I'm not sure why it isn't unzipping, either. I'll play around with it tomorrow night, and if I figure out anything I'll let you know. Thanks again!

comment:4 Changed 3 years ago by adoleo@…

Now that I'm able to use it, I wanted to let you know that the multirepo feature is FANTASTIC! Great work!

comment:5 follow-up: Changed 3 years ago by cboos

  • Status changed from new to assigned

zip_safe issue understood: the .egg file only gets unzipped when a file needed to be accessed. The problem here was that when using the following resource access:

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

the file was not found, as explained by Jorge Vargas in googlegroups:Trac-dev:830e3ccd1f371ae6.

When changing that to 'tracext', 'locale', it worked.
Now I should probably move locale below tracext/hg.

The actual setting of the zip_safe flag doesn't seem to matter (first, it's autodetected, second, even if set to True and the egg contains EGG-INGO/zip-safe flag, the locale files get extracted in a tracmercurial...egg-tmp/locale folder in the PYTHON_EGG_CACHE).

What should also be checked is whether the similar call to resource_filename(__name__, '../locale') in trac/util/translation.py will actually work when Trac is installed as an .egg or not.

comment:6 Changed 3 years ago by cboos

  • Resolution set to fixed
  • Status changed from assigned to closed

Fixed in r7901 and r7902.

Actually __name__ seems to work in pkg_resources.resource_filename, it's just the relative "../locale" part which didn't.

comment:7 in reply to: ↑ 5 Changed 3 years ago by cboos

What should also be checked is whether the similar call to resource_filename(__name__, '../locale') in trac/util/translation.py will actually work when Trac is installed as an .egg or not.

Same problem for Trac itself, see #8062.

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
to The owner will be changed from cboos. Next status will be 'closed'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.