On 3 August 2017 at 09:52, Thomas Güttler <guettl...@thomas-guettler.de> wrote: > > > Am 02.08.2017 um 18:06 schrieb Wolfgang Maier: >> >> On 08/02/2017 04:57 PM, Steven D'Aprano wrote: >>> >>> On Wed, Aug 02, 2017 at 10:48:39PM +1000, Ben Finney wrote: >>>> >>>> Thomas Güttler <guettl...@thomas-guettler.de> writes: >>>> >>>>> Maybe I am doing something wrong. I was proud because I did use >>>>> “console_scripts” entry points. >>>> >>>> >>>> Did someone lead you to believe it was wrong? Setuptools console_scripts >>>> entry points are a good tool. >>>> >>>> My point was that it is an *advanced* tool, difficult to use and also >>>> difficult to explain because the concepts are advanced. >>> >>> >>> Can you explain the use-case for when somebody might want to use >>> console_scripts entry points? >>> >>> I have a module with a main() function and an "if __name__ == ..." >>> guard. Under what circumstances is that not sufficient, and I would want >>> console_scripts? >>> >> >> If you install things using pip/setuptools and have defined a >> console_scripts entry point for it, then the corresponding wrapper >> script will be installed in whatever is considered the scripts directory >> at install time on that machine. With a bit of luck the entry point will >> thus be executable directly without any end-user intervention (like >> adding folders to $PATH and chmodding files). >> Personally, I always found it straightforward to write the wrapper >> script myself, then define this as a 'scripts' file in the package >> layout of my setup.py, but people's MMV. > > > > I was not aware of "scripts" in setup.py. But I found docs: > > http://python-packaging.readthedocs.io/en/latest/command-line-scripts.html > > Why are there two ways: "script" vs "console_scripts entry-point"?
Simple: `scripts` are legacy. `entry_points` are the new thing. There’s also a third approach: gui_scripts entry_points, which work the same way on Linux/*nix, but on Windows, it means that running your script by opening the created .exe files does not show a console window. Note that stdout/stderr do not work in that mode under Windows, which can lead to spurious application crashes. (GUI-only processes cannot use stdout/stderr because they don’t have a console attached) I’ll take the liberty to link my (better) blog post about this: https://chriswarrick.com/blog/2014/09/15/python-apps-the-right-way-entry_points-and-scripts/ -- Chris Warrick <https://chriswarrick.com/> PGP: 5EAAEA16 _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor