Paul, I understand what you say, except the part of compatibility with
Python3.5. Of course such a change is targeting future version more than
the current and previous versions. If we have this syntax for Python3.6,
users of Python3.9 will find many copy-pastable answers written this way,
and other answers will have comments saying "just add this statement to the
beginning of your script".

On Mon, Sep 19, 2016 at 11:24 PM Paul Moore <p.f.mo...@gmail.com> wrote:

> On 19 September 2016 at 19:52, אלעזר <elaz...@gmail.com> wrote:
> > Of course it doesn't  address the issues - for example, running a python
> > script from the file manager will result in a failed execution,
> unexplained.
>
> What you're talking about here is deployment of Python "applications"
> (where in your case, you're focusing on single-file scripts, but the
> problem is broader). Beyond a certain point, as I'm sure you realise,
> you can't solve this issue - someone tries to run a Unix-only script
> on Windows, for example. So really, we're looking at ways of improving
> the current state of affairs. As things stand, deploying "standalone
> applications" in Python is not particularly easy, with dependency
> management being only one of the issues.
>
> Some options for deployment come to mind - I'm sure none of them seem
> quite as easy as "just run this script", but you should remember that
> even "just run this script" doesn't always work as well as you'd like
> - on Unix you need to make the script executable and have a shebang
> line, on Windows the file extension needs to be right and registered.
> Not all users have the right (or sometimes any) Python version on
> their PATH, etc. So even "just run this script" isn't always simple
> even if the script has no dependencies outside the stdlib.
>
> So, some options:
>
> 1. The previously-mentioned rwt makes "just run this script" work as
> you want, as long as you have rwt installed. Conceded, it isn't
> available by default, but it's not hard to install as a one-off task.
> And there's a discussion ongoing about including it with pip as "pip
> run" so "pip run myscript.py" (or "py -m pip run myscript.py" on
> Windows - remember what I said about PATH? ;-)) will run a script with
> its dependencies.
> 2. You can bundle your script with its dependencies using zipapp. On
> Unix, you can even make the resulting file executable, and on Windows,
> the .pyz extension is registered for this.
> 3. Someone could write a tool to scan a script for a
> specially-formatted comment at the top that described its
> dependencies, and installed them. That (in effect) adds an "install"
> step before the script can be run, but lots of utilities have that, so
> it's not completely unheard of. And if it's GUI users you're concerned
> about, you could make that a GUI utility. Drag the script onto it, it
> lists the dependencies and confirms you want them installed, then
> offers to run the script.
> 4. There are existing platform-specific options like py2exe or
> cx_Freeze. Probably a bit heavyweight for a "simple script", though.
>
> Of course, none of these options cover the use case of "I saw this
> nice script on Stack Overflow, so I copied it, and now I want to run
> it on my PC". But honestly, if it has some dependencies, and the
> script author didn't say "you need to install FOO and BAR", or the
> user doesn't know how to install those dependencies, you're probably
> out of luck anyway. Even if the proposed "from __pypi__ import foo"
> syntax existed, I doubt many scripts posted on the web would use it -
> if only because then, Python 3.5 users wouldn't be able to run the
> scripts!
>
> IMO, for command line use, rwt is 99% of the way to what you want. For
> GUI use, there's nothing specific to this problem right now, but
> someone could certainly write something. A syntax change to the
> language would likely be *less* useful, as people would not be able to
> use it unless they were deliberately only targeting Python 3.7 and
> later, which seems optimistic at best...
>
> Paul
>
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to