disthelpers

The guidata.disthelpers module provides helper functions for Python package distribution on Microsoft Windows platforms with py2exe or on all platforms thanks to cx_Freeze.

guidata.disthelpers.get_changeset(path, rev=None)[source]

Return Mercurial repository path revision number

guidata.disthelpers.prepend_module_to_path(module_path)[source]

Prepend to sys.path module located in module_path Return string with module infos: name, revision, changeset

Use this function: 1) In your application to import local frozen copies of internal libraries 2) In your py2exe distributed package to add a text file containing the returned string

guidata.disthelpers.prepend_modules_to_path(module_base_path)[source]

Prepend to sys.path all modules located in module_base_path

guidata.disthelpers.get_msvc_version(python_version)[source]

Return Microsoft Visual C++ version used to build this Python version

guidata.disthelpers.get_dll_architecture(path)[source]

Return DLL architecture (32 or 64bit) using Microsoft dumpbin.exe

guidata.disthelpers.get_msvc_dlls(msvc_version, architecture=None, check_architecture=False)[source]

Get the list of Microsoft Visual C++ DLLs associated to architecture and Python version, create the manifest file.

architecture: integer (32 or 64) – if None, take the Python build arch python_version: X.Y

guidata.disthelpers.create_msvc_data_files(architecture=None, python_version=None, verbose=False)[source]

Including Microsoft Visual C++ DLLs

guidata.disthelpers.to_include_files(data_files)[source]

Convert data_files list to include_files list

data_files:
  • this is the py2exe data files format

  • list of tuples (dest_dirname, (src_fname1, src_fname2, …))

include_files:
  • this is the cx_Freeze data files format

  • list of tuples ((src_fname1, dst_fname1),

    (src_fname2, dst_fname2), …))

guidata.disthelpers.strip_version(version)[source]

Return version number with digits only (Windows does not support strings in version numbers)

guidata.disthelpers.remove_dir(dirname)[source]

Remove directory dirname and all its contents Print details about the operation (progress, success/failure)

class guidata.disthelpers.Distribution[source]

Distribution object

Help creating an executable using py2exe or cx_Freeze

property target_dir

Return target directory (default: ‘dist’)

setup(name, version, description, script, target_name=None, target_dir=None, icon=None, data_files=None, includes=None, excludes=None, bin_includes=None, bin_excludes=None, bin_path_includes=None, bin_path_excludes=None, msvc=None)[source]

Setup distribution object

Notes:
  • bin_path_excludes is specific to cx_Freeze (ignored if it’s None)

  • if msvc is None, it’s set to True by default on Windows platforms, False on non-Windows platforms

add_text_data_file(filename, contents)[source]

Create temporary data file filename with contents and add it to data_files

add_pyqt()[source]

Include module PyQt5 to the distribution

add_pyside()[source]

Include module PySide to the distribution

add_qt_bindings()[source]

Include Qt bindings, i.e. PyQt or PySide

add_matplotlib()[source]

Include module Matplotlib to the distribution

add_modules(*module_names)[source]

Include module module_name

add_module_data_dir(module_name, data_dir_name, extensions, copy_to_root=True, verbose=False, exclude_dirs=[])[source]

Collect data files in data_dir_name for module module_name and add them to data_files extensions: list of file extensions, e.g. (‘.png’, ‘.svg’)

add_module_dir(module_name, verbose=False, exclude_dirs=[])[source]

Collect all module files for module module_name and add them to data_files

add_module_data_files(module_name, data_dir_names, extensions, copy_to_root=True, verbose=False, exclude_dirs=[])[source]

Collect data files for module module_name and add them to data_files data_dir_names: list of dirnames, e.g. (‘images’, ) extensions: list of file extensions, e.g. (‘.png’, ‘.svg’)

build(library, cleanup=True, create_archive=None)[source]

Build executable with given library.

library:
  • ‘py2exe’: deploy using the py2exe library

  • ‘cx_Freeze’: deploy using the cx_Freeze library

cleanup: remove ‘build/dist’ directories before building distribution

create_archive (requires the executable zip):
  • None or False: do nothing

  • ‘add’: add target directory to a ZIP archive

  • ‘move’: move target directory to a ZIP archive

build_py2exe(cleanup=True, compressed=2, optimize=2, company_name=None, copyright=None, create_archive=None)[source]

Build executable with py2exe

cleanup: remove ‘build/dist’ directories before building distribution

create_archive (requires the executable zip):
  • None or False: do nothing

  • ‘add’: add target directory to a ZIP archive

  • ‘move’: move target directory to a ZIP archive

add_executable(script, target_name, icon=None)[source]

Add executable to the cx_Freeze distribution Not supported for py2exe

build_cx_freeze(cleanup=True, create_archive=None)[source]

Build executable with cx_Freeze

cleanup: remove ‘build/dist’ directories before building distribution

create_archive (requires the executable zip):
  • None or False: do nothing

  • ‘add’: add target directory to a ZIP archive

  • ‘move’: move target directory to a ZIP archive