Commit fb3356e3 authored by Michael Büsch's avatar Michael Büsch

Add support for py2exe

Signed-off-by: Michael Büsch's avatarMichael Buesch <[email protected]>
parent 6eb4a0c6
......@@ -22,6 +22,7 @@
from __future__ import division, absolute_import, print_function, unicode_literals
import sys
import os
# isPyPy is True, if the interpreter is PyPy.
......@@ -33,6 +34,11 @@ isJython = sys.platform.lower().startswith("java")
# isIronPython is True, if the interpreter is IronPython
isIronPython = "IronPython" in sys.version
# isWinStandalone is True, if this is a Windows standalone package (py2exe)
isWinStandalone = os.name == "nt" and\
(sys.executable.endswith("awlsimgui.exe") or\
sys.executable.endswith("awlsimcli.exe"))
# isPy3Compat is True, if the interpreter is Python 3 compatible.
isPy3Compat = sys.version_info[0] == 3
......
......@@ -189,9 +189,15 @@ class CpuWidget(QWidget):
# XXX: There is a race-window here. Another process might
# allocate the port that we just checked
# before our server is able to allocate it.
client.spawnServer(interpreter = interp,
listenHost = host,
listenPort = port)
if isWinStandalone:
# Run the py2exe standalone server process
client.spawnServer(serverExecutable = "server.exe",
listenHost = host,
listenPort = port)
else:
client.spawnServer(interpreter = interp,
listenHost = host,
listenPort = port)
break
else:
raise AwlSimError("Did not find a free port to run the "
......
@echo off
SET PATH=%PATH%;C:\WINDOWS;C:\WINDOWS\SYSTEM32;C:\PYTHON34;%ProgramFiles%\7-Zip
py -c "from awlsim.core.version import VERSION_MAJOR, VERSION_MINOR; print('%%d.%%d' %% (VERSION_MAJOR, VERSION_MINOR))" > version.txt
set /p version= < version.txt
set distdir=awlsim-win-standalone-%version%
set zipfile=awlsim-win-standalone-%version%.zip
echo Building standalone Windows executable for awlsim v%version%...
rem ---
rem Create the py2exe distribution
rem ---
rd /s /q build 2>NUL
rd /s /q %distdir% 2>NUL
py setup.py py2exe ^
--dist-dir=%distdir% ^
--optimize=2 ^
--bundle-files=3 ^
--compressed ^
--ignores=win32api,win32con,readline,awlsim_cython ^
--packages=awlsimhw_debug,awlsimhw_dummy ^
--quiet
if ERRORLEVEL 1 goto error_exe
rem ---
rem Copy additional files
rem ---
copy EXAMPLE.* %distdir%\
copy README.txt %distdir%\
copy COMPATIBILITY.txt %distdir%\
copy TODO.txt %distdir%\
xcopy doc\foreign-licenses %distdir%\licenses\ /E
copy COPYING.txt %distdir%\licenses\AWLSIM-LICENSE.txt
rem ---
rem Create the distribution archive
rem ---
del %zipfile% 2>NUL
7z a -tzip %zipfile% %distdir%
if ERRORLEVEL 1 goto error_zip
echo ---
echo finished
pause
exit
:error_exe
echo FAILED to build exe
goto error
:error_zip
echo FAILED to create zip archive
goto error
:error
pause
exit
\ No newline at end of file
......@@ -10,6 +10,10 @@ import hashlib
from distutils.core import setup
from distutils.extension import Extension
from awlsim.core.version import VERSION_MAJOR, VERSION_MINOR
try:
import py2exe
except ImportError as e:
py2exe = None
def makedirs(path, mode):
......@@ -171,6 +175,7 @@ def tryBuildCythonModules():
cmdclass = {}
ext_modules = []
extraScripts = []
extraKeywords = {}
# Try to build the Cython modules. This might fail.
tryBuildCythonModules()
......@@ -192,6 +197,9 @@ try:
except ValueError:
pass
if py2exe:
extraKeywords["console"] = [ "awlsimgui", "awlsim/coreserver/server.py", ]
setup( name = "awlsim",
version = "%d.%d" % (VERSION_MAJOR, VERSION_MINOR),
description = "S7 AWL/STL Soft-PLC",
......@@ -251,5 +259,6 @@ setup( name = "awlsim",
"Topic :: Software Development :: Testing",
"Topic :: System :: Emulators",
],
long_description = open("README.txt").read()
long_description = open("README.txt").read(),
**extraKeywords
)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment