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


Groups > comp.lang.python > #20940

Re: windows executable calling python script

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!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; 'script,': 0.07; 'python': 0.08; 'subject:script': 0.09; 'subject:windows': 0.09; 'todo:': 0.09; 'subject:python': 0.10; 'argument': 0.15; 'projects,': 0.15; '*const': 0.16; 'argc,': 0.16; 'cmake': 0.16; 'exe': 0.16; 'executable.': 0.16; 'exit(1);': 0.16; 'main(int': 0.16; 'name),': 0.16; 'pyinstaller': 0.16; 'setuptools': 0.16; 'this:': 0.16; 'wrote:': 0.18; 'arguments': 0.18; 'exists': 0.18; 'int': 0.18; 'somehow': 0.18; 'compiled': 0.21; "doesn't": 0.22; 'header:In- Reply-To:1': 0.22; '(without': 0.23; 'similar,': 0.23; 'fix': 0.25; 'creating': 0.25; 'code': 0.26; 'function': 0.27; 'project,': 0.28; 'script': 0.28; 'anyway.': 0.29; 'pm,': 0.29; 'installer': 0.30; 'message-id:@gmail.com': 0.31; "i've": 0.32; 'does': 0.32; 'there': 0.33; 'header:User-Agent:1': 0.33; 'easiest': 0.34; 'executable': 0.34; 'yet,': 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; 'using': 0.37; 'not,': 0.38; 'received:209.85': 0.38; 'some': 0.38; 'easier': 0.38; '(with': 0.39; 'received:209': 0.39; 'to:addr:python.org': 0.40; 'header:Received:6': 0.61; 'full': 0.62; 'link': 0.62; 'saw': 0.66; 'ship': 0.78; 'andrea': 0.84
Received-SPF pass (google.com: domain of andrea.crotti.0@gmail.com designates 10.204.129.203 as permitted sender) client-ip=10.204.129.203;
Authentication-Results mr.google.com; spf=pass (google.com: domain of andrea.crotti.0@gmail.com designates 10.204.129.203 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=uqYwz2A8DgfCEYhrB6p97CTYk9mUFYowcj4cZR4TcnQ=; b=n1PLXoCfUKt3Xmn/R59n+zJpa/rt2kG7arV3b/Mw5V/q0i12+m15hMFXfQB7unOmPl J6sM4V0GNQaAlTjlStu/O+4qnnbNbRW7XStQs2F53EQkQD60RKurCNON19Mf1a/oz+2E mSpmecz2I3pDD0hCQk9V4ElkKkYBn5/3WL8Ks=
Date Mon, 27 Feb 2012 14:21:31 +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>
In-Reply-To <4F4B8BE4.9070908@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.199.1330352496.3037.python-list@python.org> (permalink)
Lines 49
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1330352496 news.xs4all.nl 6882 [2001:888:2000:d::a6]:47647
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:20940

Show key headers only | View raw


On 02/27/2012 01:57 PM, Andrea Crotti wrote:
> I am creating an installer for python projects, using CMake and NSIS.
>
> Now my goal is to be able to select at installer time the python 
> executable that will run that project,
> and then associate them.
>
> I saw that setuptools is able to generate exe wrappers, but how does 
> that work exactly?
> From what I've understood there is some compiled C code that somehow 
> calls the python script, is that correct?
> Supposing I ship this executable in the same directory of the python 
> script (with a known name), is there a way
> to make it run the right python interpreter?
>
> The best and easiest solution would be to generate the full installer 
> with PyInstaller or similar, but unfortunately
> that doesn't work yet, and we would still need both approaches anyway.

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?)?

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 14:21 +0000

csiph-web