[Distutils] advice re: packaging tasks

Chris Jerdonek chris.jerdonek at gmail.com
Fri Oct 3 17:11:52 CEST 2014


On Fri, Oct 3, 2014 at 7:23 AM, Marius Gedminas <marius at pov.lt> wrote:
> On Thu, Oct 02, 2014 at 09:15:54AM -0700, Chris Jerdonek wrote:
>> On Thu, Oct 2, 2014 at 8:08 AM, Marius Gedminas <marius at pov.lt> wrote:
>> >> Lastly, as these setup-related tasks grow larger and more complicated,
>> >> I found it helped to break them out into a separate setup package that
>> >> sits alongside my project's main package library (and even adding
>> >> tests in some cases).  Is this normal?  Have other people run into
>> >> this?
>> >
>> > I'm not sure what you mean.  Do you have any examples?
>>
>> I mean that if you are working on project MyProject with package
>> myproject inside the repo, you might find yourself adding ad hoc
>> custom code to setup.py.  If this setup.py code starts to grow (a bit
>> like your Makefile may grow), it might make sense to move some of the
>> setup code to a package called something like myproject_setup
>> alongside myproject (which would be used only for setup tasks).  And
>> if this setup code was sufficiently complicated, you might find
>> yourself wanting to add unit tests for some of it, so you might have
>> myproject_setup/tests (and even testing it as part of your automated
>> tests, etc).
>
> Right.  I wanted to see some concrete examples of that code you find
> putting in your setup.py files.
>
> All I've seen before were bits that concatenate README.rst + CHANGES.rst
> into a long_description, or parse the version number from some source
> file in the name of DRY.

In some older projects, I had a fair amount of code that essentially
did what "check-manifest" does (but as part of running sdist).  And
yes, there was also code to do some pre-processing of README.md and to
convert that with other files into a .rst long_description.

In a newer project, I'm starting to add additional code to support
running pandoc, which you can see here, for example:

https://github.com/cjerdonek/open-rcv/blob/master/openrcv_setup/pandoc.py

I use pandoc to convert files like README.md into both rst files for
the long_description, and into HTML for local viewing (a bit similar
to what restview does).  I'm not sure what other tools people use for
this, but I've been happy with pandoc, and it is quite versatile and
powerful.

I can point you to additional specific examples off-list if you want.

--Chris


More information about the Distutils-SIG mailing list