Skip to content

Commit 0bf2731

Browse files
author
stonebig
committed
cleanups
1 parent ac1f526 commit 0bf2731

File tree

4 files changed

+21
-65
lines changed

4 files changed

+21
-65
lines changed

make.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ def _install_required_packages(self):
456456
'PyQt5-([0-9\.\-]*)-gpl-Py%s-Qt([0-9\.\-]*)%s.exe'
457457
% (self.python_version, self.pyqt_arch))
458458
# Install 'critical' packages first
459-
for happy_few in['setuptools', 'pip', 'pywin32']:
459+
for happy_few in['setuptools', 'pip']:
460460
self.install_package(
461461
'%s-([0-9\.]*[a-z\+]*[0-9]?)(.*)(\.exe|\.whl)' % happy_few,
462462
install_options=self.install_options+['--upgrade'])
@@ -773,7 +773,7 @@ def make(self, remove_existing=True):
773773
self._copy_dev_docs()
774774
if not self.simulation:
775775
self._run_complement_batch_scripts() # run_complement.bat
776-
self.distribution.patch_all_shebang()
776+
self.distribution.patch_standard_packages()
777777
# launchers at the very end
778778
self._create_launchers()
779779

winpython/disthelpers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ def get_msvc_version(python_version):
120120
# (i.e. Visual C++ 2010)
121121
return '10.0'
122122
elif python_version in ('3.5', '3.6'):
123-
return '15.0'
124-
else:
123+
return '15.0'
124+
else:
125125
raise RuntimeError("Unsupported Python version %s" % python_version)
126126

127127
def get_msvc_dlls(msvc_version, architecture=None):

winpython/utils.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -376,33 +376,6 @@ def patch_sourcelines(fname, in_line_start, out_line, endline='\n', silent_mode=
376376
"to", new_content)
377377

378378

379-
def patch_julia03():
380-
"""Ugly patch of Julia/ZMQ and Julia/Nettle to make them movable"""
381-
import io
382-
import os.path as osp
383-
out_line = '"' + os.path.dirname(os.environ["WINPYDIR"]).replace("\\", "\\\\")
384-
end_line = r"\\settings\\.julia"
385-
from winpython.utils import patch_sourcelines
386-
387-
in_line_start = '@checked_lib zmq '
388-
389-
fname = os.path.dirname(os.environ["WINPYDIR"]) + r"\settings\.julia\v0.3\ZMQ\deps\deps.jl";
390-
patch_sourcelines(fname, in_line_start, out_line, end_line)
391-
fname = os.path.dirname(os.environ["WINPYDIR"]) + r"\settings\.julia\v0.4\ZMQ\deps\deps.jl";
392-
patch_sourcelines(fname, in_line_start, out_line, end_line)
393-
fname = os.path.dirname(os.environ["WINPYDIR"]) + r"\settings\.julia\v0.5\ZMQ\deps\deps.jl";
394-
patch_sourcelines(fname, in_line_start, out_line, end_line)
395-
396-
in_line_start = '@checked_lib nettle ';
397-
398-
fname = os.path.dirname(os.environ["WINPYDIR"]) + r"\settings\.julia\v0.3\Nettle\deps\deps.jl";
399-
patch_sourcelines(fname, in_line_start, out_line, end_line)
400-
fname = os.path.dirname(os.environ["WINPYDIR"]) + r"\settings\.julia\v0.4\Nettle\deps\deps.jl";
401-
patch_sourcelines(fname, in_line_start, out_line, end_line)
402-
fname = os.path.dirname(os.environ["WINPYDIR"]) + r"\settings\.julia\v0.5\Nettle\deps\deps.jl";
403-
patch_sourcelines(fname, in_line_start, out_line, end_line)
404-
405-
406379
# =============================================================================
407380
# Extract functions
408381
# =============================================================================

winpython/wppm.py

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -394,54 +394,37 @@ def install(self, package, install_options=None):
394394
elif bname.endswith('.msi'):
395395
self.install_bdist_msi(package)
396396
self.handle_specific_packages(package)
397+
# minimal post-install actions
398+
self.patch_standard_packages(package.name)
397399
if not package.fname.endswith(('.whl', '.tar.gz', '.zip')):
398400
package.save_log(self.logdir)
399401
if tmp_fname is not None:
400402
os.remove(tmp_fname)
401403

402-
# We minimal post-install pywin (pywin32_postinstall.py do too much)
403-
if package.name == "pywin32":
404+
def patch_standard_packages(self, package_name=None):
405+
"""patch Winpython packages in need"""
406+
import filecmp
407+
# 'pywin32' minimal post-install (pywin32_postinstall.py do too much)
408+
if package_name == "pywin32" or package_name == None:
404409
origin = self.target + (r"\Lib\site-packages\pywin32_system32")
405410
destin = self.target
406411
for name in os.listdir(origin):
407-
print("shutil.copy ", osp.join(origin, name), " ", osp.join(destin, name))
408-
shutil.copyfile(osp.join(origin, name), osp.join(destin, name))
409-
410-
# We patch pip live (around line 100) !!!!
412+
here, there = osp.join(origin, name), osp.join(destin, name)
413+
if (not os.path.exists(there) or
414+
not filecmp.cmp(here, there)):
415+
shutil.copyfile(here, there)
416+
# 'pip' to do movable launchers (around line 100) !!!!
411417
# rational: https://github.com/pypa/pip/issues/2328
412-
if package.name == "get-pip":
413-
# self.exec_script
414-
my_script_is = osp.join(self.target, 'Scripts', 'get-pip.py')
415-
self.install_script(my_script_is, install_options=None)
416-
# change of method 2014-05-08:
417-
# touching pip at installation seems not working anymore
418-
# so brute force method is applied
419-
if package.name == "pip" or package.name == "get-pip" or 1 == 1:
420-
self.patch_all_shebang()
421-
# ensure pip.exe and easy_install.exe
422-
problems = [('pip', 'pip'), ('easy_install', 'easy_install-')]
423-
solutions = [('%s.%s' % sys.version_info[:2]),
424-
('%s' % sys.version_info[0])]
425-
for p in problems:
426-
problem = r'%s\Scripts\%s.exe' % (self.target, p[0])
427-
for s in solutions:
428-
solution = r'%s\Scripts\%s%s.exe' % (self.target, p[1], s)
429-
if not osp.exists(problem) and osp.exists(solution):
430-
shutil.copyfile(solution, problem)
431-
432-
if package.name == "pip" or package.name == "get-pip":
418+
if package_name == "pip" or package_name == None:
419+
# ensure pip will create movable launchers
433420
utils.patch_sourcefile(
434421
self.target + (
435422
r"\Lib\site-packages\pip\_vendor\distlib\scripts.py"),
436423
" executable = get_executable()",
437424
" executable = os.path.join(os.path.basename(get_executable()))")
438-
# We patch IPython\kernel\kernelspec.py live (around line 51) !!!!
439-
if package.name == "ipython":
440-
utils.patch_sourcefile(
441-
self.target + r"\Lib\site-packages\IPython\kernel\kernelspec.py",
442-
r" kernel_dict = json.load(f)",
443-
r" kernel_dict = json.loads(('\n'.join(f.readlines())).replace('[WINPYDIR]',(os.environ['WINPYDIR']).replace('\\','\\\\')))"+
444-
";" + "from winpython.utils import patch_julia03; patch_julia03()")
425+
426+
# create movable launchers for previous package installations
427+
self.patch_all_shebang()
445428

446429
def handle_specific_packages(self, package):
447430
"""Packages requiring additional configuration"""

0 commit comments

Comments
 (0)