Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Terry Reedy Newsgroups: comp.lang.python Subject: Re: Which Python editor has this feature? Date: Wed, 13 Jan 2016 04:05:18 -0500 Lines: 135 Message-ID: References: <830f6f97-22dd-488c-9dd6-e9cd92844307@googlegroups.com> <5f1619e5-83ff-449e-b7e5-2374a37bd50b@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Trace: news.uni-berlin.de j7jdr4OIvdcOilPRrAyifAR89n9thJvi2VVP1XleHVXg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; 'cache': 0.05; 'cpython': 0.05; 'gsoc': 0.05; 'executed': 0.07; 'main()': 0.07; 'mouse': 0.07; 'nicely': 0.07; 'postgresql': 0.07; 'subject:editor': 0.07; 'supported,': 0.07; 'versions.': 0.07; "ain't": 0.09; 'attribute.': 0.09; 'closed,': 0.09; 'exception:': 0.09; 'executes': 0.09; 'happen.': 0.09; 'ide': 0.09; 'indication': 0.09; 'none.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'refresh': 0.09; 'stale': 0.09; 'stderr': 0.09; 'stdout': 0.09; 'tracker,': 0.09; 'bug': 0.10; 'python': 0.10; 'assume': 0.11; 'anyway': 0.11; 'jan': 0.11; 'output': 0.13; 'apps': 0.15; 'folks': 0.15; '2016': 0.16; 'being,': 0.16; 'binaries': 0.16; 'carriage': 0.16; 'differnet': 0.16; 'display,': 0.16; 'experiment.': 0.16; 'fancy': 0.16; 'fruit.': 0.16; 'himself.': 0.16; 'hint': 0.16; 'hmm.': 0.16; 'idle,': 0.16; 'idle.': 0.16; 'invisible': 0.16; 'messy': 0.16; 'overwriting': 0.16; 'pip?': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'reedy': 0.16; 'relevant,': 0.16; 'such,': 0.16; 'suggestion.': 0.16; 'ugly.': 0.16; 'verbose': 0.16; 'wrote:': 0.16; 'app': 0.16; 'obviously': 0.16; 'attribute': 0.18; 'hacking': 0.18; 'thoughts': 0.18; 'version.': 0.18; 'widget': 0.18; 'written,': 0.18; 'creates': 0.18; 'gui': 0.18; 'runs': 0.18; 'student': 0.20; 'windows': 0.20; 'issue.': 0.20; 'fix': 0.21; 'so.': 0.22; '64-bit': 0.22; "aren't": 0.22; 'assuming': 0.22; 'parse': 0.22; 'produces': 0.22; 'sends': 0.22; 'tkinter': 0.22; 'am,': 0.23; 'seems': 0.23; 'tried': 0.24; 'import': 0.24; '(most': 0.24; 'url:edu': 0.24; 'header:In-Reply-To:1': 0.24; 'feature': 0.24; 'url:bugs': 0.24; 'module': 0.25; 'install': 0.25; 'header:User- Agent:1': 0.26; 'command': 0.26; 'installed': 0.26; 'header:X -Complaints-To:1': 0.26; 'chris': 0.26; 'connected': 0.27; 'supported': 0.27; 'packaging': 0.27; 'separate': 0.27; 'least': 0.27; 'issue,': 0.27; 'values': 0.28; 'always,': 0.29; 'command- line': 0.29; 'currently,': 0.29; 'itself,': 0.29; 'talked': 0.29; 'unlikely': 0.29; 'windows,': 0.29; 'random': 0.29; 'starts': 0.29; 'allows': 0.30; "i'm": 0.30; 'print': 0.30; 'too.': 0.30; 'work.': 0.30; 'code': 0.30; 'certainly': 0.30; "i'd": 0.31; 'checked': 0.31; 'supposed': 0.31; 'skip:s 30': 0.31; 'another': 0.32; "can't": 0.32; 'truth': 0.79; '"hey,': 0.84; '3.5.1': 0.84; 'about,': 0.84; 'actually,': 0.84; 'console,': 0.84; 'donald': 0.84; 'farms': 0.84; "it'd": 0.84; 'pip': 0.84; 'wheel': 0.84; 'wheels': 0.84; 'subject:this': 0.85; 'received:fios.verizon.net': 0.91; 'thing,': 0.93 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: pool-71-185-227-36.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:101597 On 1/12/2016 5:18 AM, Chris Angelico wrote: > On Tue, Jan 12, 2016 at 7:27 PM, Terry Reedy wrote: >> Can psycopg2 be installed with pip? There is an issue (#23551) to mak= e a >> pip GUI and make it accessible from IDLE. We need someone with both p= ip and >> tkinter knowledge to either design and write it or mentor a GSOC stude= nt to >> do so. One written, I would add an IDLE menu item to run it, in a sep= arate >> process, just as done now with turtledemo. > > Yes, invisible smiley... but with a hint of truth too. Obviously > installing PostgreSQL itself is outside the scope of IDLE, but > psycopg2 is indeed pip-installable... except that it isn't always, on > Windows, because wheels aren't available for all versions. (There's no > Python 3.5 wheel yet; at least, I can't see one on PyPI.) Maybe someone should give them a prod. It has been 4 months. http://www.lfd.uci.edu/~gohlke/pythonlibs/ only has psycopg, for 2.6. > So what I'm > really looking for isn't an IDLE feature but a Python packaging > feature - some people have talked about setting up build farms that > can produce wheels for people. Building binaries is a rather different issue, certainly on Windows. > Hmm. I just tried this, and actually, there's some possibly > low-hanging fruit. (Tested on Python 3.4.3 as 3.5 can't install > psycopg2 anyway.) > >>>> import pip; pip.main(["install","psycopg2"]) https://bugs.python.org/issue23551 has my report of experimenting with directly using pip.main. The main=20 issue I ran into is that pip creates a cache of 'currently installed=20 packages' the first time it needs it and never again during the same=20 process. In other words, pip.main is called exactly once when pip is=20 run from the command line. Another command from the command line starts = a new process, which makes a new cache. So calling main() repeatedly=20 may fail due to a stale cache. However, the need to refresh it is=20 predictable, so reloading the module may work. > This produces a rather messy display, because pip.main seems to assume > that writing carriage returns to the console will result in the > display nicely overwriting (producing a moving progress bar as the > file gets downloaded). If IDLE can't handle carriage returns as such, > an easy fix would be to simply display them as complete lines; it > would be more verbose than the normal console behaviour, but not as > ugly. Currently, Idle sends user code output to the tk Text widget as is,=20 except for colorizing. There was an issue about changing this, but it=20 was closed, at least for the time being, as Python allows print to send=20 output to any file and does not require than stdout be connected to a=20 'console', and anyway there is no standard for console behavior. A gui program that runs pip and displays its output would generally=20 parse output for display in differnet widgets. > > A couple of other random thoughts from this experiment. > > * Going to python.org and pointing the mouse at the download link got > me 3.5.1 32-bit. This is on Google Chrome on a Windows 7 64-bit VM. > * Instead of pip.main(["install","psycopg2"]), I'd like to be able to > say pip.install("psycopg2"). In fact, I might take that to the pip > folks as a suggestion. > * The performance difference between "import pip" on 3.4.3 and 3.5.1 > was dramatic! I don't know whether it's CPython that's been sped up or > pip itself, but it's awesome! Try with 3.4.4, as I believe its installer should also update to the=20 most recent pip version. > There's some kind of issue between pip and Idle that means that > installing a non-wheel blows up with an exception: > > > Traceback (most recent call last): > File "C:\Users\Rosuav\AppData\Local\Programs\Python\Python35-32\lib\= site-packages\pip\basecommand.py", > ... > return s.decode(sys.__stdout__.encoding) > AttributeError: 'NoneType' object has no attribute 'encoding' Assuming that sys.__sydout__ is not None is a bug on pip's part.=20 Perhaps you could report it to it list or tracker, and point Donald and=20 whoever to https://docs.python.org/3/library/sys.html#sys.__stdin__ "Note Under some conditions stdin, stdout and stderr as well as the original=20 values __stdin__, __stdout__ and __stderr__ can be None. It is usually=20 the case for Windows GUI apps that aren=E2=80=99t connected to a console = and=20 Python apps started with pythonw." IDLE is a GUI app that on Windows is started with pythonw.exe. More=20 relevant, user code is executed in a windowless pythonw process. The=20 same problem should occur with any IDE that executes user code in a=20 pythonw process. A GUI program could work around the bug by setting sys.__stdin__ to an=20 object with a .encoding attribute. I checked that this can be done. > Maybe calling pip.main just isn't a supported thing, but it'd be nice > if there were _some_ way to do this, even without a fancy GUI. Calling is once during a process is supported, or supposed to be. If you ran, at the console, > pythonw.exe -c "import pip; pip.main(['install','psycopg2'])" the same failure would happen. However, the only indication of failure, = before you checked site-packages and found no psycopg2, would be the=20 quick return to the console prompt. > How much of this is worth doing anything about, and how much is "hey, > you're hacking around calling a command-line tool from inside a GUI, > and stuff ain't a'gonna work right"? On the issue linked above, Donald Stuffit, a (the?) pip maintainer, said = that he wanted there to be a pip Gui, even though he was unlikely to=20 write it himself. We have identified 3 problems; I believe all can be=20 worked around. I added your two and the workarounds to the issue. --=20 Terry Jan Reedy