[Distutils] How to implement ‘setup.py’ functionality that itself needs third-party distributions
Ben Finney
ben+python at benfinney.id.au
Fri Jan 23 03:15:51 CET 2015
Ben Finney <ben+python at benfinney.id.au> writes:
> Marius Gedminas <marius at gedmin.as> writes:
>
> > 2. Implement metadata extraction using custom command classes[*] and
> > setup_requires.
>
> This seems to be the only one which might be feasible (and without
> needless duplication of information, which is part of the whole point of
> this exercise). I will learn more and try it.
Okay, the Setuptools ‘egg_info’ command is rather hostile to extension,
but less hostile than Setuptools entry points. I have cobbled together a
solution.
The packaging code for version 2.0.4 of ‘python-daemon’:
* Has no Setuptools entry points. These are not the right tool for the
job, it seems.
* Adds a custom Setuptools command ‘write_version_info’ to parse the
Changelog and write the version info metadata file.
* Minor hack: Uses a custom ‘egg_info’ command that will recognise and
run sub-commands. (Why doesn't every top-level command do this without
needing to be taught?)
* Major hack: Re-binds class names in order to update their base class,
after dynamically importing ‘docutils’. (If there was a way to ensure
Docutils was installed before running any of the commands, this would
not be needed.)
Thanks for all the assistance understanding the limitations and quirks
of Distutils and Setuptools. I'm not very happy with this solution, but
hopefully it is modular enough that it can be changed, in some happy
future when Python's packaging features are more tractable.
--
\ “Programs must be written for people to read, and only |
`\ incidentally for machines to execute.” —Abelson & Sussman, |
_o__) _Structure and Interpretation of Computer Programs_ |
Ben Finney
More information about the Distutils-SIG
mailing list