Issue #23 new

Executable.initScript not executed?

Sebastian Rahlf
created an issue

I've got script which is used to push some Hudson build information (from os.environment) into my GTK application.

Using Executable's initScript parameter seemed to be the logic choice. So I used

Executable(
    'deconvolute/ui.py',
    targetName="deconvolute.exe",
    initScript=os.path.abspath('insert-version-info.py'),
    base=base,
)

but for some reason this is not executed.

What am I missing?

Comments (4)

  1. Anthony Tuininga repo owner

    Hi Sebastian,

    Yes, it would seem reasonable to use the initscript and I have done so for similar reasons in the past. I'd need to see the initscript and the way you're expecting to use it, though.

    The other option is to use the "ConstantsModule" which by default is embedded in the frozen executable as BUILD_CONSTANTS. You can override bits and pieces of this but it includes

    BUILD_RELEASE_STRING = metadata.version BUILD_COPYRIGHT = None (unless specified) BUILD_TIMESTAMP = timestamp when frozen BUILD_HOST = name of computer doing the freezing SOURCE_TIMESTAMP = highest timestamp of all source modules

    There are ways of manipulating this constants module further, of course if that proves something you want to pursue.

    In your code you would do something like this:

    try: import BUILD_CONSTANTS except ImportError: pass

    Anthony

  2. Sebastian Rahlf reporter

    My original idea was that I have some version information based on environmental variables set by our build server which would be included at build time in a module to be displayed in the application later on.

    # insert-version-info.py
    import os
    with open('app/buildinfo.py', 'wb') as fp:
        fp.write('BUILD_INFO = %r' % os.environ.get('BUILD_TAG', None))
    

    The ConstantsModule is something I will want to look at, too.

  3. George Dietz

    Hi, I just encountered this same issue too with cx_Freeze 4.3.3: If I try the initScript option in the Executables section (as Sebastian tried above) it doesn't execute. However, if i use the semi-documented init_script option in build_exe, it executes and works properly:

    options = {
        'build_exe': {
            'includes': 'atexit',
            'init_script': 'os.path.abspath(prelaunch.py)', #
    

    Is this a bug or am I gravely misunderstanding expected behavior?

  4. Thomas Kluyver

    I think that's expected-ish behaviour at the moment. For cx_Freeze 5, I have hopefully sorted out all of the options that are duplicated between Executable and build_exe, and that one should land in Executable.

  5. Log in to comment