Skip to content

Commit 4d68cea

Browse files
committed
replace winpython legacy code per msvc-runtime wheel
1 parent 2d88b2d commit 4d68cea

File tree

5 files changed

+46
-232
lines changed

5 files changed

+46
-232
lines changed

generate_a_winpython_distro.bat

+23-4
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ set my_buildenv=C:\WinPython-64bit-3.6.8.0
3535

3636
rem handle alpha
3737
if "%my_release_level%"=="" set my_release_level=
38-
rem if %my_python_target%==38 set my_release_level=b1
3938

4039
rem ---------
4140
rem newAge 20191022
@@ -45,10 +44,10 @@ rem --------
4544

4645
if %my_python_target%==37 (
4746
set my_python_target_release=377
48-
set my_release=0
47+
set my_release=1
4948
)
5049
if %my_python_target%==38 (
51-
set my_python_target_release=382
50+
set my_python_target_release=384
5251
set my_release=0
5352
)
5453
if %my_python_target%==39 (
@@ -172,16 +171,36 @@ set path=%my_original_path%
172171
set my_WINPYDIRBASE=%my_root_dir_for_builds%\bd%my_python_target%\bu%my_flavor%\Wpy%my_arch%-%my_python_target_release%%my_release%%my_release_level%
173172

174173
set WINPYDIRBASE=%my_WINPYDIRBASE%
174+
175+
rem D/2020-07-04: poka-yoke
176+
if not exist %my_WINPYDIRBASE%\scripts\env.bat (
177+
echo please check and correct my_python_target_release=%my_python_target_release%
178+
echo in generate_a_winpython_distro.bat
179+
echo as %my_WINPYDIRBASE%\scripts\env.bat doesnt exist
180+
pause
181+
exit
182+
)
183+
rem F/2020-07-04: poka-yoke
184+
175185
call %my_WINPYDIRBASE%\scripts\env.bat
176186
set
177187
echo beg of step 2/3
178188
rem ok no pause
179189

190+
rem D/2020-07-05: install msvc_runtime before packages that may want to compile
191+
echo pip install msvc_runtime --pre --no-index --trusted-host=None --find-links=C:\WinP\packages.srcreq --upgrade
192+
echo pip install msvc_runtime --pre --no-index --trusted-host=None --find-links=C:\WinP\packages.srcreq --upgrade>>%my_archive_log%
193+
pip install msvc_runtime --pre --no-index --trusted-host=None --find-links=C:\WinP\packages.srcreq --upgrade
194+
rem F/2020-07-05: install msvc_runtime before packages that may want to compile
195+
180196
echo pip install -r %my_requirements% --pre --no-index --trusted-host=None --find-links=C:\WinP\packages.srcreq --upgrade
181197
echo pip install -r %my_requirements% --pre --no-index --trusted-host=None --find-links=C:\WinP\packages.srcreq --upgrade>>%my_archive_log%
198+
199+
echo if pip doesn't work, check the path of %my_WINPYDIRBASE%
200+
182201
pip install -r %my_requirements% --pre --no-index --trusted-host=None --find-links=C:\WinP\packages.srcreq --upgrade >>%my_archive_log%
183202
echo mid of step 2/3
184-
rem pause
203+
185204

186205
rem finalize
187206
@echo on

make.py

+1-13
Original file line numberDiff line numberDiff line change
@@ -782,18 +782,6 @@ def _extract_python(self):
782782
)
783783
self._print_done()
784784

785-
def _add_msvc_files(self):
786-
"""Adding Microsoft Visual C++ DLLs"""
787-
print("Adding Microsoft Visual C++ DLLs" "")
788-
msvc_version = dh.get_msvc_version(
789-
self.distribution.version
790-
)
791-
for fname in dh.get_msvc_dlls(
792-
msvc_version,
793-
architecture=self.distribution.architecture,
794-
):
795-
shutil.copy(fname, self.python_dir)
796-
797785
def _copy_dev_tools(self):
798786
"""Copy dev tools"""
799787
self._print("Copying tools")
@@ -1945,7 +1933,7 @@ def make(
19451933

19461934
if remove_existing:
19471935
if not self.simulation:
1948-
self._add_msvc_files()
1936+
# self._add_msvc_files() # replaced per msvc_runtime package
19491937
self._create_batch_scripts_initial()
19501938
self._create_batch_scripts()
19511939
# always create all launchers (as long as it is NSIS-based)

run_complement_newbuild.bat

+19
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ call scripts\env.bat
1919
@echo off
2020

2121

22+
rem * ===========================
23+
rem 2020-05-15 patch jedi-0.17.0
24+
rem * ===========================
25+
rem see https://github.com/davidhalter/jedi/commit/f871f5e726f796127d4cfb981726b494f056ebe9
26+
rem as it fixes https://github.com/davidhalter/jedi/issues/1548 Use the `project` variable before setting the default value.
27+
rem if exist "%WINPYDIR%\Lib\site-packages\jedi-0.17.0.dist-info" copy/Y "C:\WinP\tempo_fixes\Jedi-0.17.0\api\__init__.py" "%WINPYDIR%\Lib\site-packages\Jedi-0.17.0\api\__init__.py"
28+
29+
2230
rem * ==========================
2331
rem * When Python has no mingwpy
2432
rem * ==========================
@@ -46,6 +54,9 @@ rem * ===========================
4654
echo finish install of jupyterlab
4755
rem * ===========================
4856

57+
rem 2020-04-10 security
58+
rem if exist "%WINPYDIR%\Lib\site-packages\jupyterlab" "%WINPYDIR%\..\n\npm" config set ignore-scripts true
59+
4960
rem other suggestion from https://github.com/nteract/nteract
5061
rem npm install -g --production windows-build-tools
5162

@@ -295,6 +306,8 @@ if exist "%WINPYDIR%\Lib\site-packages\jupyterlab" (
295306
jupyter labextension list
296307
)
297308

309+
rem jupyter labextension update --all (will rebuild if needed)
310+
298311
rem 2018-01-15 node-gyp experience
299312
rem npm config set python "C:\WinPython\bd27\buildZero\winpython-32bit-2.7.x.2\python-2.7.13"
300313
rem npm config delete python
@@ -339,6 +352,12 @@ echo patch spyder update reflex (2019-05-18 : spyder, not spyderlib !)
339352
rem * ====================
340353
%WINPYDIR%\python.exe -c "from winpython.utils import patch_sourcefile;patch_sourcefile(r'%WINPYDIR%\Lib\site-packages\spyder\config\main.py', ' '+chr(39)+'check_updates_on_startup'+chr(39)+': True', ' '+chr(39)+'check_updates_on_startup'+chr(39)+': False' )"
341354

355+
rem * ====================
356+
echo summary 20202-04-11
357+
rem * ====================
358+
pip check
359+
if exist "%WINPYDIR%\Lib\site-packages\pipdeptree" pipdeptree
360+
342361

343362
@echo on
344363
goto the_end

winpython/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@
2828
OTHER DEALINGS IN THE SOFTWARE.
2929
"""
3030

31-
__version__ = '2.4.20200425'
31+
__version__ = '3.0.20200705'
3232
__license__ = __doc__
3333
__project_url__ = 'http://winpython.github.io/'

winpython/disthelpers.py

+2-214
Original file line numberDiff line numberDiff line change
@@ -122,219 +122,6 @@ def try_to_remove(fname):
122122
atexit.register(try_to_remove, osp.abspath(fname))
123123

124124

125-
def get_msvc_version(python_version):
126-
"""Return Microsoft Visual C++ version used to build this Python version"""
127-
if python_version is None:
128-
python_version = '2.7'
129-
warnings.warn("assuming Python 2.7 target")
130-
if python_version in (
131-
'2.6',
132-
'2.7',
133-
'3.0',
134-
'3.1',
135-
'3.2',
136-
):
137-
# Python 2.6-2.7, 3.0-3.2 were built with Visual Studio 9.0.21022.8
138-
# (i.e. Visual C++ 2008, not Visual C++ 2008 SP1!)
139-
return "9.0.21022.8"
140-
elif python_version in ('3.3', '3.4'):
141-
# Python 3.3+ were built with Visual Studio 10.0.30319.1
142-
# (i.e. Visual C++ 2010)
143-
return '10.0'
144-
elif python_version in ('3.5', '3.6'):
145-
return '15.0'
146-
elif python_version in ('3.7', '3.8'):
147-
return '15.0'
148-
elif StrictVersion(python_version) >= StrictVersion('3.9'):
149-
return '15.0'
150-
else:
151-
raise RuntimeError(
152-
"Unsupported Python version %s" % python_version
153-
)
154-
155-
156-
def get_msvc_dlls(msvc_version, architecture=None):
157-
"""Get the list of Microsoft Visual C++ DLLs associated to
158-
architecture and Python version, create the manifest file.
159-
160-
architecture: integer (32 or 64) -- if None, take the Python build arch
161-
python_version: X.Y"""
162-
current_architecture = (
163-
64 if sys.maxsize > 2 ** 32 else 32
164-
)
165-
if architecture is None:
166-
architecture = current_architecture
167-
filelist = []
168-
169-
# simple vs2015 situation: nothing (system dll)
170-
if msvc_version == '14.0':
171-
return filelist
172-
msvc_major = msvc_version.split('.')[0]
173-
msvc_minor = msvc_version.split('.')[1]
174-
175-
if msvc_major == '9':
176-
key = "1fc8b3b9a1e18e3b"
177-
atype = "" if architecture == 64 else "win32"
178-
arch = "amd64" if architecture == 64 else "x86"
179-
180-
groups = {
181-
'CRT': (
182-
'msvcr90.dll',
183-
'msvcp90.dll',
184-
'msvcm90.dll',
185-
),
186-
# 'OPENMP': ('vcomp90.dll',)
187-
}
188-
189-
for group, dll_list in groups.items():
190-
dlls = ''
191-
for dll in dll_list:
192-
dlls += ' <file name="%s" />%s' % (
193-
dll,
194-
os.linesep,
195-
)
196-
manifest = """<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
197-
<!-- Copyright (c) Microsoft Corporation. All rights reserved. -->
198-
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
199-
<noInheritable/>
200-
<assemblyIdentity
201-
type="%(atype)s"
202-
name="Microsoft.VC90.%(group)s"
203-
version="%(version)s"
204-
processorArchitecture="%(arch)s"
205-
publicKeyToken="%(key)s"
206-
/>
207-
%(dlls)s</assembly>
208-
""" % dict(
209-
version=msvc_version,
210-
key=key,
211-
atype=atype,
212-
arch=arch,
213-
group=group,
214-
dlls=dlls,
215-
)
216-
217-
vc90man = "Microsoft.VC90.%s.manifest" % group
218-
open(vc90man, 'w').write(manifest)
219-
_remove_later(vc90man)
220-
filelist += [vc90man]
221-
222-
winsxs = osp.join(
223-
os.environ['windir'], 'WinSxS'
224-
)
225-
vcstr = '%s_Microsoft.VC90.%s_%s_%s' % (
226-
arch,
227-
group,
228-
key,
229-
msvc_version,
230-
)
231-
for fname in os.listdir(winsxs):
232-
path = osp.join(winsxs, fname)
233-
if osp.isdir(
234-
path
235-
) and fname.lower().startswith(
236-
vcstr.lower()
237-
):
238-
for dllname in os.listdir(path):
239-
filelist.append(
240-
osp.join(path, dllname)
241-
)
242-
break
243-
else:
244-
raise RuntimeError(
245-
"Microsoft Visual C++ %s DLLs version %s "
246-
"were not found" % (group, msvc_version)
247-
)
248-
elif (
249-
msvc_major == '10' or msvc_major == '15'
250-
): # 15 for vs 2015
251-
namelist = [
252-
name % (msvc_major + msvc_minor)
253-
for name in (
254-
'msvcp%s.dll',
255-
'msvcr%s.dll',
256-
'vcomp%s.dll',
257-
)
258-
]
259-
if msvc_major == '15' and architecture == 64:
260-
namelist = [
261-
name % ('14' + msvc_minor)
262-
for name in (
263-
'vcruntime%s.dll',
264-
'vcruntime%s_1.dll',
265-
'msvcp%s.dll',
266-
'vccorlib%s.dll',
267-
'concrt%s.dll',
268-
'vcomp%s.dll',
269-
)
270-
]
271-
if msvc_major == '15' and architecture != 64:
272-
namelist = [
273-
name % ('14' + msvc_minor)
274-
for name in (
275-
'vcruntime%s.dll',
276-
'msvcp%s.dll',
277-
'vccorlib%s.dll',
278-
'concrt%s.dll',
279-
'vcomp%s.dll',
280-
)
281-
]
282-
windir = os.environ['windir']
283-
is_64bit_windows = osp.isdir(
284-
osp.join(windir, "SysWOW64")
285-
)
286-
287-
# Reminder: WoW64 (*W*indows 32-bit *o*n *W*indows *64*-bit) is a
288-
# subsystem of the Windows operating system capable of running 32-bit
289-
# applications and is included on all 64-bit versions of Windows
290-
# (source: http://en.wikipedia.org/wiki/WoW64)
291-
#
292-
# In other words, "SysWOW64" contains 64-bit DLL and applications,
293-
# whereas "System32" contains 64-bit DLL and applications on a 64-bit
294-
# system.
295-
sysdir = "System32"
296-
if not is_64bit_windows and architecture == 64:
297-
raise RuntimeError(
298-
"Can't find 64-bit MSVC DLLs on a 32-bit OS"
299-
)
300-
if is_64bit_windows and architecture == 32:
301-
sysdir = "SysWOW64"
302-
for dllname in namelist:
303-
fname = osp.join(windir, sysdir, dllname)
304-
print('searching', fname)
305-
if osp.exists(fname):
306-
filelist.append(fname)
307-
else:
308-
raise RuntimeError(
309-
"Microsoft Visual C++ DLLs version %s "
310-
"were not found" % msvc_version
311-
)
312-
else:
313-
raise RuntimeError(
314-
"Unsupported MSVC version %s" % msvc_version
315-
)
316-
return filelist
317-
318-
319-
def create_msvc_data_files(
320-
architecture=None, python_version=None, verbose=False
321-
):
322-
"""Including Microsoft Visual C++ DLLs"""
323-
msvc_version = get_msvc_version(python_version)
324-
filelist = get_msvc_dlls(
325-
msvc_version, architecture=architecture
326-
)
327-
print(create_msvc_data_files.__doc__)
328-
if verbose:
329-
for name in filelist:
330-
print(" ", name)
331-
msvc_major = msvc_version.split('.')[0]
332-
if msvc_major == '9':
333-
return [("Microsoft.VC90.CRT", filelist)]
334-
else:
335-
return [("", filelist)]
336-
337-
338125
def to_include_files(data_files):
339126
"""Convert data_files list to include_files list
340127
@@ -509,7 +296,8 @@ def setup(
509296
self.msvc = msvc
510297
if self.msvc:
511298
try:
512-
self.data_files += create_msvc_data_files()
299+
pass # manage via msvc_runtime wheel (or give up anyway)
300+
# self.data_files += create_msvc_data_files()
513301
except IOError:
514302
print(
515303
"Setting the msvc option to False "

0 commit comments

Comments
 (0)