Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #26952

Re: suggesting a launcher wrapper script for portable python

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
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; 'python.': 0.02; 'case.': 0.05; 'arguments': 0.07; 'filenames': 0.07; 'skip:% 20': 0.07; 'suffix': 0.07; 'wrapper': 0.07; 'scripts': 0.09; 'python': 0.09; '@echo': 0.09; 'callable': 0.09; 'directory)': 0.09; 'ide': 0.09; 'mentions': 0.09; 'portable': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'scripting': 0.09; 'subject:script': 0.09; 'url:peps': 0.09; 'skip:= 70': 0.10; "wouldn't": 0.11; 'subject:python': 0.11; 'assume': 0.11; 'file,': 0.15; "'..'": 0.16; '(assuming': 0.16; '.py': 0.16; 'cases)': 0.16; 'echo': 0.16; 'message-id:@dough.gmane.org': 0.16; "pc's": 0.16; 'preserved': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'rem': 0.16; 'scripts.': 0.16; 'such,': 0.16; 'though)': 0.16; 'woudl': 0.16; 'wrote:': 0.17; 'directory.': 0.17; 'exists': 0.17; 'script.': 0.17; 'url:dev': 0.17; 'shell': 0.18; 'windows': 0.19; 'skip:p 30': 0.20; 'skip:" 30': 0.20; 'suggested': 0.20; 'file.': 0.20; 'written': 0.20; 'dropped': 0.22; 'minor': 0.22; 'parse': 0.22; 'skip:% 10': 0.22; "i'd": 0.22; 'needed.': 0.23; 'seems': 0.23; 'thus': 0.24; 'non': 0.24; 'command': 0.24; 'host': 0.24; 'script': 0.24; 'header:In- Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; '(which': 0.26; 'creating': 0.26; 'wrote': 0.26; 'appreciated.': 0.26; 'compiled': 0.27; 'implemented': 0.27; '???': 0.27; 'thoughts': 0.27; 'header:X-Complaints-To:1': 0.28; 'run': 0.28; 'installed,': 0.29; "i'm": 0.29; 'install': 0.29; 'related': 0.30; 'waste': 0.30; 'window': 0.30; 'feedback': 0.30; 'seconds': 0.30; 'located': 0.31; 'url:python': 0.32; 'file': 0.32; 'from:addr:yahoo.co.uk': 0.32; 'launch': 0.32; 'running': 0.32; 'skip:- 10': 0.32; 'could': 0.32; 'done,': 0.33; 'to:addr:python-list': 0.33; 'recommended': 0.33; 'version': 0.34; 'self': 0.34; 'described': 0.35; 'exist': 0.35; 'add': 0.36; 'received:org': 0.36; 'created': 0.36; 'but': 0.36; 'url:org': 0.36; "didn't": 0.36; 'method': 0.36; 'useful': 0.36; 'enough': 0.36; 'does': 0.37; 'two': 0.37; 'ones': 0.37; 'passed': 0.37; 'rather': 0.37; 'subject:: ': 0.38; 'mark': 0.38; 'store': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'release': 0.39; 'header:Received:5': 0.40; 'help': 0.40; 'end': 0.40; 'think': 0.40; 'skip:u 10': 0.60; 'kind': 0.61; 'launching': 0.62; 'provide': 0.62; 'more': 0.63; 'great': 0.64; 'here': 0.65; 'started.': 0.65; 'stuck': 0.65; 'sounds': 0.71; 'click': 0.76; 'article': 0.78; 'drive.': 0.84; 'gelonida': 0.84; 'launches': 0.84; 'replicate': 0.84; 'surprised,': 0.84; "they'd": 0.84; 'drops': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Mark Lawrence <breamoreboy@yahoo.co.uk>
Subject Re: suggesting a launcher wrapper script for portable python
Date Sun, 12 Aug 2012 20:52:54 +0100
References <k06uj3$c6q$1@dough.gmane.org>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host host-78-147-182-103.as13285.net
User-Agent Mozilla/5.0 (Windows NT 6.0; rv:14.0) Gecko/20120713 Thunderbird/14.0
In-Reply-To <k06uj3$c6q$1@dough.gmane.org>
X-Antivirus avast! (VPS 120812-0, 12/08/2012), Outbound message
X-Antivirus-Status Clean
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3210.1344801132.4697.python-list@python.org> (permalink)
Lines 140
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1344801132 news.xs4all.nl 6943 [2001:888:2000:d::a6]:52353
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:26952

Show key headers only | View raw


On 12/08/2012 01:49, Gelonida N wrote:
> I just started looking at portable Python and was rather surprised, that
> I didn't find any recommended method in the documentation of how to
> launch scripts with portable python.
> Creating py2exe scripts on ones own USB drive seems to be kind of overkill.
>
> So here my own thoughts / suggestsions.
> I'm interestted in feedback of how others use portable pythons
> and how they run their scripts from a USB stick.
>
>
> Let's assume I install portable python on my USB drive and then I'd like
> to store self written python scripts on this drive.
>
> It would of course be greate if I could just click on the script and
> they'd be started.
>
>
> However under windows this would not be the case.
> The python script would either not be started at all or if the PC had
> his own python installed, then the script would be started with the PC's
> version of python.
>
> Thus a tiny wrapper script would be needed.
>
>
> Suggestion:
> --------------
> The current directory structore for portable python (2.7) is (assuming
> that %PP% is the base directory)
>
> %PP%/Python-Portable.exe       # launches the python interactive shell
> %PP%/PyScripter-Portable.exe   # launches some IDE
> %PP%/App
>
> Let's assume I add two more directories:
> %PP%/myscripts    # location of all callable scripts
> %PP%/launchers    # location with icons one can click on
>                    # to start the scripts in myscripts
>
>
>
>
> if I wrote a script named %PP%/myscripts/test1.py,
> and I created an aproprriate  named %PP%/launchers/test1.bat
>
> then I could just click on test1.bat and the Python script test1.py
> would be started. If the wrapper script is written properly, then it can
> look at its own base name and call the related python script.
>
> If I dragged and dropped some filenames on the bat file, then they would
> be passed to sys.argv of the script.
>
> Running the script from command line would also work and the present
> working directory would be preserved (which might be useful in some cases)
>
> If the script name would not be .py, but .pyw then it woudl be started
> with pythonw.
> T
>
> Below suggested script:
>
>
>
> @echo off
> REM
> =========================================================================
> REM script to start a python file with portable python
> REM
> =========================================================================
>
> REM basepath of this .bat file
> set basepath=%~dp0
>
> REM create the name of the python file related to this bat file
> REM Unfortunately I do not know how to normalyze %pyfile%,
> REM so we got stuck with the '..'
> set pyfile=%basepath%..\myscripts\%~n0.py
>
> If EXIST "%pyfile%" (
>      REM a normal console python file with .py suffix
>      "%basepath%\..\App\python.exe" "%pyfile%"  %*
> ) ELSE (
> If EXIST "%pyfile%w" (
>      REM a non  console python file with .pyw suffix
>      start "" "%basepath%\..\App\pythonw.exe" "%pyfile%w"  %*
> ) ELSE (
>      REM found neither a .py nor a .pyw file
>      echo found no python file %pyfile%
> )
> )
> REM
> =========================================================================
> REM end of script
> REM
> =========================================================================
>
>
> One minor drawback of my suggested script would be, that a console
> window pops up for a few seconds when starting a .pyw file.
>
> This could be avoided by using either a small compiled C-file (which
> sounds like overkill though)
> or by writing a windows scripting host .wsf file.
> However I don't know this well enough to replicate my batch file.
> AN article on SO mentions how to write such a script.
> However it does not parse command line arguments nor does it
> automatically determine the scripts file name.
> So any help for creating a .wsf file starting a .pyw file with command
> line arguments would be appreciated.
>
>
>
> An alternativce approach could be to provide a scipt named
> mk_wrapper.bat
> If one drags and drops a python script on it, then an apropriate wrapper
> file would be created in the launcher directory.
>
> If well done, then this could be implemented such, that the script may
> be located in an arbitrary location on the same USB drive.
>
>
>
> I think it would be great if the official portable python release
> contained some upport for launching scripts.
> Perhaps it exists alrady and I just didn't find it?
>
> If not,then I wouldn't mind if my script or a similiar sand a related
> README.txt cript were added to the official release
>

This might be a complete waste of time but can you use the new windows 
launcher described here http://www.python.org/dev/peps/pep-0397/ ???


-- 
Cheers.

Mark Lawrence.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: suggesting a launcher wrapper script for portable python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-12 20:52 +0100

csiph-web