Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I specify the default install path of an msi in cx_freeze and distutils?

I am trying to create an installer from a Python application we coded. I wrote a simple setup.py file and it generates a .msi file no problem, but I can't figure out the way to specify the default install path. We don't want it to install to the default "C:\Program Files" directory. Help?

like image 864
Cesar Avatar asked Apr 03 '12 03:04

Cesar


2 Answers

Distutils is rather limited in functionality when it comes to creating installers. I would suggest you use NSIS instead. Its quite simple and lets you customise a lot more than distutils.

The other way would be to manually add --initial-target-dir to the argument list in setup.py (before calling the setup function):

if 'bdist_msi' in sys.argv:
    sys.argv += ['--initial-target-dir', 'c:\default\path']
like image 58
aquavitae Avatar answered Oct 17 '22 15:10

aquavitae


It appears that in the current version, adding the following to your setup script provides the same functionality:

setup(
    ...
    options={'bdist_msi': {'initial_target_dir': 'C:\\alternate\\start\\path'}}
    ...
)

Note that it requires the backslash, not the forward slash.

like image 41
dvntehn00bz Avatar answered Oct 17 '22 15:10

dvntehn00bz