Edgewall Software
Modify

Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#9374 closed defect (fixed)

init/update catalog now need an installed trac

Reported by: nzoltan Owned by: Christian Boos
Priority: normal Milestone: 0.12
Component: i18n Version: 0.12dev
Severity: normal Keywords: setuptools
Cc: felix.schwarz@… Branch:
Release Notes:
API Changes:
Internal Changes:

Description

Trac is not installed on my build environment. r9786 is not built anymore.

[build]$ python setup.py update_catalog -l hu

Traceback (most recent call last):
  File "setup.py", line 33, in ?
    from trac.util.dist import get_l10n_js_cmdclass
  File "/home/dev/project/trac/trunk/src/trac/__init__.py", line 14, in ?
    __version__ = __import__('pkg_resources').get_distribution('Trac').version
  File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 229, in get_distribution
    if isinstance(dist,Requirement): dist = get_provider(dist)
  File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 115, in get_provider
    return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
  File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 585, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 483, in resolve
    raise DistributionNotFound(req)  # XXX put more info here
pkg_resources.DistributionNotFound: Trac

Is it a bug or feature?

Attachments (0)

Change History (13)

comment:1 by Christian Boos, 14 years ago

A bug …

Try replacing with:

try:
    __version__ = __import__('pkg_resources').get_distribution('Trac').version
except pkg_resources.DistributionNotFound:
    __version__ = '0.12dev'

comment:2 by Christian Boos, 14 years ago

Ah wait, I suppose all you need to do is to issue a python setup.py egg_info command before init/update.

Last edited 14 years ago by Christian Boos (previous) (diff)

in reply to:  2 comment:3 by nzoltan, 14 years ago

Replying to cboos:

Ah wait, I suppose all you need to do is to issue a python setup.py egg_info command before init/update.

[build]$ python setup.py egg_info

Traceback (most recent call last):
  File "setup.py", line 33, in ?
    from trac.util.dist import get_l10n_js_cmdclass
  File "/home/dev/project/trac/trunk/src/trac/__init__.py", line 14, in ?
    __version__ = __import__('pkg_resources').get_distribution('Trac').version
  File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 229, in get_distribution
    if isinstance(dist,Requirement): dist = get_provider(dist)
  File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 115, in get_provider
    return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
  File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 585, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 483, in resolve
    raise DistributionNotFound(req)  # XXX put more info here
pkg_resources.DistributionNotFound: Trac

comment:4 by Christian Boos, 14 years ago

Ah yes, chicken … egg_info problem ;-)

So comment:1 seems the way to go.

in reply to:  4 comment:5 by nzoltan, 14 years ago

Replying to cboos:

Ah yes, chicken … egg_info problem ;-)

So comment:1 seems the way to go.

Still no luck. :(

[build]$ python setup.py update_catalog -l hu

Traceback (most recent call last):
  File "setup.py", line 37, in ?
    except pkg_resources.DistributionNotFound:
NameError: name 'pkg_resources' is not defined

comment:6 by Christian Boos, 14 years ago

Ok, no idea why there was a __import__('pkg_resources') - maybe there was a good reason…

If not, the following should do:

from pkg_resources import DistributionNotFound, get_distribution

try:
    __version__ = get_distribution('Trac').version
except DistributionNotFound:
    __version__ = '0.12dev'

comment:7 by nzoltan, 14 years ago

My setup.py patch is:

@@ -13,6 +13,7 @@
 # history and logs, available at http://trac.edgewall.org/log/.
 
 from setuptools import setup, find_packages
+from pkg_resources import DistributionNotFound, get_distribution
 
 extra = {}
 
@@ -30,8 +31,12 @@
         'tracopt': extractors,
     }
 
-    from trac.util.dist import get_l10n_js_cmdclass
-    extra['cmdclass'] = get_l10n_js_cmdclass()
+    try:
+       from trac.util.dist import get_l10n_js_cmdclass
+       extra['cmdclass'] = get_l10n_js_cmdclass()
+       __version__ = __import__('pkg_resources').get_distribution('Trac').version
+    except DistributionNotFound:
+        __version__ = '0.12dev'
 
 except ImportError, e:
     pass

The "python setup.py update_catalog -l hu" is now works fine, but:

[build]$ python setup.py init_catalog_js -l hu

usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: setup.py --help [cmd1 cmd2 ...]
   or: setup.py --help-commands
   or: setup.py cmd --help

error: invalid command 'init_catalog_js'

and the "update_catalog_js" result is same. How can I create the messages-js.po file?

comment:8 by Christian Boos, 14 years ago

Sorry, my instructions were not clear, comment:6 was a patch for source:/trunk/trac/__init__.py, I'll write a real patch later today.

in reply to:  8 comment:9 by nzoltan, 14 years ago

Replying to cboos:

Sorry, my instructions were not clear, comment:6 was a patch for source:/trunk/trac/__init__.py, I'll write a real patch later today.

No, it's my fault, the traceback root is the __init__.py, I was careless, sorry. :) Now everything works fine with the modified __init__.py.

comment:10 by Felix Schwarz, 14 years ago

Cc: felix.schwarz@… added

comment:11 by Christian Boos, 14 years ago

Keywords: setuptools added
Resolution: fixed
Status: newclosed

Fix applied in [9806].

I suppose the __import__('pkg_resources') was preferred to import pkg_resources in order to keep the trac namespace clean, so we could add a del get_distribution, DistributionNotFound to reach the same effect, though I don't think it's worth the trouble.

comment:12 by Remy Blank, 14 years ago

Owner: set to Christian Boos

comment:13 by anonymous, 14 years ago

I have the same problem with 0.12 AND 0.13

invalid command 'update_catalog'

python setup.py update_catalog -l hu update_catalog_js -l hu usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] …]

or: setup.py —help [cmd1 cmd2 …] or: setup.py —help-commands or: setup.py cmd —help

error: invalid command 'update_catalog' make: * [update-hu] Error 1

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.