← Back to DAGDA | Support | Source: https://github.com/pyparallel/pyparallel/commit/ca64e60fd323875e2ca4af497d15d2f856f6c34d
Skip to content

Commit ca64e60

Browse files
committed
Update installer to work with git.
The serial stuff is a bit hacky and will need to be reviewed down the track (or simply abandoned when we rebase to 3.5+).
1 parent e7472b3 commit ca64e60

1 file changed

Lines changed: 86 additions & 27 deletions

File tree

‎Tools/msi/msi.py‎

Lines changed: 86 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
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+
15
# Python MSI Generator
26
# (C) 2003 Martin v. Loewis
37
# See "FOO" in comments refers to MSDN sections with the title FOO.
@@ -61,24 +65,25 @@
6165
if name == 'PY_MINOR_VERSION': minor = value
6266
if name == 'PY_MICRO_VERSION': micro = value
6367
if name == 'PY_RELEASE_LEVEL': level = levels[value]
64-
if name == 'PY_RELEASE_SERIAL': serial = value
6568

6669
short_version = major+"."+minor
6770

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()
7883

7984
# 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)
8287

8388
# This should never change. The UpgradeCode of this package can be
8489
# used in the Upgrade table of future packages to make the future
@@ -1032,20 +1037,72 @@ def hgmanifest():
10321037
d[components[0]] = None
10331038
return result
10341039

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()
10351092

10361093
# See "File Table", "Component Table", "Directory Table",
10371094
# "FeatureComponents Table"
10381095
def add_files(db):
10391096
installer = msilib.MakeInstaller()
1040-
hgfiles = hgmanifest()
1097+
files = manifest()
10411098
cab = CAB("pyparallel")
10421099
tmpfiles = []
10431100
# Add all executables, icons, text files into the TARGETDIR component
10441101
root = PyDirectory(db, cab, None, srcdir, "TARGETDIR", "SourceDir")
10451102
default_feature.set_current()
10461103
if not msilib.Win64:
10471104
root.add_file("%s/w9xpopen.exe" % PCBUILD)
1048-
root.add_file("README.txt", src="README")
1105+
root.add_file("README.txt", src="README.original")
10491106
root.add_file("NEWS.txt", src="Misc/NEWS")
10501107
root.add_file("px.bat", src="Tools/pyparallel/px.bat")
10511108
root.add_file("tefb.bat", src="Tools/pyparallel/tefb.bat")
@@ -1141,18 +1198,18 @@ def add_files(db):
11411198
# Add all .py files in Lib, except tkinter, test
11421199
dirs = []
11431200
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),
11561213
]
11571214
while pydirs:
11581215
# Commit every now and then, or else installer will complain
@@ -1551,4 +1608,6 @@ def merge(msi, feature, rootdir, modules):
15511608
print 'Running: %s' % cmd
15521609
os.system(cmd)
15531610

1611+
#update_serial()
1612+
15541613
# vim:set tw=0:

0 commit comments

Comments
 (0)