def test_esky_bundle_mscrvt(): setup, options, new_script = esky_setup('Simple Working', WORKING_SCRIPT) # setup(**options) new_script2 = make_new_script_name('testing_patching.py') insert_code(new_script2, 'import sys', 'import os', 'versiondir = os.path.dirname(sys.executable)', 'for nm in os.listdir(versiondir):', ' if nm.startswith("Microsoft.") and nm.endswith(".CRT"):', ' msvcrt_dir = os.path.join(versiondir,nm)', ' assert os.path.isdir(msvcrt_dir)', ' assert len(os.listdir(msvcrt_dir)) >= 2', ' break', 'else:', ' assert False, "MSVCRT not bundled in version dir "+versiondir') options2 = copy.deepcopy(options) options2['options']['bdist_esky']['bundle_msvcrt'] = True options2['scripts'] = [new_script2] # options2['script_args'] = ['bdist_esky_patch'] options2['version'] = '2.0' setup(**options2) # esky_zip_name = 'Simple Working-0.2.win32.zip' esky_zip_name = get_zip_name(options2) clean_exit, stderr = run_script(new_script2, freezer='esky', zip_name=esky_zip_name) assert clean_exit
def test_multiple_runs_of_setup_function(): '''make sure our fixes support multiple runs ''' from esky.bdist_esky import Executable setup, options, new_script = esky_setup('Simple Working', WORKING_SCRIPT) new_script2 = make_new_script_name('test_multiple_working.py') insert_code(new_script2,'import sys') options2 = copy.deepcopy(options) options2['scripts'] = [new_script2] options2['version'] = '0.2' esky_zip_name = get_zip_name(options2) # Now test that freeze future works as well cleanup_dirs() setup(**options) clean_exit, stderr = run_script(new_script, freezer='esky') assert clean_exit # only works if we cleanup dirs.. same as original esky cleanup_dirs() setup(**options2) if os.name == 'nt': platform = get_platform() esky_zip_name = 'Simple Working-0.2.%s.zip' % platform clean_exit, stderr = run_script(new_script2, freezer='esky', zip_name=esky_zip_name) assert clean_exit
def setuptools_setup(name, script, **changes): new_script = make_new_script_name(script) changes['scripts'] = [new_script] base_options = copy.deepcopy(V.DEFAULT_OPTIONS) changes.update({'name':name}) base_options.update(changes) return setup, base_options, new_script
def distutils_setup(name, script, **changes): from distutils.core import setup new_script = make_new_script_name(script) changes['scripts'] = [new_script] base_options = copy.deepcopy(V.DEFAULT_OPTIONS) changes.update({'name': name}) base_options.update(changes) return setup, base_options, new_script
def py2exe_setup(name, script, **changes): import py2exe from distutils.core import setup new_script = make_new_script_name(script) base_options = copy.deepcopy(V.DEFAULT_OPTIONS) changes['windows'] = [new_script] base_options.update(changes) base_options['options']['py2exe'] = {} del base_options['options']['build_exe'] changes.update({'name':name}) return setup, base_options, new_script
def py2app_setup(name, script, **changes): from cx_Freeze import setup, Executable base = None if sys.platform == "win32": base = "Win32GUI" new_script = make_new_script_name(script) base_options = copy.deepcopy(V.DEFAULT_OPTIONS) changes['executables'] = [Executable(new_script, base=base, icon=V.ICON)] changes.update({'name':name}) base_options.update(changes) return setup, base_options, new_script
def cxfreeze_setup(name, script, **changes): from cx_Freeze import setup, Executable base = None if sys.platform == "win32": base = "Win32GUI" new_script = make_new_script_name(script) base_options = copy.deepcopy(V.DEFAULT_OPTIONS) changes['executables'] = [Executable(new_script, base=base, icon=V.ICON)] changes.update({'name': name}) base_options.update(changes) return setup, base_options, new_script
def test_esky_bdist_esky_patch_command(): '''this test is overkill just need to make sure patch command returns esky''' # TODO this made it clear i need to force the selection of freezer rather trying than smart detect it setup, options, new_script = esky_setup('Simple Working', WORKING_SCRIPT) setup(**options) new_script2 = make_new_script_name('testing_patching.py') insert_code(new_script2,'import sys') options2 = copy.deepcopy(options) options2['scripts'] = [new_script2] options2['script_args'] = ['bdist_esky_patch'] options2['version'] = '0.2' setup(**options2) esky_zip_name = get_zip_name(options2) clean_exit, stderr = run_script(new_script2, freezer='esky', zip_name=esky_zip_name) assert clean_exit
def esky_setup(name, script, **changes): new_script = make_new_script_name(script) base_options = {"version": "1.0"} changes.update({'name':name}) base_options.update(changes) options = {"options": {"bdist_esky": {"compress": 'ZIP', "freezer_module": FREEZER_TO_RUN_WITH_ESKY }}} base_options['scripts'] = [new_script] base_options.update({'script_args':["bdist_esky"]}) base_options.update(options) return dist_setup, base_options, new_script #FIRST TEST USING THE FREEZE_FUTURE AND THE FIXES DEVELOPED THERE, WHEN ALL PASSING CHANGE TO distutils.setup return freeze_future.setup, base_options, new_script
def test_esky_patch(): '''need to have our esky fixes developed in freeze future moved to f_py2exe or f_cxfrexe etc for patchingo work''' tdir=os.getcwd() uzdir = os.path.join(tdir,"unzip") try: really_rmtree(uzdir) except Exception: pass setup, options, new_script = esky_setup('Simple Working', WORKING_SCRIPT) setup(**options) new_script2 = make_new_script_name('testing_patching.py') insert_code(new_script2,'import sys') options2 = copy.deepcopy(options) options2['scripts'] = [new_script2] options2['script_args'] = ['bdist_esky_patch'] options2['version'] = '2.0' options2['freezer'] = '2.0' setup(**options2) platform = get_platform() deep_extract_zipfile(os.path.join(tdir,"dist","Simple Working-1.0.%s.zip"%(platform,)),uzdir) with open(os.path.join(tdir,"dist","Simple Working-2.0.%s.from-1.0.patch"%(platform,)),"rb") as f: esky.patch.apply_patch(uzdir,f) filewithext = os.path.basename(new_script2) file = os.path.splitext(filewithext)[0] path_file = os.path.join(uzdir, file) cmd = [path_file] proc = subprocess.Popen(cmd, stderr=subprocess.PIPE) errs = proc.communicate() if not proc.returncode: exit_code = True else: exit_code = False assert exit_code really_rmtree(uzdir)