source: setup.py@ 935:79a441954367

python3
Last change on this file since 935:79a441954367 was 935:79a441954367, checked in by István Váradi <ivaradi@…>, 5 years ago

Windows build changes in setup.py for the new environment and py2exe (re #347).

File size: 7.9 KB
Line 
1# -*- coding: iso-8859-2 -*-
2
3import sys
4import os
5from glob import glob
6from distutils.core import setup
7from pathlib import Path
8
9scriptdir=os.path.dirname(sys.argv[0])
10sys.path.insert(0, os.path.join(scriptdir, "src"))
11
12import mlx.const
13import mlx.update
14
15data_files = [("sounds", glob(os.path.join("sounds", "*.*")))]
16for language in ["en", "hu"]:
17 data_files.append((os.path.join("doc", "manual", language),
18 glob(os.path.join("doc", "manual", language, "*.*"))))
19 data_files.append((os.path.join("locale", language, "LC_MESSAGES"),
20 [os.path.join("locale", language, "LC_MESSAGES",
21 "mlx.mo")]))
22
23rootFiles = ["logo.png", "conn_grey.png", "conn_red.png", "conn_green.png"]
24if os.name!="nt":
25 rootFiles.append("Microsoft.VC90.CRT.manifest")
26data_files.append(("", rootFiles))
27
28if os.name=="nt":
29 import py2exe
30
31 data_files.append(("", ["logo.ico"]))
32
33 msvcrDir = os.environ["MSVCRDIR"] if "MSVCRDIR" in os.environ else None
34 if msvcrDir:
35 data_files.append(("Microsoft.VC90.CRT",
36 ["Microsoft.VC90.CRT.manifest"] +
37 glob(os.path.join(msvcrDir, "*.*"))))
38 os.environ["PATH"] = os.environ["PATH"] + ";" + glob(os.path.join(msvcrDir))[0]
39
40
41 gtkRuntimeDir = os.environ["GTKRTDIR"] if "GTKRTDIR" in os.environ else None
42 if gtkRuntimeDir:
43 if gtkRuntimeDir.endswith("/mingw32"):
44 path = os.path.join("lib", "girepository-1.0")
45 data_files.append((path,
46 glob(os.path.join(gtkRuntimeDir, path, "*"))))
47
48 files = {}
49
50 for components in [ ["lib", "girepository-1.0"],
51 ["lib", "gdk-pixbuf-2.0", "2.10.0"],
52 ["share", "icons"],
53 ["share", "locale", "hu"],
54 ["share", "locale", "en"],
55 ["share", "themes"],
56 ["share", "glib-2.0", "schemas"]]:
57 path = os.path.join(*components)
58 p = Path(os.path.join(gtkRuntimeDir, path))
59 for f in p.glob("**/*"):
60 if f.is_file():
61 d = os.path.join(path, str(f.parent.relative_to(p)))
62 if d in files:
63 files[d].append(str(f))
64 else:
65 files[d] = [str(f)]
66
67 for path in files:
68 data_files.append((path, files[path]))
69 data_files.append(("",
70 [os.path.join(gtkRuntimeDir, "bin", "librsvg-2-2.dll"),
71 os.path.join(gtkRuntimeDir, "bin", "libcroco-0.6-3.dll")]))
72 else:
73 path = os.path.join("lib", "gtk-2.0", "2.10.0", "engines")
74 data_files.append((os.path.join("library", path),
75 [os.path.join(gtkRuntimeDir, path, "libwimp.dll")]))
76
77 path = os.path.join("share", "themes", "MS-Windows", "gtk-2.0")
78 data_files.append((os.path.join("library", path),
79 glob(os.path.join(gtkRuntimeDir, path, "*"))))
80
81 path = os.path.join("share", "locale", "hu", "LC_MESSAGES")
82 data_files.append((os.path.join("library", path),
83 glob(os.path.join(gtkRuntimeDir, path, "*"))))
84 path = os.path.join("share", "icons", "hicolor")
85 data_files.append((os.path.join("library", path),
86 glob(os.path.join(gtkRuntimeDir, path, "*"))))
87
88 cefDir = os.environ.get("CEFDIR")
89 if cefDir:
90 for fileName in ["icudtl.dat", "subprocess.exe", "natives_blob.bin",
91 "snapshot_blob.bin", "v8_context_snapshot.bin",
92 "cef.pak", "cef_100_percent.pak",
93 "cef_200_percent.pak", "cef_extensions.pak"]:
94 data_files.append(("", [os.path.join(cefDir, fileName)]))
95
96 data_files.append(("locales",
97 glob(os.path.join(cefDir, "locales", "*"))))
98
99 if os.getenv("WINE")=="yes":
100 winsysdir=os.getenv("WINSYSDIR")
101 data_files.append(("", [os.path.join(winsysdir, "python27.dll")]))
102 data_files.append(("library", [
103 os.path.join(winsysdir, "pywintypes27.dll"),
104 os.path.join(winsysdir, "WINHTTP.dll")]))
105
106 if gtkRuntimeDir:
107 gtkBinDir = os.path.join(gtkRuntimeDir, "bin")
108 data_files.append(("library", [
109 os.path.join(gtkBinDir, "freetype6.dll"),
110 os.path.join(gtkBinDir, "intl.dll"),
111 os.path.join(gtkBinDir, "zlib1.dll"),
112 os.path.join(gtkBinDir, "libglib-2.0-0.dll"),
113 os.path.join(gtkBinDir, "libatk-1.0-0.dll"),
114 os.path.join(gtkBinDir, "libcairo-2.dll"),
115 os.path.join(gtkBinDir, "libexpat-1.dll"),
116 os.path.join(gtkBinDir, "libpangowin32-1.0-0.dll"),
117 os.path.join(gtkBinDir, "libgio-2.0-0.dll"),
118 os.path.join(gtkBinDir, "libgdk-win32-2.0-0.dll"),
119 os.path.join(gtkBinDir, "libpng14-14.dll"),
120 os.path.join(gtkBinDir, "libgobject-2.0-0.dll"),
121 os.path.join(gtkBinDir, "libgdk_pixbuf-2.0-0.dll"),
122 os.path.join(gtkBinDir, "libfontconfig-1.dll"),
123 os.path.join(gtkBinDir, "libpangoft2-1.0-0.dll"),
124 os.path.join(gtkBinDir, "libgmodule-2.0-0.dll"),
125 os.path.join(gtkBinDir, "libpango-1.0-0.dll"),
126 os.path.join(gtkBinDir, "libpangocairo-1.0-0.dll"),
127 os.path.join(gtkBinDir, "libgtk-win32-2.0-0.dll"),
128 os.path.join(gtkBinDir, "libgthread-2.0-0.dll")
129 ]))
130 if cefDir:
131 data_files.append(("library", [
132 os.path.join(cefDir, "libcef.dll")
133 ]))
134
135 print(data_files)
136
137 with open("mlx-common.nsh", "wt") as f:
138 print('!define MLX_VERSION "%s"' % (mlx.const.VERSION), file=f)
139 f.close()
140else:
141 for (dirpath, dirnames, filenames) in os.walk("patches"):
142 if filenames:
143 filenames = [os.path.join(dirpath, filename)
144 for filename in filenames]
145 data_files.append((dirpath, filenames))
146
147
148long_description="""MAVA Logger X
149
150This is a program to log and evaluate the actions
151of a pilot flying a virtual Malév flight operated
152by MAVA."""
153
154setup(name = "mlx",
155 version = mlx.const.VERSION,
156 description = "MAVA Logger X",
157 long_description = long_description,
158 author = "István Váradi",
159 author_email = "ivaradi@gmail.com",
160 url = "http://mlx.varadiistvan.hu",
161 package_dir = { "" : "src" },
162 packages = ["mlx", "mlx.gui"],
163 requires = ["pyuipc", "xplra"],
164 windows = [{ "script" : "runmlx.py",
165 "icon_resources" : [(1, "logo.ico")]},
166 { "script" : "mlxupdate.py",
167 "uac_info" : "requireAdministrator"}],
168 options = { "py2exe" : { "packages" : "gi, lxml",
169 "skip_archive": True} },
170 zipfile = "library",
171 data_files = data_files,
172 platforms = ["Win32", "Linux"],
173 license = "Public Domain"
174 )
175
176if os.name=="nt":
177 mlx.update.buildManifest(os.path.join(scriptdir, "dist"))
178 with open(os.path.join(scriptdir, "dist", "Uninstall.conf"), "wt") as f:
179 print("StartMenuFolder=MAVA Logger X", file=f)
180 print("LinkName=MAVA Logger X", file=f)
Note: See TracBrowser for help on using the repository browser.