[Distutils] How to customize egg_info behavior

Jason R. Coombs jaraco at jaraco.com
Wed Aug 4 06:51:53 CEST 2010

> -----Original Message-----
> From: P.J. Eby [mailto:pje at telecommunity.com]
> There isn't any easy way to work around this at the moment (although I
> implement a formal fix  in later releases of setuptools).  In the
> you can monkeypatch thus, in the same plugin where you implement the
> above function:
>      from setuptools.command.egg_info import egg_info
>      old_tagged_version = egg_info.tagged_version
>      def tagged_version(self):
>          if self.distribution.use_hg_version:
>              return safe_version(self.distribution.get_version())
>          else:
>              return old_tagged_version(self)
>      egg_info.tagged_version = tagged_version
> Whew.  This was a tough one to figure out, and it's a little hacky.
Probably in
> 0.7 I'll just factor this into a separate entry point group for version
> calculations, so that it's not as much trouble to do something like this.

PJE: Thanks again. That's a huge help. I don't think I would have ever
figured out all of those hooks by myself.

One problem I found was that even with that code, the tag_build wasn't
getting set in setup.cfg, so I added another line to set the
egg_info.tag_build in the monkey-patched egg_info.tagged_version. After
that, it seems to work exactly as prescribed.

It's in hgtools 0.4, so feel free to give it a go. As you prescribed, set
use_hg_version=True and setup_requires hgtools>=0.4 and you'll get versions
automatically calculated based on your tags.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 6448 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/distutils-sig/attachments/20100803/3c872514/attachment.bin>

More information about the Distutils-SIG mailing list