@@ -363,31 +363,32 @@ def patch_sourcelines(fname, in_line_start, out_line, endline='\n', silent_mode=
363363 print ("impossible to patch" , fname , "from" , content ,
364364 "to" , new_content )
365365
366+
366367def patch_julia03 ():
367368 """Ugly patch of Julia/ZMQ and Julia/Nettle to make them movable"""
368369 import io
369370 import os .path as osp
370- out_line = '"' + os .path .dirname (os .environ ["WINPYDIR" ]).replace ("\\ " , "\\ \\ " )
371+ out_line = '"' + os .path .dirname (os .environ ["WINPYDIR" ]).replace ("\\ " , "\\ \\ " )
371372 end_line = r"\\settings\\.julia"
372- from winpython .utils import patch_sourcelines
373+ from winpython .utils import patch_sourcelines
373374
374- in_line_start = '@checked_lib zmq ' ;
375+ in_line_start = '@checked_lib zmq '
375376
376- fname = os .path .dirname (os .environ ["WINPYDIR" ]) + r"\settings\.julia\v0.3\ZMQ\deps\deps.jl" ;
377- patch_sourcelines (fname , in_line_start , out_line , end_line);
378- fname = os .path .dirname (os .environ ["WINPYDIR" ]) + r"\settings\.julia\v0.4\ZMQ\deps\deps.jl" ;
379- patch_sourcelines (fname , in_line_start , out_line , end_line );
380- fname = os .path .dirname (os .environ ["WINPYDIR" ]) + r"\settings\.julia\v0.5\ZMQ\deps\deps.jl" ;
381- patch_sourcelines (fname , in_line_start , out_line , end_line );
377+ fname = os .path .dirname (os .environ ["WINPYDIR" ]) + r"\settings\.julia\v0.3\ZMQ\deps\deps.jl" ;
378+ patch_sourcelines (fname , in_line_start , out_line , end_line )
379+ fname = os .path .dirname (os .environ ["WINPYDIR" ]) + r"\settings\.julia\v0.4\ZMQ\deps\deps.jl" ;
380+ patch_sourcelines (fname , in_line_start , out_line , end_line )
381+ fname = os .path .dirname (os .environ ["WINPYDIR" ]) + r"\settings\.julia\v0.5\ZMQ\deps\deps.jl" ;
382+ patch_sourcelines (fname , in_line_start , out_line , end_line )
382383
383384 in_line_start = '@checked_lib nettle ' ;
384385
385- fname = os .path .dirname (os .environ ["WINPYDIR" ]) + r"\settings\.julia\v0.3\Nettle\deps\deps.jl" ;
386- patch_sourcelines (fname , in_line_start , out_line , end_line );
387- fname = os .path .dirname (os .environ ["WINPYDIR" ]) + r"\settings\.julia\v0.4\Nettle\deps\deps.jl" ;
388- patch_sourcelines (fname , in_line_start , out_line , end_line );
389- fname = os .path .dirname (os .environ ["WINPYDIR" ]) + r"\settings\.julia\v0.5\Nettle\deps\deps.jl" ;
390- patch_sourcelines (fname , in_line_start , out_line , end_line );
386+ fname = os .path .dirname (os .environ ["WINPYDIR" ]) + r"\settings\.julia\v0.3\Nettle\deps\deps.jl" ;
387+ patch_sourcelines (fname , in_line_start , out_line , end_line )
388+ fname = os .path .dirname (os .environ ["WINPYDIR" ]) + r"\settings\.julia\v0.4\Nettle\deps\deps.jl" ;
389+ patch_sourcelines (fname , in_line_start , out_line , end_line )
390+ fname = os .path .dirname (os .environ ["WINPYDIR" ]) + r"\settings\.julia\v0.5\Nettle\deps\deps.jl" ;
391+ patch_sourcelines (fname , in_line_start , out_line , end_line )
391392
392393
393394# =============================================================================
@@ -484,85 +485,16 @@ def extract_archive(fname, targetdir=None, verbose=False):
484485# "win32|win\_amd64" to replace per "win\_amd64" for 64bit
485486WHEELBIN_PATTERN = r'([a-zA-Z0-9\-\_\.]*)-([0-9\.\_]*[a-z0-9\+]*[0-9]?)-cp([0-9]*)\-none\-(win32|win\_amd64)\.whl'
486487
488+
487489def get_source_package_infos (fname ):
488490 """Return a tuple (name, version) of the Python source package"""
489491 match = re .match (SOURCE_PATTERN , osp .basename (fname ))
490492 if match is not None :
491493 return match .groups ()[:2 ]
492494
493495
494- def build_wininst (root , python_exe = None , copy_to = None ,
495- architecture = None , verbose = False , installer = 'bdist_wininst' ):
496- """Build wininst installer from Python package located in *root*
497- and eventually copy it to *copy_to* folder.
498- Return wininst installer full path."""
499- if python_exe is None :
500- python_exe = sys .executable
501- assert osp .isfile (python_exe )
502- cmd = [python_exe , 'setup.py' , 'build' ]
503- if architecture is not None :
504- archstr = 'win32' if architecture == 32 else 'win-amd64'
505- cmd += ['--plat-name=%s' % archstr ]
506- cmd += [installer ]
507- # root = a tmp dir in windows\tmp,
508- if verbose :
509- subprocess .call (cmd , cwd = root )
510- else :
511- p = subprocess .Popen (cmd , cwd = root , stdout = subprocess .PIPE ,
512- stderr = subprocess .PIPE )
513- p .communicate ()
514- p .stdout .close ()
515- p .stderr .close ()
516- distdir = osp .join (root , 'dist' )
517- if not osp .isdir (distdir ):
518- raise RuntimeError ("Build failed: see package README file for further"
519- " details regarding installation requirements.\n \n "
520- "For more concrete debugging infos, please try to build "
521- "the package from the command line:\n "
522- "1. Open a WinPython command prompt\n "
523- "2. Change working directory to the appropriate folder\n "
524- "3. Type `python setup.py build install`" )
525- pattern = WININST_PATTERN .replace (r'(win32|win\-amd64)' , archstr )
526- for distname in os .listdir (distdir ):
527- match = re .match (pattern , distname )
528- if match is not None :
529- break
530- # for wheels (winpython here)
531- match = re .match (SOURCE_PATTERN , distname )
532<
3ADC
/code>- if match is not None :
533- break
534- match = re .match (WHEELBIN_PATTERN , distname )
535- if match is not None :
536- break
537- else :
538- raise RuntimeError ("Build failed: not a pure Python package? %s" %
539- distdir )
540- src_fname = osp .join (distdir , distname )
541- if copy_to is None :
542- return src_fname
543- else :
544- dst_fname = osp .join (copy_to , distname )
545- shutil .move (src_fname , dst_fname )
546- if verbose :
547- print (("Move: %s --> %s" % (src_fname , (dst_fname ))))
548- # remove tempo dir 'root' no more needed
549- shutil .rmtree (root , onerror = onerror )
550- return dst_fname
551-
552-
553- def source_to_wininst (fname , python_exe = None ,
554- architecture = None , verbose = False ):
555- """Extract source archive, build it and create a distutils installer"""
556- tmpdir = extract_archive (fname )
557- root = osp .join (tmpdir , '%s-%s' % get_source_package_infos (fname ))
558- assert osp .isdir (root )
559- return build_wininst (root , python_exe = python_exe ,
560- copy_to = osp .dirname (fname ),
561- architecture = architecture , verbose = verbose )
562-
563-
564- def direct_pip_install (fname , python_exe = None ,
565- architecture = None , verbose = False , install_options = None ):
496+ def direct_pip_install (fname , python_exe = None , architecture = None ,
497+ verbose = False , install_options = None ):
566498 """Direct install via pip !"""
567499 copy_to = osp .dirname (fname )
568500
@@ -599,8 +531,9 @@ def direct_pip_install(fname, python_exe=None,
599531 print ("Installed %s" % src_fname )
600532 return src_fname
601533
534+
602535def do_script (this_script , python_exe = None , copy_to = None ,
603- architecture = None , verbose = False , install_options = None ):
536+ architecture = None , verbose = False , install_options = None ):
604537 """Execute a script (get-pip typically)"""
605538 if python_exe is None :
606539 python_exe = sys .executable
0 commit comments