Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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"
elif sys.platform == 'win32':
import py2exe
buildstyle = 'console'
packager = 'py2exe'
unused_extensions.remove('.dll')
data_files += [(r'', [r'MSVCP71.dll'])]
## Necessary to find MSVCP71.dll
origIsSystemDLL = py2exe.build_exe.isSystemDLL
def isSystemDLL(pathname):
if os.path.basename(pathname).lower() in ("msvcp71.dll", "dwmapi.dll"):
return 0
return origIsSystemDLL(pathname)
py2exe.build_exe.isSystemDLL = isSystemDLL
elif sys.platform == 'darwin':
import py2app
buildstyle = 'app'
packager = 'py2app'
options = dict(py2app = dict(argv_emulation = True))
unused_extensions.remove('.jnilib')
provides = packages
requires = [#'IMDbPY(>=3.7)',
#'Cheetah(>=1.0)',
#'pycurl',
#'IMDbPY(>=4.0)',
#'PyQt(>=4.4.0)'
]
from distutils.core import setup
import matplotlib
import py2exe, sys, os
import glob
origIsSystemDLL = py2exe.build_exe.isSystemDLL
def isSystemDLL(pathname):
if os.path.basename(pathname).lower() in ("msvcp71.dll", "msvcrt.dll"):
return 0
return origIsSystemDLL(pathname)
py2exe.build_exe.isSystemDLL = isSystemDLL
setup(console=['main.py', 'configeditor.pyw', '.\\unittests\\test_all.py'],
data_files=[(r'mpl-data\data',glob.glob(r'C:\Python25\Lib\site-packages\mpl_toolkits\basemap\data\*.*'))] + \
matplotlib.get_py2exe_datafiles() + \
[(r'test_data',glob.glob(r'.\unittests\test_data\*.*'))] + \
[(r'MSLP',glob.glob(r'.\MSLP\*.nc'))] + \
[(r'output',[])] + \
[(r'input',glob.glob(r'.\input\*.*'))],
options={'py2exe': { "includes" : ["matplotlib.backends",
"matplotlib.backends.backend_qt4agg",
"matplotlib.figure",
"pylab",
"numpy",
"matplotlib.numerix.fft",
"matplotlib.numerix.linear_algebra",
"matplotlib.numerix.random_array",
from distutils.core import setup
import matplotlib
import py2exe, sys, os
import glob
origIsSystemDLL = py2exe.build_exe.isSystemDLL
def isSystemDLL(pathname):
if os.path.basename(pathname).lower() in ("msvcp71.dll", "msvcrt.dll"):
return 0
return origIsSystemDLL(pathname)
py2exe.build_exe.isSystemDLL = isSystemDLL
setup(console=['main.py', 'configeditor.pyw', '.\\unittests\\test_all.py'],
data_files=[(r'mpl-data\data',glob.glob(r'C:\Python25\Lib\site-packages\mpl_toolkits\basemap\data\*.*'))] + \
matplotlib.get_py2exe_datafiles() + \
[(r'test_data',glob.glob(r'.\unittests\test_data\*.*'))] + \
[(r'MSLP',glob.glob(r'.\MSLP\*.nc'))] + \
[(r'output',[])] + \
[(r'input',glob.glob(r'.\input\*.*'))],
options={'py2exe': { "includes" : ["matplotlib.backends",
"matplotlib.backends.backend_qt4agg",
"matplotlib.figure",
havePy2App = False
try:
import py2app
havePy2App = True
except ImportError:
pass
import glob
import shutil
import os
import stat
# hack to persuade py2exe to include PyGame libraries
if havePy2Exe:
origIsSystemDLL = py2exe.build_exe.isSystemDLL
def isSystemDLL(pathname):
if "pygame" in pathname.lower():
return 0
return origIsSystemDLL(pathname)
py2exe.build_exe.isSystemDLL = isSystemDLL
# copy server library
if not os.path.exists("libsrvr"):
shutil.copytree("../server/lib", "libsrvr")
else:
sys.path.append("libsrvr")
# collect data files
data_files = []
data_files.append(
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
sys.path.insert(0, BASE_DIR)
from setup import VERSION, APPNAME, scripts, basenames
sys.path.remove(BASE_DIR)
ICONS = [os.path.abspath(os.path.join(BASE_DIR, 'icons', i)) for i in ('library.ico', 'viewer.ico')]
for icon in ICONS:
if not os.access(icon, os.R_OK):
raise Exception('No icon at '+icon)
VERSION = re.sub('[a-z]\d+', '', VERSION)
WINVER = VERSION+'.0'
PY2EXE_DIR = os.path.join(BASE_DIR, 'build','py2exe')
class BuildEXE(py2exe.build_exe.py2exe):
def run(self):
py2exe.build_exe.py2exe.run(self)
print 'Adding plugins...'
tgt = os.path.join(self.dist_dir, 'plugins')
if not os.path.exists(tgt):
os.mkdir(tgt)
for f in glob.glob(os.path.join(BASE_DIR, 'src', 'calibre', 'plugins', '*.dll')):
shutil.copyfile(f, os.path.join(self.dist_dir, os.path.basename(f)))
for f in glob.glob(os.path.join(BASE_DIR, 'src', 'calibre', 'plugins', '*.pyd')):
shutil.copyfile(f, os.path.join(tgt, os.path.basename(f)))
for f in glob.glob(os.path.join(BASE_DIR, 'src', 'calibre', 'plugins', '*.manifest')):
shutil.copyfile(f, os.path.join(tgt, os.path.basename(f)))
shutil.copyfile('LICENSE', os.path.join(self.dist_dir, 'LICENSE'))
print
print 'Adding QtXml4.dll'