The difference is __import__ doesn't add "pkg_resources" to the module namespace so it is a bit cleaner. If that code doesn't work, it is pretty clearly a bug in hg and should be treated as such.
--Noah > -----Original Message----- > From: [email protected] [mailto:[email protected]] On > Behalf Of Stephen > Sent: Thursday, March 18, 2010 11:51 AM > To: Trac Development > Subject: [Trac-dev] importing version > > hey guys, I'm writing a hook for mercurial to auto comment on Trac > issues mentioned in the commit message. The problem I'm running into > is that mercurial has some importing module that manages imports from > among other places custom hooks. Its blowing up when it gets to the > trac/__init__.py: > __version__ = > __import__('pkg_resources').get_distribution('Trac').version > > From what I've gleaned from the mercurial code, its assuming there > wouldn't be "__import__" statements, only "from" and "import" > statements. What do you think about changing the __init__.py to: > import pkg_resources > __version__ = pkg_resources.get_distribution('Trac').version > > I realize I'm asking you to change your code because of integration > with a different project but I wanted to ask nonetheless :) > > I'm really enjoying using Trac at work, great job on this project > guys. > > Stephen > > -- > You received this message because you are subscribed to the Google > Groups "Trac Development" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to trac- > [email protected]. > For more options, visit this group at > http://groups.google.com/group/trac-dev?hl=en. -- You received this message because you are subscribed to the Google Groups "Trac Development" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/trac-dev?hl=en.
