[Distutils] Python module for use in ‘setup.py’ but not to install

Nick Coghlan ncoghlan at gmail.com
Mon Jan 19 02:01:17 CET 2015

On 19 January 2015 at 06:35, Ben Finney <ben+python at benfinney.id.au> wrote:
> Donald Stufft <donald at stufft.io> writes:
>> > On Jan 17, 2015, at 7:47 PM, Ben Finney <ben+python at benfinney.id.au> wrote:
>> > As it stands (‘python-daemon’ [0] version 2.0.3), the ‘version.py’ file
>> > is correctly included in the source distribution, correctly used by the
>> > ‘egg_info.writers’ entry point; but then ends up incorrectly installed
>> > to the run-time packages library. This causes problems for subsequent
>> > import of unrelated modules that happen to share the same name.
>> >
>> > How can I specify to Setuptools that the file is needed in the source
>> > distribution, is needed by the entry points for Setuptools, but should
>> > not be installed along with the binary distribution?
>> setup_requires?
> Did you want to say anything else about that, for instance, how it
> applies to the question or what specifically you suggest I do?
> As it stands, I can only quote the documentation:
>     setup_requires
>     A string or list of strings specifying what other distributions need
>     to be present in order for the setup script to run. […]
>     <URL:https://setuptools.pypa.io/en/latest/setuptools.html>
> The module in question is part of the same code base, and is not an
> “other distribution”. So I don't know why you suggest this option.

If you have a build/install time only dependency that you want to
distribute, you *have* to separate it out into a separate component if
you don't want it to also be present at runtime. We do not, and will
not, support selective installation of subcomponents, as it's too hard
to audit later. Instead, such components need to be separated out into
distinct packages so that the segmentation of functionality and
availability is clear to both the automated tools and to other humans.

"Extras" work the same way - they select whether or not to install
optional *dependencies*, but deliberately can't be used to selectively
install pieces of the package itself (the affected subcomponents are
instead expected to do runtime checks to see if the optional
dependencies are present and provide a useful error message if they're


Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Distutils-SIG mailing list