Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > bootstrapping on machines without Python

Reply
Thread Tools

bootstrapping on machines without Python

 
 
Jonathan Hartley
Guest
Posts: n/a
 
      11-13-2009
While examining py2exe et al of late, my thoughts keep returning to
the idea of writing, in C or similar, a compiled stand-alone
executable 'bootstrapper', which:
1) downloads and install a Python interpreter if none exists
2) runs the application's Python source code using this interpreter.

An application source code could be distributed with this small exe to
wrap its top level 'main.py', and the application could then be run on
machines which do not (yet) have Python installed.

The goal of this is to provide a way for end-users to download and
double-click a Python application, without having to know what Python
is or whether (an appropriate version of) it is installed. This method
has some disadvantages compared to using py2exe et al, but it has the
advantage that a small application would remain small: there is no
need to bundle a whole interpreter with every application. From an
advocacy point of view, it also must help that merely running such an
application would seamlessly put a usable Python interpreter installed
and on the PATH on Windows boxes.

Even my very limited understanding of the issues is enough to see that
the idea is far from trivial. I'm aware that great minds are working
on related and overlapping problems, so I thought I'd ask whether many
people have done this already, and if not, is there any value in
taking the trivial first step described above? ie. Ignore all
complications, and write a simple C program to download & install an
interpreter, then use that to run my Python.

In the long run, to be useful for real projects, the bootstrapper
would need to manage some nasty details:
* different versions of the interpreter for different applications
* download required packages
* manage conflicting versions of packages
I'm hoping that these thorny problems will be solved, if they aren't
already, by the great minds working on packaging, etc.

I'm very aware that I don't know anything at all about this, compared
to many on the list. Be gentle with me.
 
Reply With Quote
 
 
 
 
Tim Golden
Guest
Posts: n/a
 
      11-13-2009
Jonathan Hartley wrote:
> While examining py2exe et al of late, my thoughts keep returning to
> the idea of writing, in C or similar, a compiled stand-alone
> executable 'bootstrapper', which:
> 1) downloads and install a Python interpreter if none exists
> 2) runs the application's Python source code using this interpreter.


Thinking aloud about what you're describing here... Assuming Windows,
as your starting point is py2exe and I imagine that most Unix-like
boxes already have Python on them.

Step 1: The user downloads a tiny myapp.exe which is basically a zip of the
myapp package / files plus an .exe header which will...

Step 2a: ... download a minimised? (ie custom-built) Python interpreter
and stdlib bundle which is just enough to run the app. Or...

Step 2b: ... download and install the official python.org Windows
installer for version x.y identified as the highest known to run
this app if...

Step 2bi) ... that version of the interpreter isn't already installed
and registered on that machine (at least: for that user).

My step 2a seems to be little better than a bundled py2exe, so I can
only assume you mean Step 2b, especially given your comment below
about ending up with an installation of Python where one wasn't
before. This, though, seems fraught with accusations of backdoor
installations etc.

Have I misunderstood you? For the Record, I'm entirely in favour of moves
to make Python use on Windows more seamless, attractive, consistent,
etc. I was going to comment positively on your recent PyChooser widget
and to plug a similar but unpublished one of my own. But I'm not sure
if this particular proposal has enough wings to make it fly.

TJG
 
Reply With Quote
 
 
 
 
Martin P. Hellwig
Guest
Posts: n/a
 
      11-13-2009
Jonathan Hartley wrote:
> While examining py2exe et al of late, my thoughts keep returning to
> the idea of writing, in C or similar, a compiled stand-alone
> executable 'bootstrapper', which:
> 1) downloads and install a Python interpreter if none exists
> 2) runs the application's Python source code using this interpreter.

<cut>

I can see two distinctive scenarios:
- Local temporarily installation
- System wide installation (possible conflicts with older versions)

Anyway this reminds me of the web installers where you only download the
installer which download the rest from the net, like they used to be
available from adobe and for java.

It should be doable, for example you have an executable which has only
one function; download a second stage installer from a fixed location.

That second stage installer is a bit bigger and knows how to check for
dependencies for that particular platform and install other dependencies.

So you can chain a lot of installers after each other, for example the
second stage installer can be a python installer then you could do all
the remaining installing from the convenience of python.


--
MPH
http://blog.dcuktec.com
'If consumed, best digested with added seasoning to own preference.'
 
Reply With Quote
 
Thomas Heller
Guest
Posts: n/a
 
      11-13-2009
M.-A. Lemburg schrieb:
> Jonathan Hartley wrote:
>> While examining py2exe et al of late, my thoughts keep returning to
>> the idea of writing, in C or similar, a compiled stand-alone
>> executable 'bootstrapper', which:
>> 1) downloads and install a Python interpreter if none exists
>> 2) runs the application's Python source code using this interpreter.
>>
>> An application source code could be distributed with this small exe to
>> wrap its top level 'main.py', and the application could then be run on
>> machines which do not (yet) have Python installed.
>>
>> The goal of this is to provide a way for end-users to download and
>> double-click a Python application, without having to know what Python
>> is or whether (an appropriate version of) it is installed. This method
>> has some disadvantages compared to using py2exe et al, but it has the
>> advantage that a small application would remain small: there is no
>> need to bundle a whole interpreter with every application.

>
> There are two major issues with such an approach:
>
> * users will not necessarily like it if a small application
> downloads a several MB from the web somewhere without asking
>
> * installing applications on Windows typically requires admin
> rights or at least user interaction
>
> I think a good solution to the problem is wrapping the application's
> main.py in a batch file which pops up a window to let the user know
> that s/he will need to install Python first and point him/her to the
> www.python.org web site, if necessary.


Here is a batch file that simulates a similar approach,
for demonstration purposes it doesn't download and install python,
instead it simply copies 'c:\python25\python.exe' to the current directory
under a different name (if it is not yet present), and executes the script with it.
Batchfile experts should also be able to improve other things:

<snip>
@echo off && if exist py_exe.exe (py_exe.exe -x %0 %* && goto exit) else (goto download)
# The python script
import sys
print "Hi, this is Python", sys.version
sys.exit()

# rest of the batch file
"""
:download
echo Simulating download...
copy c:\python25\python.exe py_exe.exe
echo Done.
REM start the script again after downloading
%0 %*

:exit
rem """
</snip>

Thomas
 
Reply With Quote
 
mmanns@gmx.net
Guest
Posts: n/a
 
      11-13-2009
On Fri, 13 Nov 2009 02:40:28 -0800 (PST)
Jonathan Hartley <(E-Mail Removed)> wrote:

> Even my very limited understanding of the issues is enough to see that
> the idea is far from trivial.


[...]

> In the long run, to be useful for real projects, the bootstrapper
> would need to manage some nasty details:
> * different versions of the interpreter for different applications
> * download required packages
> * manage conflicting versions of packages


An easy approach could be to use the portable apps version of Python.
(I assume that you use Windows.)

After installing portable Python on your computer, your application
and any additional libraries are put into the site-packages / Scripts
folders. Next, the install folder is zipped and provided for download.

A batch script, which is downloaded and run by the user, downloads the
zip file and extracts it. The script executes python.exe with your
Python script as command line argument.

In this scenario, the user would not need Administrator privileges.
You could also get around compatibility problems by providing
preferred versions of additional libraries in the site-packages folder
of portable Python.

However, the download size would probably exceed 100 MB. I also do not
know if there are licensing issues using portable Python like this.

Martin

 
Reply With Quote
 
Jonathan Hartley
Guest
Posts: n/a
 
      11-14-2009
On Nov 13, 1:57*pm, Tim Golden <(E-Mail Removed)> wrote:
> Jonathan Hartley wrote:
> > While examining py2exe et al of late, my thoughts keep returning to
> > the idea of writing, in C or similar, a compiled stand-alone
> > executable 'bootstrapper', which:
> > 1) downloads and install a Python interpreter if none exists
> > 2) runs the application's Python source code using this interpreter.

>
> Thinking aloud about what you're describing here... Assuming Windows,
> as your starting point is py2exe and I imagine that most Unix-like
> boxes already have Python on them.
>
> Step 1: The user downloads a tiny myapp.exe which is basically a zip of the
> myapp package / files plus an .exe header which will...
>
> Step 2a: ... download a minimised? (ie custom-built) Python interpreter
> and stdlib bundle which is just enough to run the app. Or...
>
> Step 2b: ... download and install the official python.org Windows
> installer for version x.y identified as the highest known to run
> this app if...
>
> Step 2bi) ... that version of the interpreter isn't already installed
> and registered on that machine (at least: for that user).
>
> My step 2a seems to be little better than a bundled py2exe, so I can
> only assume you mean Step 2b, especially given your comment below
> about ending up with an installation of Python where one wasn't
> before. This, though, seems fraught with accusations of backdoor
> installations etc.
>
> Have I misunderstood you? For the Record, I'm entirely in favour of moves
> to make Python use on Windows more seamless, attractive, consistent,
> etc. I was going to comment positively on your recent PyChooser widget
> and to plug a similar but unpublished one of my own. But I'm not sure
> if this particular proposal has enough wings to make it fly.
>
> TJG


Hi Tim. Thanks for that.

Yes, you have understood pretty much perfectly. I was envisaging
something like 2b.

I'm very much enamored of creating cross-platform apps, but I'm
focused on deployment on Windows first, because this is where most
users are, and also where the problem seems to need the most work.

Your input is very much appreciated. It may be that you are right that
I haven't thought this through clearly enough.

Incidentally, I'd love to see your approach of dealing with the
problem that pychoose addresses - Since creating it, I'm gripped with
paranoia that it is failing to take account of lots of things which
will trip me up later (or worse- trip other people up too, if anyone
uses it)
 
Reply With Quote
 
Jonathan Hartley
Guest
Posts: n/a
 
      11-14-2009
On Nov 13, 10:25*pm, (E-Mail Removed) wrote:
> On Fri, 13 Nov 2009 02:40:28 -0800 (PST)
>
> Jonathan Hartley <(E-Mail Removed)> wrote:
> > Even my very limited understanding of the issues is enough to see that
> > the idea is far from trivial.



Thanks heaps for the input from everyone. Martin Lemburg's 'chained'
approach does sound like the smart way to do it, and Thomas does
demonstrate pretty much the simplest possible example of what I'm
thinking of. Martin Manns' portable Python sounds useful too, and is
not disimilar to a suggestion made by Michael Foord off list.

However, the problems that Tim, Martin, Marc and Martin point out do
seem very real. I think users could be placated about 'backdoor
installation' if we tell them what's going on, with an OK button. But
I confess I wasn't aware that a full Python install is quite so large
compared to the bundle produced by py2exe et al.

Perhaps this idea is overly idealistic then - I was maybe transfixed
by the 'needless consistency' of sharing a single interpreter between
many applications.

Thanks for helping me straighten out my thoughts on the subject.

Best!

Jonathan
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[ANN] Bootstrapping Ruby with MinGW: selfhosted and test sandbox! Luis Lavena Ruby 32 05-09-2008 12:47 PM
Bootstrapping Mauler Python 2 05-24-2007 05:03 PM
Networking 2 win xp machines without router Uplink Computer Information 2 02-24-2006 03:24 PM
What platforms have Python Virtual Machines and what version(s) of Python do they support? Casey Hawthorne Python 4 06-19-2005 09:20 PM
server bootstrapping upon connection (WARNING: LONG) Fortepianissimo Python 13 02-13-2004 04:45 PM



Advertisments