Issue #3 new

executables without .py extension ?

Stefano Costa
created an issue

example.txt says:

{{{

!rest

create a directory Twisted/bin and put your executables there, if you have any. Don't give them a .py extension, even if they are Python source files. Don't put any code in them except an import of and call to a main function defined somewhere else in your projects.

}}}

Is this really good practice, particularly wrt not having a .py extension?

Comments (4)

  1. Tarek Ziadé repo owner

    From Distutils/Linux point of view, it's a good practice as long as you add this header:

    If the script is added in the scripts section in setup.py, this line will be automatically adapted to the right interpreter at installation time.

    Now I agree this is not clear in this paragrah, we will add more details. Thanks

  2. Stefano Costa reporter

    I usually put

    #! /usr/bin/env python
    

    (I can't remember where I read quite some time ago it was better). Thanks for taking the time to add more details about this in the Guide.

  3. wierob

    But without the extension the file is not executable on Windows!

    However, since the first line is adjusted to the current interpreter by default (when using distutils), the following should suffice

    
    #!python
    
    

    [1] http://docs.python.org/distutils/setupscript.html#installing-scripts

    Additionally: "Don't put any code in them except an import of and call to a main function defined somewhere else ..."

    This seems to be unnecessary when using setuptools' entry_points mechanism.

  4. Stefano Costa reporter

    There's IMO a conflict between the basic example in basics_creating_distributing_dists and the “DO's” section of example.

    I guess a big red button “DON'T PANIC: this guide is a work in progress” would be good to have on the home page.

  5. Log in to comment