Example #1
0
def build_msw_packages():
    import wixpy
    distro_folder = os.path.join(RELEASE_DIR, 'MS_Windows')

    for arch in ['win32', 'win64']:
        echo_msg('=== Arch %s ===' % arch)
        portable_name = '%s-%s-%s-portable' % (APP_NAME, APP_VER, arch)
        if not RELEASE:
            portable_name = '%s-%s-%s-%s-portable' % \
                            (APP_NAME, APP_VER, TIMESTAMP, arch)
        portable_folder = os.path.join(PROJECT_DIR, portable_name)
        portable_libs = os.path.join(portable_folder, 'libs')
        if os.path.exists(portable_folder):
            shutil.rmtree(portable_folder, True)
        os.mkdir(portable_folder)

        if not is_path(distro_folder):
            os.makedirs(distro_folder)

        # Package building
        echo_msg('Creating portable package')

        portable = os.path.join(CACHE_DIR, arch, 'portable.zip')

        echo_msg('Extracting portable files from %s' % portable)
        ZipFile(portable, 'r').extractall(portable_folder)

        obsolete_folders = [
            'stdlib/test/', 'stdlib/lib2to3/tests/', 'stdlib/unittest/',
            'stdlib/msilib/', 'stdlib/idlelib/', 'stdlib/ensurepip/',
            'stdlib/distutils/'
        ]
        for folder in obsolete_folders:
            shutil.rmtree(os.path.join(portable_folder, folder), True)

        wx_zip = os.path.join(CACHE_DIR, arch, 'wx.zip')
        ZipFile(wx_zip, 'r').extractall(portable_libs)
        portable_exe_zip = os.path.join(CACHE_DIR, arch,
                                        '%s_portable.zip' % PROJECT)
        ZipFile(portable_exe_zip, 'r').extractall(portable_folder)

        for item in PKGS:
            src = os.path.join(SRC_DIR, item)
            echo_msg('Copying tree %s' % src)
            shutil.copytree(src, os.path.join(portable_libs, item))

        build.compile_sources(portable_folder)
        clear_files(portable_folder, ['py', 'so', 'pyo'])

        for item in EXTENSIONS:
            filename = os.path.basename(item)
            src = os.path.join(CACHE_DIR, arch, 'pyd', filename)
            dst = os.path.join(portable_libs, item)
            shutil.copy(src, dst)

        # Portable package compressing
        portable_zip = os.path.join(distro_folder, portable_name + '.zip')
        ziph = ZipFile(portable_zip, 'w', ZIP_DEFLATED)

        echo_msg('Compressing into %s' % portable_zip)
        for root, dirs, files in os.walk(portable_folder):
            for item in files:
                path = os.path.join(root, item)
                local_path = path.split(portable_name)[1][1:]
                ziph.write(path, os.path.join(portable_name, local_path))
        ziph.close()

        # MSI build
        echo_msg('Creating MSI package')

        clear_files(portable_folder, ['exe'])

        nonportable = os.path.join(CACHE_DIR, arch, '%s_msi.zip' % PROJECT)

        echo_msg('Extracting non-portable executables from %s' % nonportable)
        ZipFile(nonportable, 'r').extractall(portable_folder)

        msi_name = portable_name.replace('-portable', '')
        msi_data = {}
        msi_data.update(MSI_DATA)
        msi_data['_SourceDir'] = portable_folder
        if arch == 'win64':
            msi_data['Win64'] = 'yes'
            msi_data['_CheckX64'] = True
        msi_data['_OutputDir'] = distro_folder
        msi_data['_OutputName'] = msi_name + '_headless.msi'
        wixpy.build(msi_data)

        # Clearing
        shutil.rmtree(portable_folder, True)

    # Build clearing #####

    shutil.rmtree(BUILD_DIR, True)

    for item in ['MANIFEST', 'src/script/sk1', 'setup.cfg']:
        item = os.path.join(PROJECT_DIR, item)
        if os.path.lexists(item):
            os.remove(item)
Example #2
0
def build_msw_packages():
    import wixpy
    distro_folder = os.path.join(RELEASE_DIR, 'MS_Windows')

    for arch in ['win32', 'win64']:
        echo_msg('=== Arch %s ===' % arch)
        portable_name = '%s-%s-%s-portable' % (APP_NAME, APP_VER, arch)
        if not RELEASE:
            portable_name = '%s-%s-%s-%s-portable' % \
                            (APP_NAME, APP_VER, TIMESTAMP, arch)
        portable_folder = os.path.join(PROJECT_DIR, portable_name)
        portable_libs = os.path.join(portable_folder, 'libs')
        if os.path.exists(portable_folder):
            shutil.rmtree(portable_folder, True)
        os.mkdir(portable_folder)

        if not is_path(distro_folder):
            os.makedirs(distro_folder)

        # Package building
        echo_msg('Creating portable package')

        portable = os.path.join(CACHE_DIR, arch, 'portable.zip')

        echo_msg('Extracting portable files from %s' % portable)
        ZipFile(portable, 'r').extractall(portable_folder)

        obsolete_folders = [
            'stdlib/test/', 'stdlib/lib2to3/tests/', 'stdlib/unittest/',
            'stdlib/msilib/', 'stdlib/idlelib/', 'stdlib/ensurepip/',
            'stdlib/distutils/'
        ]
        for folder in obsolete_folders:
            shutil.rmtree(os.path.join(portable_folder, folder), True)

        for item in PKGS:
            src = os.path.join(SRC_DIR, item)
            echo_msg('Copying tree %s' % src)
            shutil.copytree(src, os.path.join(portable_libs, item))

        build.compile_sources(portable_folder)
        clear_files(portable_folder, ['py', 'so', 'pyo'])

        for item in EXTENSIONS:
            filename = os.path.basename(item)
            src = os.path.join(CACHE_DIR, arch, 'pyd', filename)
            dst = os.path.join(portable_libs, item)
            shutil.copy(src, dst)

        # MSI build
        echo_msg('Creating MSI package')

        clear_files(portable_folder, ['exe'])

        # Readme file
        readme = README_TEMPLATE % bbox.TIMESTAMP[:4]
        readme_path = os.path.join(portable_folder, 'readme.txt')
        with open(readme_path, 'wb') as fp:
            mark = '' if RELEASE else ' build %s' % bbox.TIMESTAMP
            fp.write('%s %s%s' % (APP_FULL_NAME, APP_VER, mark))
            fp.write('\r\n\r\n')
            fp.write(readme.replace('\n', '\r\n'))
        # License file
        src = os.path.join(CACHE_DIR, 'common', 'agpl-3.0.rtf')
        dst = os.path.join(portable_folder, 'agpl-3.0.rtf')
        shutil.copy(src, dst)

        # Exe files
        nonportable = os.path.join(CACHE_DIR, arch, '%s.zip' % PROJECT)
        echo_msg('Extracting non-portable executables from %s' % nonportable)
        ZipFile(nonportable, 'r').extractall(portable_folder)

        msi_name = portable_name.replace('-portable', '')
        msi_data = {}
        msi_data.update(MSI_DATA)
        msi_data['_SourceDir'] = portable_folder
        if arch == 'win64':
            msi_data['Win64'] = 'yes'
            msi_data['_CheckX64'] = True
        msi_data['_OutputDir'] = distro_folder
        msi_data['_OutputName'] = msi_name + '_headless.msi'
        wixpy.build(msi_data)

        # Clearing
        shutil.rmtree(portable_folder, True)

    # Build clearing #####

    shutil.rmtree(BUILD_DIR, True)

    for item in ['MANIFEST', 'src/script/uniconvertor', 'setup.cfg']:
        item = os.path.join(PROJECT_DIR, item)
        if os.path.lexists(item):
            os.remove(item)
Example #3
0
File: wix.py Project: x24git/wixpy
    else:
        key = item[2:]
        args[key] = True

if not non_options:
    print('Input JSON file is not provided!')
    sys.exit(1)

json_file = non_options[1]
if not os.path.exists(json_file):
    print('Specified JSON file "%s" is not found!' % json_file)
    sys.exit(1)

json_data = {}
try:
    with open(json_file, 'rb') as fp:
        json_encoding = args.get('json_encoding', 'utf-8')
        json_data = json.load(fp, encoding=json_encoding)
    if not json_data:
        raise Exception('Empty JSON data!')
    json_data = wixpy.utils.encode_json(json_data)
except Exception as e:
    print('Error reading JSON file! %s' % str(e))
    sys.exit(1)

wixpy.build(json_data,
            output=args.get('output'),
            stdout=args.get('stdout', False),
            xml_only=args.get('xml_only', False),
            xml_encoding=args.get('xml_encoding', 'utf-8'))
Example #4
0
        # Required
        'Name': wixpy.PROJECT,
        'UpgradeCode': wixpy.UPGRADE_CODE,
        'Version': wixpy.VERSION,
        'Manufacturer': wixpy.MANUFACTURER,
        # Optional
        'Description': '%s %s Installer' % (wixpy.PROJECT, wixpy.VERSION),
        'Comments': 'Licensed under %s' % wixpy.LICENSE,
        'Keywords': ', '.join(wixpy.KEYWORDS),
        'Win64': win64,
        'Codepage': '1252',
        'SummaryCodepage': '1252',
        'Language': '1033',
        'Languages': '1033',

        # Installation features
        '_OsCondition': '601',
        '_CheckX64': win64,
        '_AppIcon': app_icon,
        '_AddToPath': [
            '',
        ],
        '_SourceDir': builddir,
        '_InstallDir': '%s-%s' % (wixpy.PROJECT, wixpy.VERSION),
        '_OutputName': '%s-%s-%s.msi' % (wixpy.PROJECT, wixpy.VERSION, arch),
        '_OutputDir': distro_folder,
        '_SkipHidden': True,
    }
    wixpy.build(MSI_DATA)
    shutil.rmtree(builddir, True)