Skip to content

Commit db02446

Browse files
committed
Tweaks to build process and comments, and update to build 222
1 parent 787cf19 commit db02446

File tree

1 file changed

+65
-54
lines changed

1 file changed

+65
-54
lines changed

setup.py

+65-54
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
build_id="221" # may optionally include a ".{patchno}" suffix.
1+
build_id="222" # may optionally include a ".{patchno}" suffix.
22
# Putting buildno at the top prevents automatic __doc__ assignment, and
33
# I *want* the build number at the top :)
44
__doc__="""This is a distutils setup-script for the pywin32 extensions
@@ -65,6 +65,19 @@
6565
setup.py build --plat-name=win-amd64
6666
6767
see the distutils cross-compilation documentation for more details.
68+
69+
Creating Distributions:
70+
-----------------------
71+
72+
The make_all.bat batch file will build and create distributions.
73+
74+
Once a distribution has been built and tested, you should ensure that
75+
'git status' shows no dirty files, then create a tag with the format 'bXXX'
76+
77+
The executable installers are uploaded to github.
78+
79+
The "wheel" packages are uploaded to pypi using `twine upload dist/path-to.whl`
80+
6881
"""
6982
# Originally by Thomas Heller, started in 2000 or so.
7083
import os, string, sys
@@ -82,7 +95,8 @@
8295
import _winreg
8396

8497
# The rest of our imports.
85-
from distutils.core import setup, Extension, Command
98+
from setuptools import setup
99+
from distutils.core import Extension, Command
86100
from distutils.command.install import install
87101
from distutils.command.install_lib import install_lib
88102
from distutils.command.build_ext import build_ext
@@ -486,7 +500,7 @@ def finalize_options(self, build_ext):
486500
found_mfc = False
487501
for incl in os.environ.get("INCLUDE", "").split(os.pathsep):
488502
# first is a "standard" MSVC install, second is the Vista SDK.
489-
for candidate in ("..\src\occimpl.h", "..\..\src\mfc\occimpl.h"):
503+
for candidate in (r"..\src\occimpl.h", r"..\..\src\mfc\occimpl.h"):
490504
check = os.path.join(incl, candidate)
491505
if os.path.isfile(check):
492506
self.extra_compile_args.append('/DMFC_OCC_IMPL_H=\\"%s\\"' % candidate)
@@ -1036,57 +1050,54 @@ def build_extensions(self):
10361050
self.copy_file(
10371051
os.path.join(self.build_temp, fname), target_dir)
10381052
# The MFC DLLs.
1039-
try:
1040-
target_dir = os.path.join(self.build_lib, "pythonwin")
1041-
if sys.hexversion < 0x2060000:
1042-
# hrm - there doesn't seem to be a 'redist' directory for this
1043-
# compiler (even the installation CDs only seem to have the MFC
1044-
# DLLs in the "win\system" directory - just grab it from
1045-
# system32 (but we can't even use win32api for that!)
1046-
src = os.path.join(os.environ.get('SystemRoot'), 'System32', 'mfc71.dll')
1047-
if not os.path.isfile(src):
1048-
raise RuntimeError("Can't find %r" % (src,))
1049-
self.copy_file(src, target_dir)
1053+
target_dir = os.path.join(self.build_lib, "pythonwin")
1054+
if sys.hexversion < 0x2060000:
1055+
# hrm - there doesn't seem to be a 'redist' directory for this
1056+
# compiler (even the installation CDs only seem to have the MFC
1057+
# DLLs in the "win\system" directory - just grab it from
1058+
# system32 (but we can't even use win32api for that!)
1059+
src = os.path.join(os.environ.get('SystemRoot'), 'System32', 'mfc71.dll')
1060+
if not os.path.isfile(src):
1061+
raise RuntimeError("Can't find %r" % (src,))
1062+
self.copy_file(src, target_dir)
1063+
else:
1064+
plat_dir_64 = "x64"
1065+
# 2.6, 2.7, 3.0, 3.1 and 3.2 all use(d) vs2008 (compiler version 1500)
1066+
if sys.hexversion < 0x3030000:
1067+
product_key = r"SOFTWARE\Microsoft\VisualStudio\9.0\Setup\VC"
1068+
plat_dir_64 = "amd64"
1069+
mfc_dir = "Microsoft.VC90.MFC"
1070+
mfc_files = "mfc90.dll mfc90u.dll mfcm90.dll mfcm90u.dll Microsoft.VC90.MFC.manifest".split()
1071+
# 3.3 and 3.4 use(d) vs2010 (compiler version 1600, crt=10)
1072+
elif sys.hexversion < 0x3050000:
1073+
product_key = r"SOFTWARE\Microsoft\VisualStudio\10.0\Setup\VC"
1074+
mfc_dir = "Microsoft.VC100.MFC"
1075+
mfc_files = ["mfc100u.dll", "mfcm100u.dll"]
1076+
# 3.5 and later on vs2015 (compiler version 1900, crt=14)
10501077
else:
1051-
plat_dir_64 = "x64"
1052-
# 2.6, 2.7, 3.0, 3.1 and 3.2 all use(d) vs2008 (compiler version 1500)
1053-
if sys.hexversion < 0x3030000:
1054-
product_key = r"SOFTWARE\Microsoft\VisualStudio\9.0\Setup\VC"
1055-
plat_dir_64 = "amd64"
1056-
mfc_dir = "Microsoft.VC90.MFC"
1057-
mfc_files = "mfc90.dll mfc90u.dll mfcm90.dll mfcm90u.dll Microsoft.VC90.MFC.manifest".split()
1058-
# 3.3 and 3.4 use(d) vs2010 (compiler version 1600, crt=10)
1059-
elif sys.hexversion < 0x3050000:
1060-
product_key = r"SOFTWARE\Microsoft\VisualStudio\10.0\Setup\VC"
1061-
mfc_dir = "Microsoft.VC100.MFC"
1062-
mfc_files = ["mfc100u.dll", "mfcm100u.dll"]
1063-
# 3.5 and later on vs2015 (compiler version 1900, crt=14)
1064-
else:
1065-
product_key = r"SOFTWARE\Microsoft\VisualStudio\14.0\Setup\VC"
1066-
mfc_dir = "Microsoft.VC140.MFC"
1067-
mfc_files = ["mfc140u.dll", "mfcm140u.dll"]
1068-
1069-
# On a 64bit host, the value we are looking for is actually in
1070-
# SysWow64Node - but that is only available on xp and later.
1071-
access = _winreg.KEY_READ
1072-
if sys.getwindowsversion()[0] >= 5:
1073-
access = access | 512 # KEY_WOW64_32KEY
1074-
if self.plat_name == 'win-amd64':
1075-
plat_dir = plat_dir_64
1076-
else:
1077-
plat_dir = "x86"
1078-
# Find the redist directory.
1079-
vckey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, product_key,
1080-
0, access)
1081-
val, val_typ = _winreg.QueryValueEx(vckey, "ProductDir")
1082-
mfc_dir = os.path.join(val, "redist", plat_dir, mfc_dir)
1083-
if not os.path.isdir(mfc_dir):
1084-
raise RuntimeError("Can't find the redist dir at %r" % (mfc_dir))
1085-
for f in mfc_files:
1086-
self.copy_file(
1087-
os.path.join(mfc_dir, f), target_dir)
1088-
except (EnvironmentError, RuntimeError), exc:
1089-
print "Can't find an installed VC for the MFC DLLs:", exc
1078+
product_key = r"SOFTWARE\Microsoft\VisualStudio\14.0\Setup\VC"
1079+
mfc_dir = "Microsoft.VC140.MFC"
1080+
mfc_files = ["mfc140u.dll", "mfcm140u.dll"]
1081+
1082+
# On a 64bit host, the value we are looking for is actually in
1083+
# SysWow64Node - but that is only available on xp and later.
1084+
access = _winreg.KEY_READ
1085+
if sys.getwindowsversion()[0] >= 5:
1086+
access = access | 512 # KEY_WOW64_32KEY
1087+
if self.plat_name == 'win-amd64':
1088+
plat_dir = plat_dir_64
1089+
else:
1090+
plat_dir = "x86"
1091+
# Find the redist directory.
1092+
vckey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, product_key,
1093+
0, access)
1094+
val, val_typ = _winreg.QueryValueEx(vckey, "ProductDir")
1095+
mfc_dir = os.path.join(val, "redist", plat_dir, mfc_dir)
1096+
if not os.path.isdir(mfc_dir):
1097+
raise RuntimeError("Can't find the redist dir at %r" % (mfc_dir))
1098+
for f in mfc_files:
1099+
shutil.copyfile(
1100+
os.path.join(mfc_dir, f), os.path.join(target_dir, f))
10901101

10911102

10921103
def build_exefile(self, ext):
@@ -2507,7 +2518,7 @@ def convert_optional_data_files(files):
25072518
"ability to create and use COM objects, and the\n"
25082519
"Pythonwin environment.",
25092520
author="Mark Hammond (et al)",
2510-
author_email = "mhammond@users.sourceforge.net",
2521+
author_email = "mhammond@skippinet.com.au",
25112522
url="https://github.com/mhammond/pywin32",
25122523
license="PSF",
25132524
cmdclass = cmdclass,

0 commit comments

Comments
 (0)