Skip to content

Commit 72f2ef4

Browse files
committed
Issue python#26268: Merge with 3.5
2 parents fe93283 + 6fe57ad commit 72f2ef4

File tree

8 files changed

+74
-122
lines changed

8 files changed

+74
-122
lines changed

Misc/NEWS

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,11 +751,17 @@ Build
751751
Previously it could fail to compile properly if the math and cmath builds
752752
were concurrent.
753753

754-
- Issue #26268: Update OS X 10.5 installer to use OpenSSL 1.0.2f.
754+
- Issue #26268: Update OS X 10.5 installer and Windows builds to use
755+
OpenSSL 1.0.2f.
756+
755757

756758
Windows
757759
-------
758760

761+
- Issue #26268: Update the prepare_ssl.py script to handle OpenSSL releases
762+
that don't include the contents of the include directory (that is, 1.0.2e
763+
and later).
764+
759765
- Issue #26071: bdist_wininst created binaries fail to start and find
760766
32bit Python
761767

PCbuild/_hashlib.vcxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
</PropertyGroup>
6262
<ItemDefinitionGroup>
6363
<ClCompile>
64-
<AdditionalIncludeDirectories>$(opensslDir)include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
64+
<AdditionalIncludeDirectories>$(opensslIncludeDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
6565
</ClCompile>
6666
<Link>
6767
<AdditionalDependencies>ws2_32.lib;$(OutDir)libeay$(PyDebugExt).lib;$(OutDir)ssleay$(PyDebugExt).lib;%(AdditionalDependencies)</AdditionalDependencies>
@@ -87,4 +87,4 @@
8787
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
8888
<ImportGroup Label="ExtensionTargets">
8989
</ImportGroup>
90-
</Project>
90+
</Project>

PCbuild/_ssl.vcxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
</PropertyGroup>
6262
<ItemDefinitionGroup>
6363
<ClCompile>
64-
<AdditionalIncludeDirectories>$(opensslDir)include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
64+
<AdditionalIncludeDirectories>$(opensslIncludeDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
6565
</ClCompile>
6666
<Link>
6767
<AdditionalDependencies>ws2_32.lib;crypt32.lib;$(OutDir)libeay$(PyDebugExt).lib;$(OutDir)ssleay$(PyDebugExt).lib;%(AdditionalDependencies)</AdditionalDependencies>
@@ -91,4 +91,4 @@
9191
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
9292
<ImportGroup Label="ExtensionTargets">
9393
</ImportGroup>
94-
</Project>
94+
</Project>

PCbuild/get_externals.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ echo.Fetching external libraries...
5454
set libraries=
5555
set libraries=%libraries% bzip2-1.0.6
5656
if NOT "%IncludeSSL%"=="false" set libraries=%libraries% nasm-2.11.06
57-
if NOT "%IncludeSSL%"=="false" set libraries=%libraries% openssl-1.0.2d
57+
if NOT "%IncludeSSL%"=="false" set libraries=%libraries% openssl-1.0.2f
5858
set libraries=%libraries% sqlite-3.8.11.0
5959
if NOT "%IncludeTkinter%"=="false" set libraries=%libraries% tcl-core-8.6.4.2
6060
if NOT "%IncludeTkinter%"=="false" set libraries=%libraries% tk-8.6.4.2

PCbuild/openssl.props

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@
1717
<PreprocessorDefinitions Include="_CRT_SECURE_NO_WARNINGS" />
1818
<PreprocessorDefinitions Include="_CRT_SECURE_NO_DEPRECATE" />
1919
<PreprocessorDefinitions Include="OPENSSL_THREADS" />
20-
<PreprocessorDefinitions Include="OPENSSL_SYSNAME_WIN32" />
20+
<!-- <PreprocessorDefinitions Include="OPENSSL_SYSNAME_WIN32" /> -->
2121
<PreprocessorDefinitions Include="OPENSSL_IA32_SSE2" />
22-
<PreprocessorDefinitions Include="OPENSSL_CPUID_OBJ" />
2322
<PreprocessorDefinitions Include="SHA1_ASM" />
2423
<PreprocessorDefinitions Include="SHA256_ASM" />
2524
<PreprocessorDefinitions Include="SHA512_ASM" />
@@ -53,7 +52,7 @@
5352
<ClCompile>
5453
<!-- Suppress 64-bit truncation warnings - they aren't ours to worry about -->
5554
<DisableSpecificWarnings>4244;4267</DisableSpecificWarnings>
56-
<AdditionalIncludeDirectories>$(opensslDir);$(opensslDir)include;$(opensslDir)crypto;$(opensslDir)crypto\asn1;$(opensslDir)crypto\evp;$(opensslDir)crypto\modes</AdditionalIncludeDirectories>
55+
<AdditionalIncludeDirectories>$(opensslDir);$(opensslIncludeDir);$(opensslDir)crypto;$(opensslDir)crypto\asn1;$(opensslDir)crypto\evp;$(opensslDir)crypto\modes</AdditionalIncludeDirectories>
5756
<PreprocessorDefinitions>$(_PreprocessorDefinitionList);%(PreprocessorDefinitions)</PreprocessorDefinitions>
5857
</ClCompile>
5958
</ItemDefinitionGroup>
@@ -74,4 +73,4 @@ $(nasm) -o "$(IntDir)%(NasmCompile.Filename).obj" "%(NasmCompile.FullPath)"' />
7473
<Lib Include="$(IntDir)%(NasmCompile.Filename).obj" />
7574
</ItemGroup>
7675
</Target>
77-
</Project>
76+
</Project>

PCbuild/prepare_ssl.py

Lines changed: 55 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
import os
2222
import re
2323
import sys
24-
import shutil
2524
import subprocess
25+
from shutil import copy
2626

2727
# Find all "foo.exe" files on the PATH.
28-
def find_all_on_path(filename, extras = None):
28+
def find_all_on_path(filename, extras=None):
2929
entries = os.environ["PATH"].split(os.pathsep)
3030
ret = []
3131
for p in entries:
@@ -39,6 +39,7 @@ def find_all_on_path(filename, extras = None):
3939
ret.append(fname)
4040
return ret
4141

42+
4243
# Find a suitable Perl installation for OpenSSL.
4344
# cygwin perl does *not* work. ActivePerl does.
4445
# Being a Perl dummy, the simplest way I can check is if the "Win32" package
@@ -61,144 +62,85 @@ def find_working_perl(perls):
6162
print("NO perl interpreters were found on this machine at all!")
6263
print(" Please install ActivePerl and ensure it appears on your path")
6364

64-
def create_makefile64(makefile, m32):
65-
"""Create and fix makefile for 64bit
66-
67-
Replace 32 with 64bit directories
68-
"""
69-
if not os.path.isfile(m32):
70-
return
71-
with open(m32) as fin:
72-
with open(makefile, 'w') as fout:
73-
for line in fin:
74-
line = line.replace("=tmp32", "=tmp64")
75-
line = line.replace("=out32", "=out64")
76-
line = line.replace("=inc32", "=inc64")
77-
# force 64 bit machine
78-
line = line.replace("MKLIB=lib", "MKLIB=lib /MACHINE:X64")
79-
line = line.replace("LFLAGS=", "LFLAGS=/MACHINE:X64 ")
80-
# don't link against the lib on 64bit systems
81-
line = line.replace("bufferoverflowu.lib", "")
82-
fout.write(line)
83-
os.unlink(m32)
84-
85-
def create_asms(makefile):
65+
66+
def create_asms(makefile, tmp_d):
8667
#create a custom makefile out of the provided one
8768
asm_makefile = os.path.splitext(makefile)[0] + '.asm.mak'
88-
with open(makefile) as fin:
89-
with open(asm_makefile, 'w') as fout:
90-
for line in fin:
91-
# Keep everything up to the install target (it's convenient)
92-
if line.startswith('install: all'):
93-
break
94-
else:
69+
with open(makefile) as fin, open(asm_makefile, 'w') as fout:
70+
for line in fin:
71+
# Keep everything up to the install target (it's convenient)
72+
if line.startswith('install: all'):
73+
break
74+
fout.write(line)
75+
asms = []
76+
for line in fin:
77+
if '.asm' in line and line.strip().endswith('.pl'):
78+
asms.append(line.split(':')[0])
79+
while line.strip():
9580
fout.write(line)
96-
asms = []
97-
for line in fin:
98-
if '.asm' in line and line.strip().endswith('.pl'):
99-
asms.append(line.split(':')[0])
100-
while line.strip():
101-
fout.write(line)
102-
line = next(fin)
103-
fout.write('\n')
81+
line = next(fin)
82+
fout.write('\n')
10483

105-
fout.write('asms: $(TMP_D) ')
106-
fout.write(' '.join(asms))
107-
fout.write('\n')
84+
fout.write('asms: $(TMP_D) ')
85+
fout.write(' '.join(asms))
86+
fout.write('\n')
87+
os.system('nmake /f {} PERL=perl TMP_D={} asms'.format(asm_makefile, tmp_d))
10888

109-
os.system('nmake /f {} PERL=perl asms'.format(asm_makefile))
110-
os.unlink(asm_makefile)
11189

112-
113-
114-
def fix_makefile(makefile):
115-
"""Fix some stuff in all makefiles
116-
"""
117-
if not os.path.isfile(makefile):
118-
return
90+
def copy_includes(makefile, suffix):
91+
dir = 'include'+suffix+'\\openssl'
92+
os.makedirs(dir, exist_ok=True)
11993
copy_if_different = r'$(PERL) $(SRC_D)\util\copy-if-different.pl'
12094
with open(makefile) as fin:
121-
lines = fin.readlines()
122-
with open(makefile, 'w') as fout:
123-
for line in lines:
124-
if line.startswith("PERL="):
125-
continue
126-
if line.startswith("CP="):
127-
line = "CP=copy\n"
128-
if line.startswith("MKDIR="):
129-
line = "MKDIR=mkdir\n"
130-
if line.startswith("CFLAG="):
131-
line = line.strip()
132-
for algo in ("RC5", "MDC2", "IDEA"):
133-
noalgo = " -DOPENSSL_NO_%s" % algo
134-
if noalgo not in line:
135-
line = line + noalgo
136-
line = line + '\n'
95+
for line in fin:
13796
if copy_if_different in line:
138-
line = line.replace(copy_if_different, 'copy /Y')
139-
fout.write(line)
97+
perl, script, src, dest = line.split()
98+
if not '$(INCO_D)' in dest:
99+
continue
100+
# We're in the root of the source tree
101+
src = src.replace('$(SRC_D)', '.').strip('"')
102+
dest = dest.strip('"').replace('$(INCO_D)', dir)
103+
print('copying', src, 'to', dest)
104+
copy(src, dest)
105+
140106

141107
def run_configure(configure, do_script):
142108
print("perl Configure "+configure+" no-idea no-mdc2")
143109
os.system("perl Configure "+configure+" no-idea no-mdc2")
144110
print(do_script)
145111
os.system(do_script)
146112

147-
def cmp(f1, f2):
148-
bufsize = 1024 * 8
149-
with open(f1, 'rb') as fp1, open(f2, 'rb') as fp2:
150-
while True:
151-
b1 = fp1.read(bufsize)
152-
b2 = fp2.read(bufsize)
153-
if b1 != b2:
154-
return False
155-
if not b1:
156-
return True
157-
158-
def copy(src, dst):
159-
if os.path.isfile(dst) and cmp(src, dst):
160-
return
161-
shutil.copy(src, dst)
162113

163114
def prep(arch):
115+
makefile_template = "ms\\nt{}.mak"
116+
generated_makefile = makefile_template.format('')
164117
if arch == "x86":
165118
configure = "VC-WIN32"
166119
do_script = "ms\\do_nasm"
167-
makefile="ms\\nt.mak"
168-
m32 = makefile
169-
dirsuffix = "32"
120+
suffix = "32"
170121
elif arch == "amd64":
171122
configure = "VC-WIN64A"
172123
do_script = "ms\\do_win64a"
173-
makefile = "ms\\nt64.mak"
174-
m32 = makefile.replace('64', '')
175-
dirsuffix = "64"
124+
suffix = "64"
176125
#os.environ["VSEXTCOMP_USECL"] = "MS_OPTERON"
177126
else:
178127
raise ValueError('Unrecognized platform: %s' % arch)
179128

180-
# rebuild makefile when we do the role over from 32 to 64 build
181-
if arch == "amd64" and os.path.isfile(m32) and not os.path.isfile(makefile):
182-
os.unlink(m32)
183-
184-
# If the ssl makefiles do not exist, we invoke Perl to generate them.
185-
# Due to a bug in this script, the makefile sometimes ended up empty
186-
# Force a regeneration if it is.
187-
if not os.path.isfile(makefile) or os.path.getsize(makefile)==0:
188-
print("Creating the makefiles...")
189-
sys.stdout.flush()
190-
run_configure(configure, do_script)
191-
192-
if arch == "amd64":
193-
create_makefile64(makefile, m32)
194-
fix_makefile(makefile)
195-
copy(r"crypto\buildinf.h", r"crypto\buildinf_%s.h" % arch)
196-
copy(r"crypto\opensslconf.h", r"crypto\opensslconf_%s.h" % arch)
197-
else:
198-
print(makefile, 'already exists!')
129+
print("Creating the makefiles...")
130+
sys.stdout.flush()
131+
# run configure, copy includes, create asms
132+
run_configure(configure, do_script)
133+
makefile = makefile_template.format(suffix)
134+
try:
135+
os.unlink(makefile)
136+
except FileNotFoundError:
137+
pass
138+
os.rename(generated_makefile, makefile)
139+
copy_includes(makefile, suffix)
199140

200141
print('creating asms...')
201-
create_asms(makefile)
142+
create_asms(makefile, 'tmp'+suffix)
143+
202144

203145
def main():
204146
if len(sys.argv) == 1:
@@ -229,6 +171,9 @@ def main():
229171
print("Found a working perl at '%s'" % (perl,))
230172
else:
231173
sys.exit(1)
174+
if not find_all_on_path('nmake.exe'):
175+
print('Could not find nmake.exe, try running env.bat')
176+
sys.exit(1)
232177
sys.stdout.flush()
233178

234179
# Put our working Perl at the front of our path

PCbuild/python.props

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@
4141
<sqlite3Dir>$(ExternalsDir)sqlite-3.8.11.0\</sqlite3Dir>
4242
<bz2Dir>$(ExternalsDir)bzip2-1.0.6\</bz2Dir>
4343
<lzmaDir>$(ExternalsDir)xz-5.0.5\</lzmaDir>
44-
<opensslDir>$(ExternalsDir)openssl-1.0.2d\</opensslDir>
44+
<opensslDir>$(ExternalsDir)openssl-1.0.2f\</opensslDir>
45+
<opensslIncludeDir>$(opensslDir)include32</opensslIncludeDir>
46+
<opensslIncludeDir Condition="'$(ArchName)' == 'amd64'">$(opensslDir)include64</opensslIncludeDir>
4547
<nasmDir>$(ExternalsDir)\nasm-2.11.06\</nasmDir>
4648

4749
<!-- Suffix for all binaries when building for debug -->

PCbuild/readme.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ _lzma
169169
Homepage:
170170
http://tukaani.org/xz/
171171
_ssl
172-
Python wrapper for version 1.0.2d of the OpenSSL secure sockets
172+
Python wrapper for version 1.0.2f of the OpenSSL secure sockets
173173
library, which is built by ssl.vcxproj
174174
Homepage:
175175
http://www.openssl.org/

0 commit comments

Comments
 (0)