Re: [Python-ideas] from __pip__ import

2016-09-21 Thread Chris Barker
On Mon, Sep 19, 2016 at 9:25 AM, אלעזר wrote: > Many proposals to add something to stdlib are rejected here with the > suggestion to add such library to pypi first. As noted by someone, pypi is > not as reachable as stdlib, and one should install that package first, > which many people don't know

Re: [Python-ideas] from __pip__ import

2016-09-21 Thread Nick Coghlan
On 21 September 2016 at 06:59, Chris Angelico wrote: > On Wed, Sep 21, 2016 at 4:58 AM, אלעזר wrote: >> I think that combining user convenience and security considerations, there >> should be some way to invoke a GUI version of pip with flashing screen >> asking for permissions to install the lib

Re: [Python-ideas] from __pip__ import

2016-09-20 Thread Chris Angelico
On Wed, Sep 21, 2016 at 4:58 AM, אלעזר wrote: > I think that combining user convenience and security considerations, there > should be some way to invoke a GUI version of pip with flashing screen > asking for permissions to install the library. In situations where > interaction with the user is no

Re: [Python-ideas] from __pip__ import

2016-09-20 Thread אלעזר
On Tue, Sep 20, 2016 at 9:48 PM Stephen J. Turnbull < turnbull.stephen...@u.tsukuba.ac.jp> wrote: > Paul Moore writes: > > > I'm just saying that I don't want core Python to implicitly install > > packages for me. > > +1 > > > But that's simply a personal opinion. > > +0.5 > > It's not *purely*

Re: [Python-ideas] from __pip__ import

2016-09-20 Thread Stephen J. Turnbull
Paul Moore writes: > I'm just saying that I don't want core Python to implicitly install > packages for me. +1 > But that's simply a personal opinion. +0.5 It's not *purely* a personal opinion, though. The original proposal is to include the facility and allow *script authors*, rather than

Re: [Python-ideas] from __pip__ import

2016-09-20 Thread Paul Moore
On 20 September 2016 at 13:58, Random832 wrote: > On Tue, Sep 20, 2016, at 07:12, אלעזר wrote: >> Moreover, being able to do it programmatically is a security risk, >> since it requires elevated privileges that I don't know how to drop, >> and most people will not think about doing, but a library

Re: [Python-ideas] from __pip__ import

2016-09-20 Thread Random832
On Tue, Sep 20, 2016, at 07:12, אלעזר wrote: > Moreover, being able to do it programmatically is a security risk, > since it requires elevated privileges that I don't know how to drop, > and most people will not think about doing, but a library > implementation will. Maybe we should be thinking ab

Re: [Python-ideas] from __pip__ import

2016-09-20 Thread Paul Moore
On 20 September 2016 at 12:12, אלעזר wrote: > Moreover, being able to do it programmatically is a security risk, since it > requires elevated privileges that I don't know how to drop, and most people > will not think about doing, but a library implementation will. > > So if someone uses subprocess

Re: [Python-ideas] from __pip__ import

2016-09-20 Thread Xavier Combelle
Le 20/09/2016 à 12:35, Paul Moore a écrit : > > While on the whole subject of this, I should also point out that there > are a lot of potential issues with installing new packages while a > Python program is running. They are all low-probability, and easy to > avoid if you're not doing weird thin

Re: [Python-ideas] from __pip__ import

2016-09-20 Thread אלעזר
Moreover, being able to do it programmatically is a security risk, since it requires elevated privileges that I don't know how to drop, and most people will not think about doing, but a library implementation will. So if someone uses subprocess.run(), and the system asks the user for elevated priv

Re: [Python-ideas] from __pip__ import

2016-09-20 Thread אלעזר
I think I generally understand concerns, and partially agree. I'm certainly not dismissing them. I only try to understand what are the precise problems and why the current situation - with dangerous functions at reach, easily buried deep in the code instead of marked on the top of the script - is s

Re: [Python-ideas] from __pip__ import

2016-09-20 Thread Paul Moore
On 20 September 2016 at 11:46, אלעזר wrote: > So it should be something like > > from unsafe.__pip__ import benchmark > > Where unsafe is the hypothetical namespace in which exec(), eval() and > subprocess.run() would have reside given your concerns. In my opinion, it should be # Please install

Re: [Python-ideas] from __pip__ import

2016-09-20 Thread Paul Moore
On 20 September 2016 at 11:40, אלעזר wrote: > I believe that at least some of these problems can be addressed given that > pip *knows* that this import is an in-script import. Not with pip as it is now. There's talk of detecting problem cases and reporting back "you need to restart your Python se

Re: [Python-ideas] from __pip__ import

2016-09-20 Thread אלעזר
On Tue, Sep 20, 2016 at 1:42 PM Paul Moore wrote: > On 20 September 2016 at 00:28, אלעזר wrote: > > On Tue, Sep 20, 2016 at 2:20 AM Stephen J. Turnbull > > wrote: > >> > >> אלעזר writes: > >> > >> > Another use case, though I admit not the top priority of anyone here, > >> is > >> > that of a

Re: [Python-ideas] from __pip__ import

2016-09-20 Thread Paul Moore
On 20 September 2016 at 00:28, אלעזר wrote: > On Tue, Sep 20, 2016 at 2:20 AM Stephen J. Turnbull > wrote: >> >> אלעזר writes: >> >> > Another use case, though I admit not the top priority of anyone here, >> is >> > that of assignment checkers. In most courses I took at the university, >> the >

Re: [Python-ideas] from __pip__ import

2016-09-20 Thread אלעזר
I believe that at least some of these problems can be addressed given that pip *knows* that this import is an in-script import. So the list of corner cases will be shorter. Elazar On Tue, Sep 20, 2016 at 1:35 PM Paul Moore wrote: > On 19 September 2016 at 23:46, אלעזר wrote: > >> import pip >

Re: [Python-ideas] from __pip__ import

2016-09-20 Thread Paul Moore
On 19 September 2016 at 23:46, אלעזר wrote: >> import pip >> pip.install('attrs') >> import attr > > Please forgive me for my ignorance, but it doesn't work as written - what's > the actual method? As David Mertz said, pip.main(['install', 'attrs']) works right now, but it is NOT a supported use

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Ethan Furman
On 09/19/2016 06:45 PM, Chris Angelico wrote: Yes we are (at least in that instance). With more real-world tests, they're allowed to use all the standard library - this was the "in some cases" bit. (We don't teach float multiplication, because it's very complication, but we do teach some stuff a

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Steven D'Aprano
On Mon, Sep 19, 2016 at 05:06:50PM -0700, Ethan Furman wrote: > On 09/19/2016 04:38 PM, אלעזר wrote: > > >I was talking specifically about advanced courses, in which an assignment > > is "implement a side-channel attack using data" and you can use whatever > > library you like. > > Am I misunders

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Chris Angelico
On Tue, Sep 20, 2016 at 10:42 AM, Steven D'Aprano wrote: > On Tue, Sep 20, 2016 at 09:34:12AM +1000, Chris Angelico wrote: > >> It's more than that, though. When a student is given an assignment, >> it's usually to help said student to learn to *write code*, not to >> learn how to walk into the pl

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Steven D'Aprano
On Mon, Sep 19, 2016 at 11:35:39PM +, אלעזר wrote: > Xavier, how is connecting and installing different from a windows popup > "this software requires changes to your firewall settings" or "requires > elevated privileges" which already happens. I am all for a two-step > process, but I think it

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Steven D'Aprano
On Mon, Sep 19, 2016 at 04:55:26PM +, אלעזר wrote: > A library in PyPi still requires installing it, which undermine many of > the benefits. It won't help me with my gist/activestate recipe, code that I > send to a friend, etc. I want to lower the barrier of inexperienced users. When you say

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Steven D'Aprano
On Tue, Sep 20, 2016 at 09:34:12AM +1000, Chris Angelico wrote: > It's more than that, though. When a student is given an assignment, > it's usually to help said student to learn to *write code*, not to > learn how to walk into the plumbing store of PyPI and look for > something that approximates

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Steven D'Aprano
On Mon, Sep 19, 2016 at 08:34:41PM +, אלעזר wrote: > If we have this syntax for Python3.6 3.6 now is under feature-freeze. The earliest any new features can be added is 3.7. -- Steve ___ Python-ideas mailing list Python-ideas@python.org https:/

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread אלעזר
On Tue, Sep 20, 2016 at 3:06 AM Ethan Furman wrote: > On 09/19/2016 04:38 PM, אלעזר wrote: > > > I was talking specifically about advanced courses, in which an assignment > > is "implement a side-channel attack using data" and you can use whatever > > library you like. > > Am I misunderstanding

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Ethan Furman
On 09/19/2016 04:38 PM, אלעזר wrote: I was talking specifically about advanced courses, in which an assignment is "implement a side-channel attack using data" and you can use whatever library you like. Am I misunderstanding, or did you just say you want this new functionality in order to im

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread אלעזר
But grepping and piping could work I assume? On Tue, Sep 20, 2016 at 2:41 AM Chris Angelico wrote: > On Tue, Sep 20, 2016 at 9:27 AM, Xavier Combelle > wrote: > > I find the idea of tracking the dependencies in the script might be a > > good idea. > > However, magically downloading without warn

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Chris Angelico
On Tue, Sep 20, 2016 at 9:27 AM, Xavier Combelle wrote: > I find the idea of tracking the dependencies in the script might be a > good idea. > However, magically downloading without warning the user is in my point > of view for sure a bad idea. > I would far prefer that pip could scan a script to

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread אלעזר
On Tue, Sep 20, 2016 at 2:34 AM Chris Angelico wrote: > On Tue, Sep 20, 2016 at 9:20 AM, Stephen J. Turnbull > wrote: > > אלעזר writes: > > > > > Another use case, though I admit not the top priority of anyone here, > is > > > that of assignment checkers. In most courses I took at the > univer

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread אלעזר
Xavier, how is connecting and installing different from a windows popup "this software requires changes to your firewall settings" or "requires elevated privileges" which already happens. I am all for a two-step process, but I think it should be more user friendly, and it can be done as a Python co

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Chris Angelico
On Tue, Sep 20, 2016 at 9:20 AM, Stephen J. Turnbull wrote: > אלעזר writes: > > > Another use case, though I admit not the top priority of anyone here, is > > that of assignment checkers. In most courses I took at the university, the > > person who checks the assignments says something like "yo

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread אלעזר
On Tue, Sep 20, 2016 at 2:20 AM Stephen J. Turnbull < turnbull.stephen...@u.tsukuba.ac.jp> wrote: > אלעזר writes: > > > Another use case, though I admit not the top priority of anyone here, is > > that of assignment checkers. In most courses I took at the university, > the > > person who checks

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Xavier Combelle
Le 19/09/2016 à 18:25, אלעזר a écrit : > Many proposals to add something to stdlib are rejected here with the > suggestion to add such library to pypi first. As noted by someone, > pypi is not as reachable as stdlib, and one should install that > package first, which many people don't know how. Ad

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Stephen J. Turnbull
אלעזר writes: > Another use case, though I admit not the top priority of anyone here, is > that of assignment checkers. In most courses I took at the university, the > person who checks the assignments says something like "you are allowed to > use only this this and this libraries", in order n

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread אלעזר
Sounds good, thanks. So I'll suggest adding the method mentioned in Paul's code as a promised API, either as pip.install or otherwise. `pip.main(['install', 'boltons'])` is not the clearest it can get. Elazar On Tue, Sep 20, 2016 at 2:02 AM David Mertz wrote: > >>> import pip > >>> pip.main(['

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread David Mertz
>>> import pip >>> pip.main(['install', 'boltons']) Requirement already satisfied (use --upgrade to upgrade): boltons in ./anaconda/lib/python3.5/site-packages 0 This is easy, short, and uses existing syntax and an existing module. Yes, I know technically the API isn't promised; I wouldn't object

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread אלעזר
On Tue, Sep 20, 2016 at 1:40 AM Paul Moore wrote: > On 19 September 2016 at 23:13, אלעזר wrote: > > Alternative syntax might be that of import decorators > > > > @from_pip("attrs") > > import attr > > At which point you may as well just (insert disclaimer about "using > pip's internal API isn't

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Paul Moore
On 19 September 2016 at 23:13, אלעזר wrote: > Alternative syntax might be that of import decorators > > @from_pip("attrs") > import attr At which point you may as well just (insert disclaimer about "using pip's internal API isn't supported" here, and glossing over the fact that pip doesn't yet ha

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread אלעזר
Alternative syntax might be that of import decorators @from_pip("attrs") import attr It's only worthwhile if there are any other uses for import decorators. One possibility is for other online modules, probably by giving a url. I can come up with more, but it's making a solution without having a

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread אלעזר
Another use case, though I admit not the top priority of anyone here, is that of assignment checkers. In most courses I took at the university, the person who checks the assignments says something like "you are allowed to use only this this and this libraries", in order not to mess with unknown dep

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Paul Moore
On 19 September 2016 at 21:34, אלעזר wrote: > 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

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread אלעזר
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 othe

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread MRAB
On 2016-09-19 19:48, Chris Angelico wrote: On Tue, Sep 20, 2016 at 4:43 AM, MRAB wrote: On 2016-09-19 18:20, אלעזר wrote: Obviously from __pip__ import "run-lambda>=0.1.0" Which is ugly but not my fault :) [snip] One possible problem I can see is that if it's quoted you might think th

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Paul Moore
On 19 September 2016 at 19:52, אלעזר 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 f

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Chris Angelico
On Tue, Sep 20, 2016 at 4:52 AM, אלעזר wrote: > Wow chris, that's a nice one! > > 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. True, it doesn't; but if anything else goes wrong, you have the

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread אלעזר
Wow chris, that's a nice one! 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. On Mon, Sep 19, 2016 at 9:48 PM Chris Angelico wrote: > On Tue, Sep 20, 2016 at 4:43 AM, MRAB wrote: > > On 2016-0

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread אלעזר
Then you'll get SyntaxError: from __pip__ imports must occur at the beginning of the file Or "must be string literal or an identifier" if it's allowed outside the beginning of the file. On Mon, Sep 19, 2016 at 9:44 PM MRAB wrote: > On 2016-09-19 18:20, אלעזר wrote: > > Obviously > > > >

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Chris Angelico
On Tue, Sep 20, 2016 at 4:43 AM, MRAB wrote: > On 2016-09-19 18:20, אלעזר wrote: >> >> Obviously >> >> from __pip__ import "run-lambda>=0.1.0" >> >> Which is ugly but not my fault :) >> > [snip] > One possible problem I can see is that if it's quoted you might think that > it's an expression a

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread MRAB
On 2016-09-19 18:20, אלעזר wrote: Obviously from __pip__ import "run-lambda>=0.1.0" Which is ugly but not my fault :) [snip] One possible problem I can see is that if it's quoted you might think that it's an expression and that you could also write: package = "run-lambda>=0.1.0"

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread אלעזר
Ryan I assume any error could be translated to your version through the `from ` statement too? Regarding the rabbit hole, the internet connection and privileges were required for running this script in the first place. I only suggest giving the developer - perhaps not a software engineer at all -

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Ryan Gonzalez
This sounds like a great idea, but I've seen stuff like this done before, and it never ends well. You end up with a gargantuan-sized rabbit hole, since running a basic script could now involve using an internet connection and potentially root permissions. IF one were to go this route, I prefer bun

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Sven R. Kunze
Which is still not allowed syntax IIRC? ;) On 19.09.2016 19:20, אלעזר wrote: Obviously from __pip__ import "run-lambda>=0.1.0" Which is ugly but not my fault :) On Mon, Sep 19, 2016 at 8:16 PM Sven R. Kunze > wrote: I can definitely understand your point.

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Paul Moore
On 19 September 2016 at 17:59, Joonas Liik wrote: > using pip from within python is not that difficult already. > as can be seen with a glance to: > http://stackoverflow.com/questions/12332975/installing-python-module-within-code Note that pip does not officially support any use of its internal A

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Paul Moore
On 19 September 2016 at 18:20, אלעזר wrote: > Obviously > > from __pip__ import "run-lambda>=0.1.0" If we were going to go down this route (which I'm not at all convinced we should) it should be "from __pypi__ import" not "from __pip__ import" (as PyPI is where the code is coming from, not pi

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread אלעזר
Obviously from __pip__ import "run-lambda>=0.1.0" Which is ugly but not my fault :) On Mon, Sep 19, 2016 at 8:16 PM Sven R. Kunze wrote: > I can definitely understand your point. > > The only issue with it (besides that it doesn't seem to be a good way for > dependency management) is how d

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Sven R. Kunze
I can definitely understand your point. The only issue with it (besides that it doesn't seem to be a good way for dependency management) is how do you manage the syntax involved here? Pip provides distributions. Each distribution contains a set of packages and modules. The latter can be impor

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread אלעזר
Thanks Joonas. I withdraw my proposal - nothing more is strictly needed. It should be idiomatic somehow, but I don't have any specific suggestion. On Mon, Sep 19, 2016 at 7:59 PM Joonas Liik wrote: > On 19 September 2016 at 19:55, אלעזר wrote: > > A library in PyPi still requires installing it

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Joonas Liik
On 19 September 2016 at 19:55, אלעזר wrote: > A library in PyPi still requires installing it, which undermine many of the > benefits. It won't help me with my gist/activestate recipe, code that I send > to a friend, etc. I want to lower the barrier of inexperienced users. > > As a documentation o

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread אלעזר
A library in PyPi still requires installing it, which undermine many of the benefits. It won't help me with my gist/activestate recipe, code that I send to a friend, etc. I want to lower the barrier of inexperienced users. As a documentation of dependencies it will suffice indeed. Elazar On Mon

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Ethan Furman
On 09/19/2016 09:25 AM, אלעזר wrote: Many proposals to add something to stdlib are rejected here with the suggestion to add such library to pypi first. As noted by someone, pypi is not as reachable as stdlib, and one should install that package first, which many people don't know how. Additio