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


Groups > comp.lang.python > #20944

Re: windows executable calling python script

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <andrea.crotti.0@gmail.com>
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; '#include': 0.05; 'interpreter': 0.05; 'char': 0.07; 'wrapper': 0.07; 'python': 0.08; '(char': 0.09; 'shortcut': 0.09; 'solution,': 0.09; 'subject:script': 0.09; 'subject:windows': 0.09; 'todo:': 0.09; 'subject:python': 0.10; 'argument': 0.15; '*const': 0.16; '0};': 0.16; 'argc,': 0.16; 'executable,': 0.16; 'executable.': 0.16; 'exit(1);': 0.16; 'main(int': 0.16; 'this:': 0.16; 'wrote:': 0.18; 'arguments': 0.18; 'exists': 0.18; 'int': 0.18; "doesn't": 0.22; 'header:In-Reply-To:1': 0.22; '(without': 0.23; 'fix': 0.25; 'function': 0.27; 'pm,': 0.29; 'message-id:@gmail.com': 0.31; 'header:User-Agent:1': 0.33; 'record': 0.34; 'executable': 0.34; 'to:addr:python-list': 0.35; 'something': 0.35; 'received:209.85.214': 0.36; 'to:name:python-list': 0.37; 'run': 0.37; 'received:10.0.0': 0.37; 'but': 0.37; 'received:google.com': 0.37; 'not,': 0.38; 'received:209.85': 0.38; 'think': 0.38; 'easier': 0.38; 'received:209': 0.39; 'to:addr:python.org': 0.40; 'header:Received:6': 0.61; 'full': 0.62; 'link': 0.62; 'andrea': 0.84
Received-SPF pass (google.com: domain of andrea.crotti.0@gmail.com designates 10.204.152.219 as permitted sender) client-ip=10.204.152.219;
Authentication-Results mr.google.com; spf=pass (google.com: domain of andrea.crotti.0@gmail.com designates 10.204.152.219 as permitted sender) smtp.mail=andrea.crotti.0@gmail.com; dkim=pass header.i=andrea.crotti.0@gmail.com
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=O+uy8kLvgDGy8Fl2qf6DxLLPhDxcP9OhvsmqoCSkNK0=; b=CBH0t6FM3VPitKAdZgxvbTETZbe2PruOAJsWwob38OXZ8Tyfdu9FzOqSz0bZKnf08N oxYqsPS4DQaebrMeSXR+fu75nYnIXyhUvd+pJZwzMfVjYdt5yYojtWAo1BacCfBYu80I QvhYKKFY9+dehFf1Z9y2kjGXiIWtatfmdpNcQ=
Date Mon, 27 Feb 2012 15:05:22 +0000
From Andrea Crotti <andrea.crotti.0@gmail.com>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:10.0.2) Gecko/20120217 Thunderbird/10.0.2
MIME-Version 1.0
To python-list <python-list@python.org>
Subject Re: windows executable calling python script
References <4F4B8BE4.9070908@gmail.com> <4F4B916B.7080600@gmail.com>
In-Reply-To <4F4B916B.7080600@gmail.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
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.202.1330355127.3037.python-list@python.org> (permalink)
Lines 49
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1330355127 news.xs4all.nl 6860 [2001:888:2000:d::a6]:37269
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:20944

Show key headers only | View raw


On 02/27/2012 02:21 PM, Andrea Crotti wrote:
>
> At the moment I ended up with something like this:
>
> #include <stdarg.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include <unistd.h>
>
>
> // the function takes as arguments only the python interpreter full path
> int main(int argc, char *argv[])
> {
>   if (argc < 2) {
>     fprintf(stderr, "Usage = ./run <python_executable_path>");
>     exit(1);
>   }
>   /* TODO: make the path absolute? is it necessary? */
>   char *const to_run[1] = {"run.py"};
>   /* TODO: check if the path exists or not, and if it's executable */
>
>   execv(argv[1], to_run);
>   return 1;
> }
>
> which still doesn't work (I have to fix the execv) but when it will in 
> theory I will only need
> to tell NSIS to create a link to that executable passing as argument 
> the right python executable.
> After that it will run the run.py with in the local directory..
>
> Easier ways (without py2exe and similars?)?

For the record I think I found a solution, now the wrapper works:
int main(int argc, char *argv[])
{
   if (argc < 2) {
     fprintf(stderr, "Usage = ./run <python_executable_path>");
     exit(1);
   }
   /* TODO: make the path absolute? is it necessary? */
   char *const to_run[] = {"python", RUNNER, (char *) 0};
   execv(argv[1], to_run);
   return 1;
}

and I only need to tell NSIS to create a shortcut passing as argument 
the path to the python executable,
nice and simple..

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


Thread

Re: windows executable calling python script Andrea Crotti <andrea.crotti.0@gmail.com> - 2012-02-27 15:05 +0000

csiph-web