Skip to content
Permalink
Browse files

Added spec file for building with pyinstaller

  • Loading branch information...
Kurocon committed Apr 22, 2016
1 parent d8c1e88 commit ecf8ee27979392864290765017cb0cee756d9dc5
Showing with 144 additions and 1 deletion.
  1. +0 −1 .gitignore
  2. +144 −0 oce.spec
@@ -30,7 +30,6 @@ var/
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
144 oce.spec
@@ -0,0 +1,144 @@
# -*- mode: python -*-
import os
from glob import glob

print("#################################")
print("# Building OsuCollectionsEditor #")
print("#################################")

block_cipher = None

# Add staticfiles to build
static_files = [
('logging.conf', '.'),
('icons', 'icons')
]


# Build the exe with libraries

print("")
print("Building OCE with separate libraries")
print("####################################")
print("")
print("Analysing...")
print("")

a = Analysis(['oce.py'],
pathex=[SPECPATH],
binaries=static_files,
datas=None,
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)

print("")
print("Archiving")
print("")

pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)

print("")
print("Compiling executable")
print("")

exe = EXE(pyz,
a.scripts,
exclude_binaries=True,
name='oce',
debug=False,
strip=False,
upx=True,
console=True )

print("")
print("Collecting libraries")
print("")

coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
name='oce')


# Build the portable exe

print("")
print("Building OCE portable (with included libraries)")
print("###############################################")
print("")
print("Analysing")
print("")

a = Analysis(['oce.py'],
pathex=[SPECPATH],
binaries=static_files,
datas=static_files,
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)

print("")
print("Archiving")
print("")

pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)

print("")
print("Building executable")
print("")

portable_exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
name='oce_p',
debug=False,
strip=False,
upx=True,
console=True )

print("")
print("Collecting static files")
print("")

# Copy static files to portable dir
a.datas += [('logging.conf', 'logging.conf', 'DATA')]
for i in glob(os.path.join('icons', '*')):
a.datas += [(i, i, 'DATA')]

portable_coll = COLLECT(portable_exe,
a.datas,
strip=False,
upx=True,
name="oce_portable"
)

print("")
print("Cleaning up")
print("")

try:
os.remove(os.path.join(DISTPATH, "oce_p"))
except OSError:
pass

try:
os.rename(os.path.join(DISTPATH, "oce_portable", "oce_p"), os.path.join(DISTPATH, "oce_portable", "oce"))
except WindowsError:
os.remove(os.path.join(DISTPATH, "oce_portable", "oce"))
os.rename(os.path.join(DISTPATH, "oce_portable", "oce_p"), os.path.join(DISTPATH, "oce_portable", "oce"))

0 comments on commit ecf8ee2

Please sign in to comment.
You can’t perform that action at this time.