views:

183

answers:

3

So you can use distutils to create a file, such as

PIL-1.1.6.win32-py2.5.exe

which you can run and use to easily install something. However, the installation requires user input to proceed (you have to click 'OK' three times). I want to create an easily installable windows version that you can just run as a cmd line program, that doesn't require input from the user. Is this possible? Do these .exe files do it already, but you need to pass them a magic cmd line argument to work?

A: 

You get the executable by running "setup.py bdist_wininst". You can have something simpler by running "setup.py bdist_dumb". This will produce a .zip file which, unzipped at the root of the drive where Python is installed, provided that it's installed in the same directory as the machine you've build it, will install the library.

Now I don't know if there is an unzip command-line utility under Windows that can be used to do that; I usually have Cygwin installed on all my Windows boxes, but it may prove quite simple to just ship it with the .zip.

fraca7
A: 

I have done this before using a simple batch file to call setuptools' install script passing the egg file path as an argument to it. The only trouble is that you need to ensure that script is in the PATH, which it might not be.

Assuming Python itself is in the PATH you can try something like this in a python script you would distribute with your egg (call it install.py or somesuch).

import sys
from pkg_resources import load_entry_point

def install_egg(egg_file_path):
    sys.argv[1] = egg_file_path
    easy_install = load_entry_point(
        'setuptools==0.6c9', 
        'console_scripts', 
        'easy_install'
    )
    easy_install()

if __name__ == "__main__":
    install_egg("PIL-1.1.6.win32-py2.5.egg")

Essentially this does the same as the "easy_install.py" script. You're locating the entrypoint for that script, and setting up sys.argv so that the first argument points at your egg file. It should do the rest for you.

HTH

jkp
+1  A: 

See this post which describes an idea to modify the stub installer like this:

It also mentions another alternative: use setup.py bdist_msi instead, which will produce an msi package, that can be installed unattended

David Fraser