|
| 1 | +# NOTE: this needs to be run with a Visual Studio 2010 x64 command prompt and |
| 2 | +# a x86 Python 2.7 installation with pywin32 installed. Run via: |
| 3 | +# C:\Users\Trent\Home\src\pyparallel\Tools\msi>C:\Python27\python.exe msi.py |
| 4 | + |
1 | 5 | # Python MSI Generator |
2 | 6 | # (C) 2003 Martin v. Loewis |
3 | 7 | # See "FOO" in comments refers to MSDN sections with the title FOO. |
|
61 | 65 | if name == 'PY_MINOR_VERSION': minor = value |
62 | 66 | if name == 'PY_MICRO_VERSION': micro = value |
63 | 67 | if name == 'PY_RELEASE_LEVEL': level = levels[value] |
64 | | - if name == 'PY_RELEASE_SERIAL': serial = value |
65 | 68 |
|
66 | 69 | short_version = major+"."+minor |
67 | 70 |
|
68 | | -# PyParallel: we're making installers far more frequently now (after every few |
69 | | -# commits), so use the hg repo serial revision as our serial number (ensures |
70 | | -# the installer .msi gets a unique version). |
71 | | -from subprocess import check_output |
72 | | -hgsum = check_output('hg sum') |
73 | | -# First line of output will look something like this: |
74 | | -# 'parent: 94329:2ce4e90fd470 tip' |
75 | | -# ^^^^^ |
76 | | -# We want that bit. |
77 | | -serial = hgsum.splitlines()[0].split(' ')[1].split(':')[0] |
| 71 | +serial_header = srcdir + '/Include/serial.h' |
| 72 | + |
| 73 | +def load_serial(): |
| 74 | + with open(serial_header, 'r') as f: |
| 75 | + return f.read().replace('#define PY_RELEASE_SERIAL', '').strip() |
| 76 | + |
| 77 | +def update_serial(): |
| 78 | + serial = str(int(load_serial())+1) |
| 79 | + with open(serial_header, 'w') as f: |
| 80 | + f.write(' '.join(('#define PY_RELEASE_SERIAL ', serial))) |
| 81 | + |
| 82 | +serial = load_serial() |
78 | 83 |
|
79 | 84 | # See PC/make_versioninfo.c |
80 | | -FIELD3 = 1000*int(micro) + 10*level + int(serial) |
81 | | -current_version = "%s.%d" % (short_version, FIELD3) |
| 85 | +#FIELD3 = 1000*int(micro) + 10*level + int(serial) |
| 86 | +current_version = "%s.%s" % (short_version, serial) |
82 | 87 |
|
83 | 88 | # This should never change. The UpgradeCode of this package can be |
84 | 89 | # used in the Upgrade table of future packages to make the future |
@@ -1032,20 +1037,72 @@ def hgmanifest(): |
1032 | 1037 | d[components[0]] = None |
1033 | 1038 | return result |
1034 | 1039 |
|
| 1040 | +def gitmanifest(): |
| 1041 | + # Lazy copy & paste of git environment initialization code from |
| 1042 | + # Lib/px/commands.py. |
| 1043 | + from os.path import ( |
| 1044 | + join, |
| 1045 | + abspath, |
| 1046 | + normpath, |
| 1047 | + ) |
| 1048 | + def join_path(*args): |
| 1049 | + return abspath(normpath(join(*args))) |
| 1050 | + |
| 1051 | + git_root = 'c:\\msysgit' |
| 1052 | + git_bin = join_path(git_root, 'bin') |
| 1053 | + mingw_bin = join_path(git_root, 'mingw/bin') |
| 1054 | + git_cmd = join_path(git_root, 'cmd') |
| 1055 | + |
| 1056 | + prepend_path = ';'.join(( |
| 1057 | + git_bin, |
| 1058 | + mingw_bin, |
| 1059 | + git_cmd, |
| 1060 | + )) |
| 1061 | + |
| 1062 | + existing_path = os.environ['PATH'] |
| 1063 | + new_path = ';'.join((prepend_path, existing_path)) |
| 1064 | + os.environ['PATH'] = new_path |
| 1065 | + os.environ['PLINK_PROTOCOL'] = 'ssh' |
| 1066 | + os.environ['TERM'] = 'msys' |
| 1067 | + |
| 1068 | + cwd = os.getcwd() |
| 1069 | + os.chdir('../..') |
| 1070 | + cmd = 'git ls > Tools/msi/manifest.txt' |
| 1071 | + os.system(cmd) |
| 1072 | + os.chdir(cwd) |
| 1073 | + with open('manifest.txt', 'r') as f: |
| 1074 | + lines = f.readlines() |
| 1075 | + |
| 1076 | + # Create nested directories for file tree |
| 1077 | + result = {} |
| 1078 | + for line in lines: |
| 1079 | + # -1 = remove trailing \n |
| 1080 | + components = line[:-1].split('/') |
| 1081 | + d = result |
| 1082 | + while len(components) > 1: |
| 1083 | + d1 = d.setdefault(components[0], {}) |
| 1084 | + d = d1 |
| 1085 | + del components[0] |
| 1086 | + d[components[0]] = None |
| 1087 | + |
| 1088 | + return result |
| 1089 | + |
| 1090 | +def manifest(): |
| 1091 | + return gitmanifest() |
1035 | 1092 |
|
1036 | 1093 | # See "File Table", "Component Table", "Directory Table", |
1037 | 1094 | # "FeatureComponents Table" |
1038 | 1095 | def add_files(db): |
1039 | 1096 | installer = msilib.MakeInstaller() |
1040 | | - hgfiles = hgmanifest() |
| 1097 | + files = manifest() |
1041 | 1098 | cab = CAB("pyparallel") |
1042 | 1099 | tmpfiles = [] |
1043 | 1100 | # Add all executables, icons, text files into the TARGETDIR component |
1044 | 1101 | root = PyDirectory(db, cab, None, srcdir, "TARGETDIR", "SourceDir") |
1045 | 1102 | default_feature.set_current() |
1046 | 1103 | if not msilib.Win64: |
1047 | 1104 | root.add_file("%s/w9xpopen.exe" % PCBUILD) |
1048 | | - root.add_file("README.txt", src="README") |
| 1105 | + root.add_file("README.txt", src="README.original") |
1049 | 1106 | root.add_file("NEWS.txt", src="Misc/NEWS") |
1050 | 1107 | root.add_file("px.bat", src="Tools/pyparallel/px.bat") |
1051 | 1108 | root.add_file("tefb.bat", src="Tools/pyparallel/tefb.bat") |
@@ -1141,18 +1198,18 @@ def add_files(db): |
1141 | 1198 | # Add all .py files in Lib, except tkinter, test |
1142 | 1199 | dirs = [] |
1143 | 1200 | pydirs = [ |
1144 | | - (root, "Lib", hgfiles["Lib"], default_feature), |
1145 | | - (root, "examples", hgfiles["examples"], default_feature), |
1146 | | - (root, "Python", hgfiles["Python"], source), |
1147 | | - (root, "PCbuild", hgfiles["PCbuild"], source), |
1148 | | - (root, "PC", hgfiles["PC"], source), |
1149 | | - (root, "diffs", hgfiles["diffs"], source), |
1150 | | - (root, "Include", hgfiles["Include"], source), |
1151 | | - (root, "Grammar", hgfiles["Grammar"], source), |
1152 | | - (root, "Objects", hgfiles["Objects"], source), |
1153 | | - (root, "Modules", hgfiles["Modules"], source), |
1154 | | - (root, "Parser", hgfiles["Parser"], source), |
1155 | | - (root, "contrib", hgfiles["contrib"], source), |
| 1201 | + (root, "Lib", files["Lib"], default_feature), |
| 1202 | + (root, "examples", files["examples"], default_feature), |
| 1203 | + (root, "Python", files["Python"], source), |
| 1204 | + (root, "PCbuild", files["PCbuild"], source), |
| 1205 | + (root, "PC", files["PC"], source), |
| 1206 | + (root, "diffs", files["diffs"], source), |
| 1207 | + (root, "Include", files["Include"], source), |
| 1208 | + (root, "Grammar", files["Grammar"], source), |
| 1209 | + (root, "Objects", files["Objects"], source), |
| 1210 | + (root, "Modules", files["Modules"], source), |
| 1211 | + (root, "Parser", files["Parser"], source), |
| 1212 | + (root, "contrib", files["contrib"], source), |
1156 | 1213 | ] |
1157 | 1214 | while pydirs: |
1158 | 1215 | # Commit every now and then, or else installer will complain |
@@ -1551,4 +1608,6 @@ def merge(msi, feature, rootdir, modules): |
1551 | 1608 | print 'Running: %s' % cmd |
1552 | 1609 | os.system(cmd) |
1553 | 1610 |
|
| 1611 | +#update_serial() |
| 1612 | + |
1554 | 1613 | # vim:set tw=0: |
0 commit comments