Using a ChangeLog as a canonical source of package metadata

Ben Finney ben+python at benfinney.id.au
Wed Jan 14 11:59:45 CET 2015


Ben Finney <ben+python at benfinney.id.au> writes:

> The idea is to parse from the Changelog the version metadata, and
> record it in Setuptools metadata. Then the ‘pkg_resources’ module of
> Setuptools allows programmatic access to that metadata.

One tricky aspect is: at what specific point should the Changelog be
parsed and the version metadata recorded in Setuptools package metadata?

At first I thought it should be done immediately on starting ‘setup.py’,
in order to have values to supply to the ‘setup()’ call. So I imported
the ‘version’ module which itself imports ‘docutils’ to have the reST
parsing available; then ‘setup.py’ continues by feeding the Changelog to
a function which parses it and emits values which are used to supply
parameters to ‘setup()’.

As was revealed in a recent version of the code base, though, this
causes a circular dependency. Docutils is a third-party library, which
needs to be declared as a dependency and satsified before it can be
imported. But that dependency can't be declared until ‘setup()’ has run
to specify what the dependencies are!

So in a later release I've had to break that circle by introducing an
initial “unknown” state for the version information, in order to allow
‘setup()’ to run and get the dependencies installed. Then when the
‘setup.py egg_info’ command is run, the Changelog is parsed and the
version info metadata file is injected into the Setuptools metadata for
the distribution.

Rather more complicated than I would like, because of the need to have
‘setup()’ as a top-level call in ‘setup.py’. This would be more
straightforward if we could assume the commonly-deployed existence of a
*declarative* build system (such as Make); but in Python we're stuck
with ‘setup.py’ and its limitations for now. Fortunately, the hard work
of many people have made those much better in recent years.


I'm interested to know what people writing Python distributions think of
this approach. Again, the example I'm discussing is in ‘python-daemon’'s
code base, at <URL:https://alioth.debian.org/projects/python-daemon/>.

Eventually I might propose this to the Distutils folks as a possible
improvement, but I'd like to refine it more in the face of actual usage.

-- 
 \          “… a Microsoft Certified System Engineer is to information |
  `\     technology as a McDonalds Certified Food Specialist is to the |
_o__)                               culinary arts.” —Michael Bacarella |
Ben Finney




More information about the Python-list mailing list