Home > Mobile >  Cx_freeze bdist_msi directories syntax? how to interpret 'directory_table'
Cx_freeze bdist_msi directories syntax? how to interpret 'directory_table'

Time:02-10

I am having trouble creating new directories with the MSI generated with cx_freeze. I don't understand the windows direcotry_tables object and there is little to no documentation explaining it. has anyone had any success with this?

here is the documentation for the setup script for cx_freeze bdist_msi.

https://cx-freeze.readthedocs.io/en/latest/setup_script.html#commands

similar windows documentation on 'directory tables'

https://docs.microsoft.com/en-us/windows/win32/msi/directory-table?redirectedfrom=MSDN

I would like my installer to create a directory in C:\ProgramData but I can't figure out what arguments to use in the "directory_table" 3 tuple to do this. Below is the default example directory table which works with no errors but I am not sure where the directory is actually put.

directory_table = [
    ("ProgramMenuFolder", "TARGETDIR", "."),
    ("MyProgramMenu", "ProgramMenuFolder", "MYPROG~1|My Program"),]

Hopefully someone has run into this previously, thanks for the help. below is my setup.py:

from cx_Freeze import setup, Executable
import sys

company_name = 'MyCompany'
product_name = 'TestTKApp'


#list of 3-tuples.  need help here. 
directory_table = [
    ("ProgramMenuFolder", "TARGETDIR", "."),
    ("MyProgramMenu", "ProgramMenuFolder", "MYPROG~1|My Program"),]

base = None
if sys.platform == 'win32':
    base = 'Win32GUI'
    
build_exe_options = {"includes": ["testmath"],
                     "path" : sys.path,
                     "include_files": [(r"PATH\TO\SOME\FILE","junk.txt")],
                     
                     }

bdist_msi_options = {
    # 'upgrade_code': '{66620F3A-DC3A-11E2-B341-002219E9B01E}',
    'add_to_path': False,
    'initial_target_dir': r'C:\ProgramFiles\%s\%s' % (company_name, product_name),
    'target_name' : 'TestTKapp Installer',
    'directories' : directory_table, 
    "summary_data": {"author": "Me",
    "comments": "Test TKapp",}
    }
setup(name='Test Dist App',
      version = ' 1.0.0',
      executables = [Executable(r"C:\PATH\TO\MY\APP\TestTKAPP.py", base = "Win32GUI")],
      options={'bdist_msi': bdist_msi_options,
               'build_exe': build_exe_options},
      )

CodePudding user response:

Ended up using an Inno Script to create my MSI. would still like to know how to do with with cx_freeze.

see documentation for inno scripting here. much easier and simply process for building windows installers:

https://jrsoftware.org/isdl.php

in summary(How to build a python exe);

  1. use pipreqs to create a requirements.txt for my project
  2. build virtual environment with that requirments.txt
  3. create a cx_freeze setup.py script to create MyApp.exe
  4. run cx_freeze setup.py from my virtual environment
  5. use Inno Script to create windows installer (msi) for MyApp.exe
  • Related