This is: "script_name = project.main:do_stuff with setuptools
Setuptools creates scripts called script_name , which imports and runs the project.main:do_stuff , rather than running the script directly. You should re-read this part ( alternative link if you are using Distribute) of the setuptools documents again to understand why. The generated script contains if __name__ == "__main__" . So yes, this is still a de facto way to make it execute.
This is a copy of easy_install installed with setuptools
#!/usr/bin/python # EASY-INSTALL-ENTRY-SCRIPT: 'distribute==0.6.14','console_scripts','easy_install' __requires__ = 'distribute==0.6.14' import sys from pkg_resources import load_entry_point if __name__ == '__main__': sys.exit( load_entry_point('distribute==0.6.14', 'console_scripts', 'easy_install')() )
I think it is best to define an entry point and a script similar to easy_install. This imports and uses the entry point, as shown in the example if __name__ == "__main__": do_stuff() . This is great for debugging and early testing, also if you use distutils , there is no need to add / change anything. You may also have another application to call do_stuff () to access your application with the costs of running it in the shell, which is what setuptools works, distutils copies the script.
Mike ramirez
source share