[Distutils] setup.py should use if __name__ == '__main__', right?

Noah Kantrowitz noah at coderanger.net
Mon Apr 7 05:06:20 CEST 2014


setup.py is not intended to be importable, so it has no "import time". Pretty sure I've never seen this patten used in a setup.py, nor would I think it has much semantic utility.

--Noah

On Apr 6, 2014, at 8:04 PM, Asheesh Laroia <lists at asheesh.org> wrote:

> Hi nice distutils/PyPA people,
> 
> I had a question that probably is worth showing up in the archives. Namely:
> 
> It seems to me like bizarre bad form for the setup.py file to execute what amounts to a main() function at import time.
> 
> I presume this is just some kind of historical accident, and if the early authors of the distutils docs were careful, they'd have recommended:
> 
> from distutils.core import setup
> 
> if __name__ == '__main__':
>     setup()  # FIXME args
> 
> 
> rather than just:
> 
> from distutils.core import setup
> 
> setup()  # FIXME args
> 
> 
> 
> Is that an accurate assessment? If so, that's great, because I plan to remark on this bemusedly in my talk. If there is a reason it is the way it is, however, then I will avoid making a joke that is wrong in an important way.
> 
> -- Asheesh.
> _______________________________________________
> Distutils-SIG maillist  -  Distutils-SIG at python.org
> https://mail.python.org/mailman/listinfo/distutils-sig

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 163 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://mail.python.org/pipermail/distutils-sig/attachments/20140406/44e53677/attachment.sig>


More information about the Distutils-SIG mailing list