Edgewall Software
Modify

Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#9961 closed defect (fixed)

first time easy_install won't compile the catalogs

Reported by: Christian Boos Owned by: Jun Omae
Priority: normal Milestone: 0.12.2
Component: i18n Version: 0.12
Severity: normal Keywords: setuptools
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

By doing a few test installations, I noticed a strange effect: for a new Python installation or for a new virtualenv having just setuptools and Babel, easy_install Trac calls the appropriate install_lib step but this fails to trigger a compile_catalog step (r9638 and r9763).

This can be easily reproduced, in a fresh Python environment having only setuptools and Babel installed so far:

$ tar xvfz Trac-0.12.1.tar.gz
$ cd Trac-0.12.1
$ python setup.py -v bdist_egg 
...
running bdist_egg
running egg_info
writing requirements to Trac.egg-info/requires.txt
writing Trac.egg-info/PKG-INFO
writing top-level names to Trac.egg-info/top_level.txt
writing dependency_links to Trac.egg-info/dependency_links.txt
writing entry points to Trac.egg-info/entry_points.txt
reading manifest file 'Trac.egg-info/SOURCES.txt'
writing manifest file 'Trac.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
creating build
...

Whereas if the install is actually an upgrade, then it works as expected (e.g. easy_install Trac==0.12; easy_install -U Trac==0.12.1):

...
running install_lib
running compile_catalog_js
compiling catalog 'trac/locale/sl/LC_MESSAGES/messages-js.po' to 'trac/locale/sl/LC_MESSAGES/messages-js.mo'
...

I suspect the from trac.util.dist import get_l10n_js_cmdclass line to fail in the first situation. Debugging this shows the following error: No module named genshi.builder… The compile_catalog_js step indeed requires Genshi so this is not a side effect error we could try to ignore. With setuptools, the bdist_egg step is executed before the Genshi package gets installed. That actually happens at the very end of easy_install Trac:

Installed .../lib/python2.5/site-packages/Trac-0.12.1-py2.5.egg
Processing dependencies for Trac
Searching for Genshi>=0.6
...

So to solve this, we'd need to be able to trigger an install of Genshi at a very early stage.

In the meantime, we can advise to do an explicit:

easy_install Babel Genshi
easy_install Trac

for first time installations (easy_install Babel Genshi Trac won't work either).

Attachments (1)

t9961-dist.diff (18.5 KB ) - added by Jun Omae 13 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 by Christian Boos, 13 years ago

Summary: first time easy_install don't compile the catalogsfirst time easy_install won't compile the catalogs

typo

comment:2 by Jun Omae, 13 years ago

Ad hoc solution, it triggers to install genshi before the build stage.

Index: setup.py
===================================================================
--- setup.py    (revision 10435)
+++ setup.py    (working copy)
@@ -85,6 +85,9 @@
     test_suite = 'trac.test.suite',
     zip_safe = True,

+    setup_requires = [
+        'Genshi>=0.6',
+    ],
     install_requires = [
         'setuptools>=0.6b1',
         'Genshi>=0.6',

comment:3 by Christian Boos, 13 years ago

The problem is that we require Genshi through the early import trac.utils.dist, in order to provide the generate_messages_js Command. So we should also delay importing the genshi dependencies, like:

  • dist.py

     
    2929
    3030from distutils.errors import DistutilsOptionError
    3131from setuptools.command.install_lib import install_lib as _install_lib
    3232
    33 from genshi.core import Stream
    34 from genshi.input import XMLParser
    35 
    3633from trac.util.presentation import to_json
    3734

But I'm not sure that's enough, there are indirect dependencies IIRC.

Anyway, thanks for the tip about setup_requires!

Version 0, edited 13 years ago by Christian Boos (next)

comment:4 by Jun Omae, 13 years ago

I just understand the problem now. Thanks for the more detailed explanation. We need to be able to import get_l10n*cmdclass without Genshi in setup.py.

Then, I think that the cmdclasses should be moved to trac.dist from trac.util.dist.

trac.util.dist depends on trac.util and trac.util.html. trac.util.html directly depends on Genshi. trac.dist can minimize the dependencies with the delay importing.

I create a experimental patch t9961-dist.diff.

by Jun Omae, 13 years ago

Attachment: t9961-dist.diff added

comment:5 by Christian Boos, 13 years ago

Milestone: next-major-0.1X0.12.2
Owner: changed from Christian Boos to Jun Omae

Looks pretty good! I'll test this evening.

in reply to:  4 comment:6 by Remy Blank, 13 years ago

Replying to jomae:

Then, I think that the cmdclasses should be moved to trac.dist from trac.util.dist.

Minimizing (or even eliminating all) Trac dependencies in the dist module sounds like an excellent idea.

The fact that trac.util imports all sorts of stuff is a dependency nightmare (I understand we do it for backward compatibility), ideally it should be empty and all functionality should be in trac.util.* sub-modules. Maybe we should do some clean-up at some point.

comment:7 by Christian Boos, 13 years ago

The patch seems to work great!

(babel-only)cboos@lynx:~/tests/0.12-stable$ python setup.py bdist_egg
warning: no previously-included files found matching 'doc/2000ft.graffle'
warning: no previously-included files matching '*' found under directory 'doc/logo.lineform'
zip_safe flag not set; analyzing archive contents...

Installed /home/cboos/tests/0.12-stable/Genshi-0.6-py2.7.egg
running bdist_egg
running egg_info
creating Trac.egg-info
...
running install_lib
running compile_catalog_js
compiling catalog 'trac/locale/sl/LC_MESSAGES/messages-js.po' to ...

However as you can see above, the first thing we get are the warnings emitted by Genshi's install. This is not so nice, maybe we can do:

  • setup.py

    diff --git a/setup.py b/setup.py
    a b  
    4343    from trac.dist import get_l10n_js_cmdclass
    4444    extra['cmdclass'] = get_l10n_js_cmdclass()
    4545
    46 except ImportError, e:
     46except ImportError:
    4747    pass
    4848
     49try:
     50    import genshi
     51except ImportError:
     52    print "Genshi is needed by Trac setup, pre-installing"
     53    # give some context to the warnings we might get when installing Genshi
     54
     55
    4956setup(
    5057    name = 'Trac',
    5158    version = '0.12.2',

Then we get:

(babel-only)cboos@lynx:~/tests/0.12-stable$ python setup.py bdist_egg
Genshi is needed by Trac setup, pre-installing
warning: no previously-included files found matching 'doc/2000ft.graffle'
warning: no previously-included files matching '*' found under directory 'doc/logo.lineform'
zip_safe flag not set; analyzing archive contents...

Installed /home/cboos/tests/0.12-stable/Genshi-0.6-py2.7.egg
running bdist_egg
...

only if Genshi was actually missing.

comment:8 by Jun Omae, 13 years ago

Resolution: fixed
Status: newclosed

Thanks for your testing and reviews! Committed in [10444].

comment:9 by Christian Boos, 13 years ago

Good! I'll take care of merging, as I'm currently merging 0.12-stable. On trunk I will redo the trac/util/dist.py → trac/dist.py as a copy ;-)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jun Omae.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Jun Omae 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.