[Python-ideas] Re: Idea/PEP draft: Add support of __main__.py to argparse.ArgumentParser.prog

2019-08-24 Thread Richard Musil
On Sat, Aug 24, 2019 at 9:25 AM Michael Hooreman wrote: > Running __main.py__ as a script works *only* if we use absolute imports. > And I consider that using absolute imports in a package to itself is a very > bad practice. So, __main.py__ is not an executable. > I probably should clarify my or

[Python-ideas] Re: Idea/PEP draft: Add support of __main__.py to argparse.ArgumentParser.prog

2019-08-24 Thread Michael Hooreman
Thanks Richard, You are right. So, my doubt about the fact that it must be changed or not is meaningful, and argparse should not be changed. I'll keep using the « overriding » class, and plane to make a pip package for that. Thanks to everybody for those discussions. Le sam. 24 août 2019 09:5

[Python-ideas] Re: Idea/PEP draft: Add support of __main__.py to argparse.ArgumentParser.prog

2019-08-24 Thread Michael Hooreman
Thanks Richard, In fact, I should add more than the python executable in prog: it must contain -m and the package « classpath », but I can try arpund this. I'll come back with the results asap. Running __main.py__ as a script works *only* if we use absolute imports. And I consider that using abso

[Python-ideas] Re: Idea/PEP draft: Add support of __main__.py to argparse.ArgumentParser.prog

2019-08-24 Thread Andrew Barnert via Python-ideas
On Aug 24, 2019, at 00:25, Michael Hooreman wrote: > > In fact, I should add more than the python executable in prog: it must > contain -m and the package « classpath » But that’s not a valid prog. If you try to execute the program “python -m spam” with arguments “eggs” and “cheese” (whether w

[Python-ideas] Re: Idea/PEP draft: Add support of __main__.py to argparse.ArgumentParser.prog

2019-08-24 Thread Michael Hooreman
What being part of the program and what are arguments is not meaningful at this point: I only want an accurate usage string. I don't make a setuptools entry point here for the good reason that this is used as part of a system, which is not using standard deliverables. You have to consider that the

[Python-ideas] Re: Idea/PEP draft: Add support of __main__.py to argparse.ArgumentParser.prog

2019-08-24 Thread Michael Hooreman
Let me clarify a bit. Setuptools and standalone scripts is indeed the best classical approach, but that does not adapts to my use case. I'm working with a contunuously, fast evolving system, and there is no "identified release" (continuous delivery). I'm under the impression that you tell me that

[Python-ideas] Re: Idea/PEP draft: Add support of __main__.py to argparse.ArgumentParser.prog

2019-08-24 Thread Andrew Barnert via Python-ideas
On Aug 24, 2019, at 08:48, Michael Hooreman wrote: > > Let me clarify a bit. Setuptools and standalone scripts is indeed the > best classical approach, but that does not adapts to my use case. I'm > working with a contunuously, fast evolving system, and there is no > "identified release" (continu

[Python-ideas] Re: Idea/PEP draft: Add support of __main__.py to argparse.ArgumentParser.prog

2019-08-24 Thread Michael Hooreman
Thanks for those advises, Andrew To tell you a bit more about my context, I'm working on an end-to-end data science projets, which is: - using 90% of python, but also different things - those thing are sometimes impacting system configuration - there's a development accounts, I'm working there wit

[Python-ideas] Re: Idea/PEP draft: Add support of __main__.py to argparse.ArgumentParser.prog

2019-08-24 Thread Wes Turner
# Python packaging, setup.py, console_scripts entrypoints, and __main__.py ```python !ls ** ``` examplenb.ipynb requirements.txt setup.py example: __init__.py __main__.py thecode.py ```python !cat setup.py ``` from setuptools import setup setup(name='example',

[Python-ideas] Re: Idea/PEP draft: Add support of __main__.py to argparse.ArgumentParser.prog

2019-08-24 Thread Wes Turner
https://python-packaging.readthedocs.io/en/latest/command-line-scripts.html#the-console-scripts-entry-point On Sat, Aug 24, 2019 at 5:11 PM Wes Turner wrote: > > # Python packaging, setup.py, console_scripts entrypoints, and __main__.py > > > ```python > !ls ** > ``` > > examplenb.ipynb requ

[Python-ideas] Re: Idea/PEP draft: Add support of __main__.py to argparse.ArgumentParser.prog

2019-08-24 Thread Andrew Barnert via Python-ideas
On Aug 24, 2019, at 13:16, Michael Hooreman wrote: > > I'll consider what you say, and try to understand what entrypoint is. I have > understood entrypoint as a wording for an entry point (main) script. Sorry. Well, it _is_ that, but the point is that setuptools can auto-generate those main sc

[Python-ideas] Re: Idea/PEP draft: Add support of __main__.py to argparse.ArgumentParser.prog

2019-08-24 Thread Wes Turner
```python !cat ../../bin/example ``` #!/home/user/-wrk/-ve37/s_example/bin/python3 # EASY-INSTALL-ENTRY-SCRIPT: 'example','console_scripts','example' __requires__ = 'example' import re import sys from pkg_resources import load_entry_point if __name__ == '__main__':

[Python-ideas] Re: Idea/PEP draft: Add support of __main__.py to argparse.ArgumentParser.prog

2019-08-24 Thread Michael Hooreman
Tanks a lot Wes, I know what I will do on Monday :-) Le sam. 24 août 2019 23:22, Wes Turner a écrit : > ```python > !cat ../../bin/example > ``` > > #!/home/user/-wrk/-ve37/s_example/bin/python3 > # EASY-INSTALL-ENTRY-SCRIPT: 'example','console_scripts','example' > __requires__ = 'e

[Python-ideas] Re: Idea/PEP draft: Add support of __main__.py to argparse.ArgumentParser.prog

2019-08-24 Thread Wes Turner
NP! Sometimes it's just easier to explain with code On Sat, Aug 24, 2019 at 5:30 PM Michael Hooreman wrote: > > Tanks a lot Wes, > > I know what I will do on Monday :-) > > Le sam. 24 août 2019 23:22, Wes Turner a écrit : >> >> ```python >> !cat ../../bin/example >> ``` >> >> #!/home/user/-w

[Python-ideas] Re: Idea/PEP draft: Add support of __main__.py to argparse.ArgumentParser.prog

2019-08-24 Thread Wes Turner
Source: https://github.com/westurner/setuptoolsexample Read-only GitHub notebook view: https://github.com/westurner/setuptoolsexample/blob/master/examplenb.ipynb Read/Write mybinder.org (BinderHub (repo2docker)) notebook: https://mybinder.org/v2/gh/westurner/setuptoolsexample/master?filepath=exam

[Python-ideas] Re: Idea/PEP draft: Add support of __main__.py to argparse.ArgumentParser.prog

2019-08-24 Thread Michael Hooreman
Indeed. I usually do a workflow which makes my needs compatible with the standards, but I've started this when I was a python beginner. I'm aware since months that I should use setuptools, but it was not on my priority, because that bad decision had no impact. Now, time to change had come... May

[Python-ideas] Re: Idea/PEP draft: Add support of __main__.py to argparse.ArgumentParser.prog

2019-08-24 Thread Wes Turner
So, to rephrase your request, you want argparse.ArgumentParser.prog to contain "{sys.executable} -m {modulename}" so that the help text correctly indicates that it was invoked that way? PEP notes: - POSIX only is maybe not a good strategy - Can cmdline contain other unescaped \0's? - This would b