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


Groups > comp.lang.python > #20944

Re: windows executable calling python script

Date 2012-02-27 15:05 +0000
From Andrea Crotti <andrea.crotti.0@gmail.com>
Subject Re: windows executable calling python script
References <4F4B8BE4.9070908@gmail.com> <4F4B916B.7080600@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.202.1330355127.3037.python-list@python.org> (permalink)

Show all headers | 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