Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 81ca7c7

Browse files
committed
Updates to the msi builder and PCbuild9 directory. msi.py can now create installers from the PCbuild9 directory with MSVCR90.dll. PCbuild and MSVCR71.dll are still the default.
1 parent 6030a60 commit 81ca7c7

4 files changed

Lines changed: 83 additions & 32 deletions

File tree

PCbuild9/installer.bmp

57.4 KB
Binary file not shown.

PCbuild9/pyd.vsprops

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,17 @@
77
>
88
<Tool
99
Name="VCCLCompilerTool"
10-
RuntimeLibrary="2"
1110
PreprocessorDefinitions="NDEBUG"
11+
RuntimeLibrary="2"
1212
/>
1313
<Tool
1414
Name="VCLinkerTool"
1515
OutputFile="$(OutDir)\$(ProjectName).pyd"
16-
ImportLibrary="$(IntDir)\$(TargetName).lib"
1716
ProgramDatabaseFile="$(OutDir)\$(ProjectName).pdb"
17+
ImportLibrary="$(IntDir)\$(TargetName).lib"
18+
/>
19+
<Tool
20+
Name="VCPostBuildEventTool"
21+
CommandLine="copy $(IntDir)\$(ProjectName).lib $(OutDir)"
1822
/>
1923
</VisualStudioPropertySheet>

PCbuild9/pyd_d.vsprops

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@
1616
Name="VCLinkerTool"
1717
OutputFile="$(OutDir)\$(ProjectName)_d.pyd"
1818
LinkIncremental="1"
19-
ImportLibrary="$(IntDir)\$(TargetName).lib"
2019
ProgramDatabaseFile="$(OutDir)\$(ProjectName)_d.pdb"
20+
ImportLibrary="$(IntDir)\$(TargetName).lib"
21+
/>
22+
<Tool
23+
Name="VCPostBuildEventTool"
24+
CommandLine="copy $(IntDir)\$(ProjectName)_d.lib $(OutDir)"
2125
/>
2226
</VisualStudioPropertySheet>

Tools/msi/msi.py

Lines changed: 72 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Python MSI Generator
22
# (C) 2003 Martin v. Loewis
33
# See "FOO" in comments refers to MSDN sections with the title FOO.
4-
import msilib, schema, sequence, os, glob, time, re
4+
import msilib, schema, sequence, os, glob, time, re, shutil
55
from msilib import Feature, CAB, Directory, Dialog, Binary, add_data
66
import uisample
77
from win32com.client import constants
@@ -26,6 +26,12 @@
2626
have_tcl = True
2727
# Where is sqlite3.dll located, relative to srcdir?
2828
sqlite_dir = "../sqlite-source-3.3.4"
29+
# path to PCbuild directory
30+
PCBUILD="PCbuild"
31+
#PCBUILD="PCbuild9"
32+
# msvcrt version
33+
MSVCR = "71"
34+
#MSVCR = "90"
2935

3036
try:
3137
from config import *
@@ -101,6 +107,7 @@
101107
# Using the same UUID is fine since these files are versioned,
102108
# so Installer will always keep the newest version.
103109
msvcr71_uuid = "{8666C8DD-D0B4-4B42-928E-A69E32FA5D4D}"
110+
msvcr90_uuid = "" # XXX
104111
pythondll_uuid = {
105112
"24":"{9B81E618-2301-4035-AC77-75D9ABEB7301}",
106113
"25":"{2e41b118-38bd-4c1b-a840-6977efd1b911}",
@@ -147,15 +154,15 @@ def build_mingw_lib(lib_file, def_file, dll_file, mingw_lib):
147154
return True
148155

149156
# Target files (.def and .a) go in PCBuild directory
150-
lib_file = os.path.join(srcdir, "PCBuild", "python%s%s.lib" % (major, minor))
151-
def_file = os.path.join(srcdir, "PCBuild", "python%s%s.def" % (major, minor))
157+
lib_file = os.path.join(srcdir, PCBUILD, "python%s%s.lib" % (major, minor))
158+
def_file = os.path.join(srcdir, PCBUILD, "python%s%s.def" % (major, minor))
152159
dll_file = "python%s%s.dll" % (major, minor)
153-
mingw_lib = os.path.join(srcdir, "PCBuild", "libpython%s%s.a" % (major, minor))
160+
mingw_lib = os.path.join(srcdir, PCBUILD, "libpython%s%s.a" % (major, minor))
154161

155162
have_mingw = build_mingw_lib(lib_file, def_file, dll_file, mingw_lib)
156163

157164
# Determine the target architechture
158-
dll_path = os.path.join(srcdir, "PCBuild", dll_file)
165+
dll_path = os.path.join(srcdir, PCBUILD, dll_file)
159166
msilib.set_arch_from_file(dll_path)
160167
if msilib.pe_type(dll_path) != msilib.pe_type("msisupport.dll"):
161168
raise SystemError("msisupport.dll for incorrect architecture")
@@ -327,7 +334,7 @@ def add_ui(db):
327334
if not os.path.exists(srcdir+r"\PC\python_icon.exe"):
328335
raise "Run icons.mak in PC directory"
329336
add_data(db, "Binary",
330-
[("PythonWin", msilib.Binary(srcdir+r"\PCbuild\installer.bmp")), # 152x328 pixels
337+
[("PythonWin", msilib.Binary(r"%s\%s\installer.bmp" % (srcdir, PCBUILD))), # 152x328 pixels
331338
("py.ico",msilib.Binary(srcdir+r"\PC\py.ico")),
332339
])
333340
add_data(db, "Icon",
@@ -816,19 +823,45 @@ def extract_msvcr71():
816823
r"Software\Microsoft\VisualStudio\7.1\Setup\VS")
817824
dir = _winreg.QueryValueEx(k, "MSMDir")[0]
818825
_winreg.CloseKey(k)
819-
files = glob.glob1(dir, "*CRT71*")
820-
assert len(files) == 1
821-
file = os.path.join(dir, files[0])
826+
files = glob.glob1(dir, "*VCR71*.dll")
827+
assert len(files) > 0, (dir, files)
822828
# Extract msvcr71.dll
823-
m = msilib.MakeMerge2()
824-
m.OpenModule(file, 0)
825-
m.ExtractFiles(".")
826-
m.CloseModule()
829+
#m = msilib.MakeMerge2()
830+
#m.OpenModule(file, 0)
831+
#m.ExtractFiles(".")
832+
#m.CloseModule()
833+
for file in files:
834+
shutil.copy(os.path.join(dir, file), '.')
827835
# Find the version/language of msvcr71.dll
828836
installer = msilib.MakeInstaller()
829837
return installer.FileVersion("msvcr71.dll", 0), \
830838
installer.FileVersion("msvcr71.dll", 1)
831839

840+
def extract_msvcr90():
841+
import _winreg
842+
# Find the location of the merge modules
843+
k = _winreg.OpenKey(
844+
_winreg.HKEY_LOCAL_MACHINE,
845+
r"Software\Microsoft\VisualStudio\9.0\Setup\VS")
846+
prod_dir = _winreg.QueryValueEx(k, "ProductDir")[0]
847+
_winreg.CloseKey(k)
848+
849+
# Copy msvcr90*
850+
dir = os.path.join(prod_dir, r'VC\redist\x86\Microsoft.VC90.CRT')
851+
files = glob.glob1(dir, "*CRT*.dll") + glob.glob1(dir, "*VCR*.dll")
852+
for file in files:
853+
shutil.copy(os.path.join(dir, file), '.')
854+
855+
dir = os.path.join(prod_dir, r'VC\redist\Debug_NonRedist\x86\Microsoft.VC90.DebugCRT')
856+
files = glob.glob1(dir, "*CRT*.dll") + glob.glob1(dir, "*VCR*.dll")
857+
for file in files:
858+
shutil.copy(os.path.join(dir, file), '.')
859+
860+
# Find the version/language of msvcr90.dll
861+
installer = msilib.MakeInstaller()
862+
return installer.FileVersion("msvcr90.dll", 0), \
863+
installer.FileVersion("msvcr90.dll", 1)
864+
832865
class PyDirectory(Directory):
833866
"""By default, all components in the Python installer
834867
can run from source."""
@@ -846,38 +879,48 @@ def add_files(db):
846879
root = PyDirectory(db, cab, None, srcdir, "TARGETDIR", "SourceDir")
847880
default_feature.set_current()
848881
if not msilib.Win64:
849-
root.add_file("PCBuild/w9xpopen.exe")
882+
root.add_file("%s/w9xpopen.exe" % PCBUILD)
850883
root.add_file("README.txt", src="README")
851884
root.add_file("NEWS.txt", src="Misc/NEWS")
852885
root.add_file("LICENSE.txt", src="LICENSE")
853886
root.start_component("python.exe", keyfile="python.exe")
854-
root.add_file("PCBuild/python.exe")
887+
root.add_file("%s/python.exe" % PCBUILD)
855888
root.start_component("pythonw.exe", keyfile="pythonw.exe")
856-
root.add_file("PCBuild/pythonw.exe")
889+
root.add_file("%s/pythonw.exe" % PCBUILD)
857890

858891
# msidbComponentAttributesSharedDllRefCount = 8, see "Component Table"
859892
dlldir = PyDirectory(db, cab, root, srcdir, "DLLDIR", ".")
860893
pydll = "python%s%s.dll" % (major, minor)
861-
pydllsrc = srcdir + "/PCBuild/" + pydll
894+
pydllsrc = os.path.join(srcdir, PCBUILD, pydll)
862895
dlldir.start_component("DLLDIR", flags = 8, keyfile = pydll, uuid = pythondll_uuid)
863896
installer = msilib.MakeInstaller()
864897
pyversion = installer.FileVersion(pydllsrc, 0)
865898
if not snapshot:
866899
# For releases, the Python DLL has the same version as the
867900
# installer package.
868901
assert pyversion.split(".")[:3] == current_version.split(".")
869-
dlldir.add_file("PCBuild/python%s%s.dll" % (major, minor),
902+
dlldir.add_file("%s/python%s%s.dll" % (PCBUILD, major, minor),
870903
version=pyversion,
871904
language=installer.FileVersion(pydllsrc, 1))
872905
# XXX determine dependencies
873-
version, lang = extract_msvcr71()
874-
dlldir.start_component("msvcr71", flags=8, keyfile="msvcr71.dll", uuid=msvcr71_uuid)
875-
dlldir.add_file("msvcr71.dll", src=os.path.abspath("msvcr71.dll"),
876-
version=version, language=lang)
877-
tmpfiles.append("msvcr71.dll")
906+
if MSVCR == "90":
907+
version, lang = extract_msvcr90()
908+
dlldir.start_component("msvcr90", flags=8, keyfile="msvcr90.dll",
909+
uuid=msvcr90_uuid)
910+
dlldir.add_file("msvcr90.dll", src=os.path.abspath("msvcr90.dll"),
911+
version=version, language=lang)
912+
tmpfiles.append("msvcr90.dll")
913+
else:
914+
version, lang = extract_msvcr71()
915+
dlldir.start_component("msvcr71", flags=8, keyfile="msvcr71.dll",
916+
uuid=msvcr71_uuid)
917+
dlldir.add_file("msvcr71.dll", src=os.path.abspath("msvcr71.dll"),
918+
version=version, language=lang)
919+
tmpfiles.append("msvcr71.dll")
920+
878921

879922
# Check if _ctypes.pyd exists
880-
have_ctypes = os.path.exists(srcdir+"/PCBuild/_ctypes.pyd")
923+
have_ctypes = os.path.exists(srcdir+"/%s/_ctypes.pyd" % PCBUILD)
881924
if not have_ctypes:
882925
print("WARNING: _ctypes.pyd not found, ctypes will not be included")
883926
extensions.remove("_ctypes.pyd")
@@ -963,15 +1006,15 @@ def add_files(db):
9631006
pydirs.append((lib, f))
9641007
# Add DLLs
9651008
default_feature.set_current()
966-
lib = PyDirectory(db, cab, root, srcdir+"/PCBuild", "DLLs", "DLLS|DLLs")
1009+
lib = PyDirectory(db, cab, root, srcdir + "/" + PCBUILD, "DLLs", "DLLS|DLLs")
9671010
lib.add_file("py.ico", src="../PC/py.ico")
9681011
lib.add_file("pyc.ico", src="../PC/pyc.ico")
9691012
dlls = []
9701013
tclfiles = []
9711014
for f in extensions:
9721015
if f=="_tkinter.pyd":
9731016
continue
974-
if not os.path.exists(srcdir+"/PCBuild/"+f):
1017+
if not os.path.exists(srcdir + "/" + PCBUILD + "/" + f):
9751018
print("WARNING: Missing extension", f)
9761019
continue
9771020
dlls.append(f)
@@ -985,7 +1028,7 @@ def add_files(db):
9851028
sqlite_arch = ""
9861029
lib.add_file(srcdir+"/"+sqlite_dir+sqlite_arch+"/sqlite3.dll")
9871030
if have_tcl:
988-
if not os.path.exists(srcdir+"/PCBuild/_tkinter.pyd"):
1031+
if not os.path.exists("%s/%s/_tkinter.pyd" % (srcdir, PCBUILD)):
9891032
print("WARNING: Missing _tkinter.pyd")
9901033
else:
9911034
lib.start_component("TkDLLs", tcltk)
@@ -995,7 +1038,7 @@ def add_files(db):
9951038
for f in glob.glob1(tcldir, "*.dll"):
9961039
lib.add_file(f, src=os.path.join(tcldir, f))
9971040
# check whether there are any unknown extensions
998-
for f in glob.glob1(srcdir+"/PCBuild", "*.pyd"):
1041+
for f in glob.glob1(srcdir+"/"+PCBUILD, "*.pyd"):
9991042
if f.endswith("_d.pyd"): continue # debug version
10001043
if f in dlls: continue
10011044
print("WARNING: Unknown extension", f)
@@ -1006,7 +1049,7 @@ def add_files(db):
10061049
lib.glob("*.h")
10071050
lib.add_file("pyconfig.h", src="../PC/pyconfig.h")
10081051
# Add import libraries
1009-
lib = PyDirectory(db, cab, root, "PCBuild", "libs", "LIBS|libs")
1052+
lib = PyDirectory(db, cab, root, PCBUILD, "libs", "LIBS|libs")
10101053
for f in dlls:
10111054
lib.add_file(f.replace('pyd','lib'))
10121055
lib.add_file('python%s%s.lib' % (major, minor))

0 commit comments

Comments
 (0)