Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
except LookupError:
pass
# path from Python import system
try:
names = name.split('.')
for i in range(len(names)):
modname = '.'.join(names[:i + 1])
__import__(modname)
return getattr(sys.modules[name], '__path__', [])[1:]
except ImportError:
pass
return default
def __setitem__(self, name, value):
packagePathMap[name] = value
modulefinder.packagePathMap = PackagePathMap()
# fix a problem that `py2exe` includes MinWin's ApiSet Stub DLLs on Windows 7.
# http://www.avertlabs.com/research/blog/index.php/2010/01/05/windows-7-kernel-api-refactoring/
if sys.getwindowsversion()[:2] >= (6, 1):
build_exe._isSystemDLL = build_exe.isSystemDLL
def isSystemDLL(pathname):
if build_exe._isSystemDLL(pathname):
return True
try:
language = win32api.GetFileVersionInfo(pathname,
'\\VarFileInfo\\Translation')
company = win32api.GetFileVersionInfo(pathname,
'\\StringFileInfo\\%.4x%.4x\\CompanyName' % language[0])
def copy_extensions(self, extensions):
#Get pygame default font
pygamedir = os.path.split(pygame.base.__file__)[0]
pygame_default_font = os.path.join(pygamedir, pygame.font.get_default_font())
#Add font to list of extension to be copied
extensions.append(Module("pygame.font", pygame_default_font))
py2exe.build_exe.py2exe.copy_extensions(self, extensions)
def copyQtPlugins(paths):
import shutil
from PySide2 import QtCore
basePath = QtCore.QLibraryInfo.location(QtCore.QLibraryInfo.PluginsPath)
basePath = basePath.replace('/', '\\')
destBase = os.getcwd() + '\\' + OUT_DIR
for elem in paths:
elemDir, elemName = os.path.split(elem)
source = basePath + '\\' + elem
dest = destBase + '\\' + elem
destDir = destBase + '\\' + elemDir
os.makedirs(destDir, exist_ok=True)
shutil.copy(source, dest)
class build_installer(py2exe):
def run(self):
py2exe.run(self)
print('*** deleting unnecessary libraries and modules ***')
pruneUnneededLibraries()
print('*** copying qt plugins ***')
copyQtPlugins(qt_plugins)
script = NSISScript()
script.create()
print("*** compiling the NSIS setup script ***")
script.compile()
print("*** DONE ***")
guiIcons = glob('syncplay/resources/*.ico') + glob('syncplay/resources/*.png') + ['syncplay/resources/spinner.mng']
resources = [
"syncplay/resources/syncplayintf.lua",
Build the library and .exe files with py2exe.
"""
buildSetup = self.buildSetup
sys.path.append(EncodePath(buildSetup.pyVersionDir))
from distutils.core import setup
InstallPy2exePatch()
import py2exe
origIsSystemDLL = py2exe.build_exe.isSystemDLL
def isSystemDLL(path):
if basename(path).lower().startswith("api-ms-win-"):
return 1
else:
return origIsSystemDLL(path)
py2exe.build_exe.isSystemDLL = isSystemDLL
libraryDir = buildSetup.libraryDir
if exists(libraryDir):
for filename in os.listdir(libraryDir):
path = join(libraryDir, filename)
if not os.path.isdir(path):
os.remove(path)
wip_version = None
if buildSetup.appVersion.startswith("WIP-"):
# this is to avoid a py2exe warning when building a WIP version
wip_version = buildSetup.appVersion
buildSetup.appVersion = ".".join(
buildSetup.appVersion.split("-")[1].split(".")
)
import glob, fnmatch
import sys, os, shutil
import operator
except ImportError as message:
raise (SystemExit, "Unable to load module. %s" % message)
#hack which fixes the pygame mixer and pygame font
orig_is_system_dll = py2exe.build_exe.isSystemDLL # save the orginal before we edit it
def isSystemDLL(_pathname):
# checks if the freetype and ogg dll files are being included
if os.path.basename(_pathname).lower() in ("libfreetype-6.dll", "libogg-0.dll","sdl_ttf.dll"): # "sdl_ttf.dll" added by arit.
return 0
return orig_is_system_dll(_pathname) # return the orginal function
py2exe.build_exe.isSystemDLL = isSystemDLL # override the default function with this one
class pygame2exe(py2exe.build_exe.py2exe): #This hack make sure that pygame default font is copied: no need to modify code for specifying default font
def copy_extensions(self, _extensions):
#Get pygame default font
pygame_dir = os.path.split(pygame.base.__file__)[0]
pygame_default_font = os.path.join(pygame_dir, pygame.font.get_default_font())
#Add font to list of extension to be copied
_extensions.append(Module("pygame.font", pygame_default_font))
py2exe.build_exe.py2exe.copy_extensions(self, _extensions)
class BuildExe:
def __init__(self):
#Name of starting .py
self.script = "main.py"
#Name of program
self.project_name = "Project TUSSLE"
import py2exe, pygame
from modulefinder import Module
import glob, fnmatch
import sys, os, shutil
import operator
except ImportError, message:
raise SystemExit, "Unable to load module. %s" % message
#hack which fixes the pygame mixer and pygame font
origIsSystemDLL = py2exe.build_exe.isSystemDLL # save the orginal before we edit it
def isSystemDLL(pathname):
# checks if the freetype and ogg dll files are being included
if os.path.basename(pathname).lower() in ("libfreetype-6.dll", "libogg-0.dll","sdl_ttf.dll"): # "sdl_ttf.dll" added by arit.
return 0
return origIsSystemDLL(pathname) # return the orginal function
py2exe.build_exe.isSystemDLL = isSystemDLL # override the default function with this one
class pygame2exe(py2exe.build_exe.py2exe): #This hack make sure that pygame default font is copied: no need to modify code for specifying default font
def copy_extensions(self, extensions):
#Get pygame default font
pygamedir = os.path.split(pygame.base.__file__)[0]
pygame_default_font = os.path.join(pygamedir, pygame.font.get_default_font())
#Add font to list of extension to be copied
extensions.append(Module("pygame.font", pygame_default_font))
py2exe.build_exe.py2exe.copy_extensions(self, extensions)
class BuildExe:
def __init__(self):
#Name of starting .py
self.script = "../asteroides.py"
import py2exe, pygame
from modulefinder import Module
import glob, fnmatch
import sys, os, shutil
import operator
except ImportError as message:
raise (SystemExit, "Unable to load module. %s" % message)
#hack which fixes the pygame mixer and pygame font
orig_is_system_dll = py2exe.build_exe.isSystemDLL # save the orginal before we edit it
def isSystemDLL(_pathname):
# checks if the freetype and ogg dll files are being included
if os.path.basename(_pathname).lower() in ("libfreetype-6.dll", "libogg-0.dll","sdl_ttf.dll"): # "sdl_ttf.dll" added by arit.
return 0
return orig_is_system_dll(_pathname) # return the orginal function
py2exe.build_exe.isSystemDLL = isSystemDLL # override the default function with this one
class pygame2exe(py2exe.build_exe.py2exe): #This hack make sure that pygame default font is copied: no need to modify code for specifying default font
def copy_extensions(self, _extensions):
#Get pygame default font
pygame_dir = os.path.split(pygame.base.__file__)[0]
pygame_default_font = os.path.join(pygame_dir, pygame.font.get_default_font())
#Add font to list of extension to be copied
_extensions.append(Module("pygame.font", pygame_default_font))
py2exe.build_exe.py2exe.copy_extensions(self, _extensions)
class BuildExe:
def __init__(self):
#Name of starting .py
self.script = "main.py"
# the user delete it first if it does. (This is safer
# than calling rm_rf() on it, in case the user has
# specified '/' or some equally foolish directory as the
# dist directory.)
if os.path.exists(self.dist_dir):
print "Error, the directory %s already exists." % (self.dist_dir)
print "Please remove it before starting this script."
sys.exit(1)
# Override py2exe's isSystemDLL because it erroneously
# flags sdl_ttf.dll and libogg-0.dll as system DLLs
self.origIsSystemDLL = py2exe.build_exe.isSystemDLL
py2exe.build_exe.isSystemDLL = self.isSystemDLL
# Build the .exe files, etc.
py2exe.build_exe.py2exe.run(self)
# Now run NSIS to build the installer.
cmd = '"%(makensis)s" /DVERSION=%(version)s install\\windows_installer.nsi' % {
'makensis' : self.makensis,
'version' : pykversion.PYKARAOKE_VERSION_STRING,
}
print cmd
os.system(cmd)
# Now that we've got an installer, we can empty the dist
# dir again.
self.rm_rf(self.dist_dir)
def copy_extensions(self, _extensions):
#Get pygame default font
pygame_dir = os.path.split(pygame.base.__file__)[0]
pygame_default_font = os.path.join(pygame_dir, pygame.font.get_default_font())
#Add font to list of extension to be copied
_extensions.append(Module("pygame.font", pygame_default_font))
py2exe.build_exe.py2exe.copy_extensions(self, _extensions)
{"DOLLAR": "$",
"STYLE": cfg.style,
"TAG_PREFIX": cfg.tag_prefix,
"PARENTDIR_PREFIX": cfg.parentdir_prefix,
"VERSIONFILE_SOURCE": cfg.versionfile_source,
})
cmds["build_exe"] = cmd_build_exe
del cmds["build_py"]
if 'py2exe' in sys.modules: # py2exe enabled?
try:
from py2exe.distutils_buildexe import py2exe as _py2exe # py3
except ImportError:
from py2exe.build_exe import py2exe as _py2exe # py2
class cmd_py2exe(_py2exe):
def run(self):
root = get_root()
cfg = get_config_from_root(root)
versions = get_versions()
target_versionfile = cfg.versionfile_source
print("UPDATING %s" % target_versionfile)
write_to_version_file(target_versionfile, versions)
_py2exe.run(self)
os.unlink(target_versionfile)
with open(cfg.versionfile_source, "w") as f:
LONG = LONG_VERSION_PY[cfg.VCS]
f.write(LONG %
{"DOLLAR": "$",
"STYLE": cfg.style,
"TAG_PREFIX": cfg.tag_prefix,