示例#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)
示例#2
0
      url=URL,
      download_url=DOWNLOAD_URL,
      long_description=LONG_DESCRIPTION,
      classifiers=CLASSIFIERS,
      packages=build.get_source_structure(excludes=EXCLUDES),
      package_dir=build.get_package_dirs(excludes=EXCLUDES),
      package_data=package_data,
      data_files=data_files,
      scripts=scripts,
      ext_modules=modules)

############################################################
# .py source compiling
############################################################
if not UPDATE_MODULES:
    build.compile_sources()

############################################################
# This section for developing purpose only
# Command 'python setup.py build_update' allows
# automating build and copying of native extensions
# into package directory
############################################################
if UPDATE_MODULES:
    build.copy_modules(modules)

############################################################
# Implementation of bdist_deb command
############################################################
if DEB_PACKAGE:
    utils.deb.DebBuilder(
示例#3
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)
示例#4
0
def build_macos_dmg():
    distro_folder = os.path.join(RELEASE_DIR, 'macOS')
    arch = 'macOS_10.9_Mavericks'
    echo_msg('=== Build for %s ===' % arch)
    pkg_name = '%s-%s-%s_and_newer' % (APP_NAME, APP_VER, arch)
    if not RELEASE:
        pkg_name = '%s-%s-%s-%s_and_newer' % \
                   (APP_NAME, APP_VER, TIMESTAMP, arch)
    pkg_folder = os.path.join(PROJECT_DIR, 'package')
    app_folder = os.path.join(pkg_folder, 'opt/uniconvertor')
    py_pkgs = os.path.join(pkg_folder, 'opt/uniconvertor/pkgs')
    if os.path.exists(pkg_folder):
        shutil.rmtree(pkg_folder, True)
    os.mkdir(pkg_folder)

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

    # Package building
    echo_msg('Creating macOS package')

    pkg_common_dir = os.path.join(CACHE_DIR, 'common')
    pkg_cache_dir = os.path.join(CACHE_DIR, 'macos')
    pkg_cache = os.path.join(pkg_cache_dir, 'cache.zip')

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

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

    build.compile_sources(py_pkgs)
    clear_files(py_pkgs, ['py', 'pyo'])
    clear_files('%s/uc2' % py_pkgs, ['so'])

    for item in EXTENSIONS:
        item = item.replace('.pyd', '.so')
        filename = os.path.basename(item)
        src = os.path.join(CACHE_DIR, 'macos', 'so', filename)
        dst = os.path.join(py_pkgs, item)
        shutil.copy(src, dst)

    # Launcher
    src = os.path.join(CACHE_DIR, 'macos', 'uniconvertor')
    dst = os.path.join('%s/bin' % app_folder, 'uniconvertor')
    shutil.copy(src, dst)
    # Readme file
    readme = README_TEMPLATE % bbox.TIMESTAMP[:4]
    readme_path = os.path.join(app_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('\n\n')
        fp.write(readme)
    # Uninstall.txt
    uninstall = os.path.join(app_folder, 'UNINSTALL.txt')
    with open(uninstall, 'wb') as fp:
        fp.write(MAC_UNINSTALL)
    # License file
    src = os.path.join(CACHE_DIR, 'common', 'agpl-3.0.rtf')
    dst = os.path.join(app_folder, 'agpl-3.0.rtf')
    shutil.copy(src, dst)

    # PKG and DMG build
    echo_msg('Creating DMG image')

    pkg.PkgBuilder({
        'src_dir': pkg_folder,  # path to distribution folder
        'build_dir': './build_dir',  # path for build
        'install_dir': '/',  # where to install app
        'identifier':
        'org.sK1Project.UniConvertor',  # domain.Publisher.AppName
        'app_name': '%s %s' % (APP_FULL_NAME, APP_VER),  # pretty app name
        'app_ver': APP_VER,  # app version
        'pkg_name': '%s_%s.pkg' % (APP_FULL_NAME, APP_VER),  # package name
        'preinstall': os.path.join(pkg_cache_dir, 'preinstall'),
        'postinstall': os.path.join(pkg_cache_dir, 'postinstall'),
        'license': os.path.join(pkg_common_dir, 'agpl-3.0.rtf'),
        'welcome': os.path.join(pkg_cache_dir, 'welcome.rtf'),
        'background': os.path.join(pkg_cache_dir, 'background.png'),
        'check_version': '10.9',
        'dmg': {
            'targets':
            ['./build_dir/%s_%s.pkg' % (APP_FULL_NAME, APP_VER), uninstall],
            'dmg_filename':
            '%s.dmg' % pkg_name,
            'volume_name':
            '%s %s' % (APP_FULL_NAME, APP_VER),
            'dist_dir':
            distro_folder,
        },
        'remove_build': True,
    })
    shutil.rmtree(pkg_folder, True)
示例#5
0
def build_msw_packages():
    echo_msg('Creating portable package')
    distro_folder = os.path.join(RELEASE_DIR, 'MS_Windows')
    out = ' 1> /dev/null  2> /dev/null' if not DEBUG_MODE else ''

    clear_folders()
    if os.path.isdir(DIST_DIR):
        shutil.rmtree(DIST_DIR, True)

    command('cd %s;python2 %s build %s' % (PROJECT_DIR, SCRIPT, out))
    libdir = os.path.join(BUILD_DIR, 'lib.linux-x86_64-2.7')
    build.compile_sources(libdir)
    clear_files(libdir)
    clear_files(libdir, 'so')

    for arch in ['win32', 'win64']:
        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)
        if os.path.exists(portable_folder):
            shutil.rmtree(portable_folder, True)
        os.mkdir(portable_folder)
        portable = os.path.join('/%s-devres' % arch, 'portable.zip')

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

        build.compile_sources(portable_folder)
        clear_files(portable_folder)

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

        for item in EXTENSIONS:
            filename = os.path.basename(item)
            src = os.path.join('/%s-devres' % arch, 'pyd', filename)
            dst = os.path.join(portable_libs, item)
            shutil.copy(src, dst)

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

        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()
        shutil.rmtree(portable_folder, True)

    # Build clearing #####

    shutil.rmtree(BUILD_DIR, True)

    for item in ['MANIFEST', 'MANIFEST.in', 'src/script/sk1',
                 'src/script/uniconvertor', 'setup.cfg']:
        item = os.path.join(PROJECT_DIR, item)
        if os.path.lexists(item):
            os.remove(item)
示例#6
0
    print('Extract stdlib')
    portable = os.path.join(projdir, 'resources', 'stdlib-py27-%s.zip' % arch)
    ZipFile(portable, 'r').extractall(builddir)

    for folder in ['stdlib/test/', 'stdlib/lib2to3/tests/']:
        shutil.rmtree(os.path.join(builddir, folder), True)

    print('Copy sources')
    dest = os.path.join(builddir, 'wixpy')
    shutil.copytree(wixpy_path, dest)
    exe_src = os.path.join(projdir, 'scripts', arch, 'wix.py.exe')
    shutil.copy(exe_src, builddir)

    print('Compile sources')
    build.compile_sources(builddir)
    clear_files(builddir, ['py', 'pyo'])

    print('Build MSI')
    win64 = arch == 'win64'
    MSI_DATA = {
        # 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,