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

setup.py: Add win postinst script

Signed-off-by: Michael Büsch's avatarMichael Buesch <m@bues.ch>
parent a03512d5
#! python
import sys
import os
try:
if sys.argv[1] == "-install":
wrapper = os.path.join(sys.prefix, "Scripts", "awlsim-win.bat")
for d in (get_special_folder_path("CSIDL_COMMON_STARTMENU"),
get_special_folder_path("CSIDL_STARTMENU")):
if os.path.isdir(d):
shortcut = os.path.join(d, "Awlsim.lnk")
create_shortcut(wrapper, "Awlsim", shortcut)
file_created(shortcut)
break
except Exception as e:
print(str(e))
raise
......@@ -170,6 +170,7 @@ def tryBuildCythonModules():
cmdclass = {}
ext_modules = []
extraScripts = []
# Try to build the Cython modules. This might fail.
tryBuildCythonModules()
......@@ -181,6 +182,16 @@ try:
except LookupError:
codecs.register(lambda name: codecs.lookup("ascii") if name == "mbcs" else None)
# Add win postinstall script
try:
idx = sys.argv.index("bdist_wininst")
if idx > 0:
sys.argv.insert(idx + 1, "--install-script")
sys.argv.insert(idx + 2, "awlsim-wininst-postinstall.py")
extraScripts.append("awlsim-wininst-postinstall.py")
except ValueError:
pass
setup( name = "awlsim",
version = "%d.%d" % (VERSION_MAJOR, VERSION_MINOR),
description = "Step 7 AWL/STL/PLC simulator",
......@@ -200,7 +211,7 @@ setup( name = "awlsim",
"awlsimgui",
"awlsim-server",
"awlsim-linuxcnc-hal",
"awlsim-win.bat", ],
"awlsim-win.bat", ] + extraScripts,
cmdclass = cmdclass,
ext_modules = ext_modules,
keywords = [ "AWL", "STL", "SPS", "PLC", "Step 7",
......
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