Update dist.py
This commit is contained in:
114
scripts/dist.py
114
scripts/dist.py
@@ -43,6 +43,16 @@ class FileStub():
|
|||||||
def flush(self, *args):
|
def flush(self, *args):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
i = 0
|
||||||
|
def loginfo(path, names):
|
||||||
|
# Print out a "progress" and return directories / files to ignore
|
||||||
|
global i
|
||||||
|
i += 1
|
||||||
|
if i % 10 == 0:
|
||||||
|
sys.stdout.write(".")
|
||||||
|
sys.stdout.flush()
|
||||||
|
return ()
|
||||||
|
|
||||||
def copyanything(src, dst):
|
def copyanything(src, dst):
|
||||||
try:
|
try:
|
||||||
shutil.copytree(src, dst, ignore=loginfo)
|
shutil.copytree(src, dst, ignore=loginfo)
|
||||||
@@ -60,7 +70,7 @@ def zipdir(path, zip):
|
|||||||
for file in files:
|
for file in files:
|
||||||
zip.write(os.path.join(root, file))
|
zip.write(os.path.join(root, file))
|
||||||
|
|
||||||
skels = ['win', 'mac', 'src', 'win-wx3']
|
skels = ['win', 'mac', 'src', 'mac-wx3']
|
||||||
iscc = "C:\Program Files (x86)\Inno Setup 5\ISCC.exe" # inno script location via wine
|
iscc = "C:\Program Files (x86)\Inno Setup 5\ISCC.exe" # inno script location via wine
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
@@ -86,9 +96,6 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
options.platforms = options.platforms.split(",")
|
options.platforms = options.platforms.split(",")
|
||||||
|
|
||||||
#sys.path.append(options.base)
|
|
||||||
#import config as pyfaconfig
|
|
||||||
|
|
||||||
for skel in skels:
|
for skel in skels:
|
||||||
if skel not in options.platforms:
|
if skel not in options.platforms:
|
||||||
continue
|
continue
|
||||||
@@ -97,10 +104,12 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
info = {}
|
info = {}
|
||||||
config = {}
|
config = {}
|
||||||
|
setup = {}
|
||||||
skeleton = os.path.expanduser(os.path.join(options.skeleton, skel))
|
skeleton = os.path.expanduser(os.path.join(options.skeleton, skel))
|
||||||
|
|
||||||
execfile(os.path.join(options.base, "config.py"), config)
|
execfile(os.path.join(options.base, "config.py"), config)
|
||||||
execfile(os.path.join(skeleton, "info.py"), info)
|
execfile(os.path.join(skeleton, "info.py"), info)
|
||||||
|
execfile(os.path.join(options.base, "setup.py"), setup)
|
||||||
|
|
||||||
destination = os.path.expanduser(options.destination)
|
destination = os.path.expanduser(options.destination)
|
||||||
if not os.path.isdir(destination) or not os.access(destination, os.W_OK | os.X_OK):
|
if not os.path.isdir(destination) or not os.access(destination, os.W_OK | os.X_OK):
|
||||||
@@ -130,89 +139,66 @@ if __name__ == "__main__":
|
|||||||
)
|
)
|
||||||
|
|
||||||
archiveName = "{}.{}".format(fileName, "zip" if options.zip else "tar.bz2")
|
archiveName = "{}.{}".format(fileName, "zip" if options.zip else "tar.bz2")
|
||||||
dst = os.path.join(os.getcwd(), dirName) # tmp directory where files are copied
|
tmpDir = os.path.join(os.getcwd(), dirName) # tmp directory where files are copied
|
||||||
tmpFile = os.path.join(os.getcwd(), archiveName)
|
tmpFile = os.path.join(os.getcwd(), archiveName)
|
||||||
|
|
||||||
i = 0
|
|
||||||
ignoreData = (".git", ".gitignore", ".gitmodules", "dist_assets", "build", "dist", "scripts", ".idea", "imgs")
|
|
||||||
def loginfo(path, names):
|
|
||||||
# Print out a "progress" and return directories / files to ignore
|
|
||||||
global i
|
|
||||||
i += 1
|
|
||||||
if i % 10 == 0:
|
|
||||||
sys.stdout.write(".")
|
|
||||||
sys.stdout.flush()
|
|
||||||
return ignoreData
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
print "Copying skeleton to ", dst
|
print "Copying skeleton to ", tmpDir
|
||||||
i = 0
|
shutil.copytree(skeleton, tmpDir, ignore=loginfo)
|
||||||
shutil.copytree(skeleton, dst, ignore=loginfo)
|
|
||||||
print
|
print
|
||||||
if skel != "win":
|
source = os.path.expanduser(options.base)
|
||||||
# simply copying base into working build
|
root = os.path.join(tmpDir, info["base"])
|
||||||
base = os.path.join(dst, info["base"])
|
|
||||||
print "Copying base to ", base
|
|
||||||
|
|
||||||
i = 0
|
# it is easier to work from the source directory
|
||||||
for stuff in os.listdir(os.path.expanduser(options.base)):
|
oldcwd = os.getcwd()
|
||||||
currSource = os.path.join(os.path.expanduser(options.base), stuff)
|
os.chdir(source)
|
||||||
currDest = os.path.join(base, stuff)
|
|
||||||
if stuff in ignoreData:
|
|
||||||
continue
|
|
||||||
elif os.path.isdir(currSource):
|
|
||||||
shutil.copytree(currSource, currDest, ignore=loginfo)
|
|
||||||
else:
|
|
||||||
shutil.copy2(currSource, currDest)
|
|
||||||
|
|
||||||
print
|
if info["library"]:
|
||||||
print "Copying done, making archive: ", tmpFile
|
print "Injecting files into", info["library"]
|
||||||
else:
|
libraryFile = os.path.join(root, info["library"])
|
||||||
# this should work, but it's barely been tested
|
|
||||||
base = os.path.join(dst, info["base"])
|
|
||||||
source = os.path.expanduser(options.base)
|
|
||||||
sys.path.append(source)
|
|
||||||
import setup
|
|
||||||
|
|
||||||
print "Injecting files into library.zip"
|
|
||||||
# the following operations require us to be in the source directory
|
|
||||||
# for the zipping to work correctly
|
|
||||||
oldcwd = os.getcwd()
|
|
||||||
os.chdir(source)
|
|
||||||
|
|
||||||
libraryFile = os.path.join(base, "library.zip")
|
|
||||||
|
|
||||||
with zipfile.ZipFile(libraryFile, 'a') as library:
|
with zipfile.ZipFile(libraryFile, 'a') as library:
|
||||||
for dir in setup.packages:
|
for dir in setup['packages']:
|
||||||
zipdir(dir, library)
|
zipdir(dir, library)
|
||||||
library.write('pyfa.py', 'pyfa__main__.py')
|
library.write('pyfa.py', 'pyfa__main__.py')
|
||||||
library.write('config.py')
|
library.write('config.py')
|
||||||
|
else: # platforms where we don't have a packaged library
|
||||||
|
print "Copying modules into", root
|
||||||
|
for dir in setup['packages']:
|
||||||
|
copyanything(dir, os.path.join(root, dir))
|
||||||
|
|
||||||
print "Copying included files"
|
# add some additional files to root dir for these platforms
|
||||||
for dir in setup.include_files:
|
# (hopefully can figure out a way later for OS X to use the one in
|
||||||
copyanything(dir, os.path.join(base, dir))
|
# it's library)
|
||||||
|
if skel == 'mac-wx3':
|
||||||
|
setup['include_files'] += ['pyfa.py']
|
||||||
|
if skel == 'mac' or skel == 'src':
|
||||||
|
setup['include_files'] += ['pyfa.py', 'config.py']
|
||||||
|
|
||||||
os.chdir(oldcwd)
|
print "Copying included files:",
|
||||||
|
|
||||||
print "Creating images zipfile"
|
for file in setup['include_files']:
|
||||||
# Move imgs to zipfile
|
print file,
|
||||||
oldcwd = os.getcwd()
|
copyanything(file, os.path.join(root, file))
|
||||||
os.chdir(source)
|
|
||||||
imagesFile = os.path.join(base, "imgs.zip")
|
print "Creating images zipfile:",
|
||||||
|
os.chdir(os.path.join(source, 'imgs'))
|
||||||
|
imagesFile = os.path.join(root, "imgs.zip")
|
||||||
|
|
||||||
with zipfile.ZipFile(imagesFile, 'w') as images:
|
with zipfile.ZipFile(imagesFile, 'w') as images:
|
||||||
os.chdir('imgs') # need to be in images directory
|
for dir in setup['icon_dirs']:
|
||||||
for dir in setup.icon_dirs:
|
print dir,
|
||||||
zipdir(dir, images)
|
zipdir(dir, images)
|
||||||
os.chdir(oldcwd)
|
os.chdir(oldcwd)
|
||||||
|
|
||||||
|
print "Creating archive"
|
||||||
if options.zip:
|
if options.zip:
|
||||||
archive = zipfile.ZipFile(tmpFile, 'w', compression=zipfile.ZIP_DEFLATED)
|
archive = zipfile.ZipFile(tmpFile, 'w', compression=zipfile.ZIP_DEFLATED)
|
||||||
zipdir(dirName, archive)
|
zipdir(dirName, archive)
|
||||||
archive.close()
|
archive.close()
|
||||||
else:
|
else:
|
||||||
archive = tarfile.open(tmpFile, "w:bz2")
|
archive = tarfile.open(tmpFile, "w:bz2")
|
||||||
archive.add(dst, arcname=info["arcname"])
|
archive.add(tmpDir, arcname=info["arcname"])
|
||||||
archive.close()
|
archive.close()
|
||||||
|
|
||||||
print "Moving archive to ", destination
|
print "Moving archive to ", destination
|
||||||
@@ -236,7 +222,7 @@ if __name__ == "__main__":
|
|||||||
os.path.join(os.path.dirname(__file__), "pyfa-setup.iss"),
|
os.path.join(os.path.dirname(__file__), "pyfa-setup.iss"),
|
||||||
"/dMyAppVersion=%s"%(config['version']),
|
"/dMyAppVersion=%s"%(config['version']),
|
||||||
"/dMyAppExpansion=%s"%(expansion),
|
"/dMyAppExpansion=%s"%(expansion),
|
||||||
"/dMyAppDir=%s"%dst,
|
"/dMyAppDir=%s"%tmpDir,
|
||||||
"/dMyOutputDir=%s"%destination,
|
"/dMyOutputDir=%s"%destination,
|
||||||
"/dMyOutputFile=%s"%fileName]) #stdout=devnull, stderr=devnull
|
"/dMyOutputFile=%s"%fileName]) #stdout=devnull, stderr=devnull
|
||||||
|
|
||||||
@@ -252,7 +238,7 @@ if __name__ == "__main__":
|
|||||||
shutil.rmtree("dist") # Inno dir
|
shutil.rmtree("dist") # Inno dir
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
shutil.rmtree(dst)
|
shutil.rmtree(tmpDir)
|
||||||
os.unlink(tmpFile)
|
os.unlink(tmpFile)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|||||||
2
setup.py
2
setup.py
@@ -5,7 +5,9 @@ Windows executable: python setup.py build
|
|||||||
Windows executable + installer: python setup.py bdist_msi
|
Windows executable + installer: python setup.py bdist_msi
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# The modules that contain the bulk of teh source
|
||||||
packages = ['eos', 'gui', 'service', 'utils']
|
packages = ['eos', 'gui', 'service', 'utils']
|
||||||
|
# Extra files that will be copied into the root directory
|
||||||
include_files = ['eve.db', 'LICENSE', 'README.md']
|
include_files = ['eve.db', 'LICENSE', 'README.md']
|
||||||
# this is read by dist.py to package the icons
|
# this is read by dist.py to package the icons
|
||||||
icon_dirs = ['gui', 'icons', 'renders']
|
icon_dirs = ['gui', 'icons', 'renders']
|
||||||
|
|||||||
Reference in New Issue
Block a user