mirror of
https://github.com/timsutton/brigadier.git
synced 2025-05-29 06:25:36 -04:00
Windows build script support for PyInstaller 2.1
This commit is contained in:
parent
7412efcfc2
commit
aaca3c484d
1 changed files with 9 additions and 14 deletions
|
@ -14,7 +14,7 @@ import subprocess
|
||||||
import shutil
|
import shutil
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
PYINSTALLER_URL = 'http://sourceforge.net/projects/pyinstaller/files/2.0/pyinstaller-2.0.zip/download'
|
PYINSTALLER_URL = 'https://pypi.python.org/packages/source/P/PyInstaller/PyInstaller-2.1.zip'
|
||||||
PYINST_ZIPFILE = os.path.join(os.getcwd(), 'pyinstaller.zip')
|
PYINST_ZIPFILE = os.path.join(os.getcwd(), 'pyinstaller.zip')
|
||||||
NAME = 'brigadier'
|
NAME = 'brigadier'
|
||||||
|
|
||||||
|
@ -22,9 +22,8 @@ with open('VERSION', 'r') as fd:
|
||||||
version = fd.read().strip()
|
version = fd.read().strip()
|
||||||
name_versioned = NAME + '-' + version
|
name_versioned = NAME + '-' + version
|
||||||
exe_name = NAME + '.exe'
|
exe_name = NAME + '.exe'
|
||||||
spec_dir = os.path.join(os.getcwd(), 'spec')
|
|
||||||
dist_dir = os.path.join(spec_dir, 'dist')
|
|
||||||
pack_dir = os.path.join(os.getcwd(), name_versioned)
|
pack_dir = os.path.join(os.getcwd(), name_versioned)
|
||||||
|
build_dir = os.path.join(os.getcwd(), 'build')
|
||||||
|
|
||||||
need_pyinstaller = False
|
need_pyinstaller = False
|
||||||
if os.path.exists(PYINST_ZIPFILE):
|
if os.path.exists(PYINST_ZIPFILE):
|
||||||
|
@ -42,23 +41,19 @@ if need_pyinstaller:
|
||||||
urllib.urlretrieve(PYINSTALLER_URL, filename=PYINST_ZIPFILE)
|
urllib.urlretrieve(PYINSTALLER_URL, filename=PYINST_ZIPFILE)
|
||||||
|
|
||||||
dlzip = ZipFile(PYINST_ZIPFILE)
|
dlzip = ZipFile(PYINST_ZIPFILE)
|
||||||
pyinst_root = dlzip.namelist()[0].strip('/')
|
pyinst_root = dlzip.namelist()[0].split("/")[0]
|
||||||
dlzip.extractall()
|
dlzip.extractall()
|
||||||
|
|
||||||
print "Building version %s..." % version
|
print "Building version %s..." % version
|
||||||
build_cmd = [os.path.join(os.environ["SYSTEMDRIVE"] + "\\", 'Python27', 'python.exe'),
|
build_cmd = [os.path.join(os.environ["SYSTEMDRIVE"] + "\\", 'Python27', 'python.exe'),
|
||||||
os.path.join(os.getcwd(), pyinst_root, 'pyinstaller.py'),
|
os.path.join(os.getcwd(), pyinst_root, 'pyinstaller.py'),
|
||||||
'-F',
|
'-F',
|
||||||
'--out', spec_dir,
|
'--distpath', pack_dir,
|
||||||
'--name', NAME,
|
'--name', NAME,
|
||||||
'brigadier']
|
'brigadier']
|
||||||
subprocess.call(build_cmd)
|
subprocess.call(build_cmd)
|
||||||
|
|
||||||
print "Compressing to zip file..."
|
print "Compressing to zip file..."
|
||||||
if not os.path.isdir(pack_dir):
|
|
||||||
os.mkdir(pack_dir)
|
|
||||||
os.rename(os.path.join(dist_dir, exe_name),
|
|
||||||
os.path.join(pack_dir, exe_name))
|
|
||||||
zipfile_name = name_versioned + '.zip'
|
zipfile_name = name_versioned + '.zip'
|
||||||
packzip = ZipFile(zipfile_name, 'w')
|
packzip = ZipFile(zipfile_name, 'w')
|
||||||
packzip.write(os.path.basename(pack_dir))
|
packzip.write(os.path.basename(pack_dir))
|
||||||
|
@ -68,11 +63,11 @@ with open(zipfile_name, 'r') as zipfd:
|
||||||
sha1 = hashlib.sha1(zipfd.read()).hexdigest()
|
sha1 = hashlib.sha1(zipfd.read()).hexdigest()
|
||||||
|
|
||||||
print "Cleaning up..."
|
print "Cleaning up..."
|
||||||
for dirs in [pack_dir, spec_dir, pyinst_root]:
|
for dirs in [pack_dir, build_dir, pyinst_root]:
|
||||||
shutil.rmtree(dirs)
|
shutil.rmtree(dirs)
|
||||||
for f in os.listdir(os.getcwd()):
|
for f in os.listdir(os.getcwd()):
|
||||||
if f.startswith('logdict'):
|
if f.startswith('logdict'):
|
||||||
os.remove(f)
|
os.remove(f)
|
||||||
|
|
||||||
print "Built and archived to %s." % zipfile_name
|
print "Built and archived to %s." % zipfile_name
|
||||||
print "SHA1: %s" % sha1
|
print "SHA1: %s" % sha1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue