@@ -707,12 +707,12 @@ def getGitBinaryReleases(cache=False):
707707 The value associated with each key contains the full URL to
708708 download a tar containing that binary distribution.
709709 '''
710- # Get first page of releases
711710 try :
712711 import requests
713712 except :
714713 print ('Unable to install binaries in getGitBinaryReleases():\n requests module not available' )
715714 return
715+ # Get first page of releases. (Could there be more than one?)
716716 releases = []
717717 tries = 0
718718 while tries < 5 : # this has been known to fail, so retry
@@ -722,20 +722,14 @@ def getGitBinaryReleases(cache=False):
722722 headers = BASE_HEADER
723723 ).json ()
724724 try :
725- # Get assets of latest release
726- assets = requests .get (
727- url = f"{ G2binURL } /releases/{ releases [- 1 ]['id' ]} /assets" ,
728- headers = BASE_HEADER
729- ).json ()
730-
725+ # loop over assets of latest release (will [-1] always get this?)
731726 versions = []
732727 URLs = []
733- count = 0
734- for asset in assets :
735- if asset ['name' ].endswith ('.tgz' ):
736- versions .append (asset ['name' ][:- 4 ]) # Remove .tgz tail
737- URLs .append (asset ['browser_download_url' ])
738- count += 1
728+ for asset in releases [- 1 ]['assets' ]:
729+ if not asset ['name' ].endswith ('.tgz' ): continue
730+ versions .append (asset ['name' ][:- 4 ]) # Remove .tgz tail
731+ URLs .append (asset ['browser_download_url' ])
732+ count = len (versions )
739733 # Cache the binary releases for later use in case GitHub
740734 # prevents us from using a query to get them
741735 if cache and count > 4 :
@@ -746,7 +740,7 @@ def getGitBinaryReleases(cache=False):
746740 fp .close ()
747741 return dict (zip (versions ,URLs ))
748742 except :
749- print ('Attempt to list GSAS-II binary releases failed, sleeping for 10 sec and then retrying' )
743+ print ('Attempt to get GSAS-II binary releases/assets failed, sleeping for 10 sec and then retrying' )
750744 import time
751745 time .sleep (10 ) # this does not seem to help when GitHub is not letting the queries through
752746
@@ -762,7 +756,7 @@ def getGitBinaryReleases(cache=False):
762756 except :
763757 raise IOError ('Cache read of releases failed too.' )
764758
765- def getGitBinaryLoc (npver = None ,pyver = None ,verbose = True ):
759+ def getGitBinaryLoc (npver = None ,pyver = None ,verbose = True , debug = False ):
766760 '''Identify the best GSAS-II binary download location from the
767761 distributions in the latest release section of the github repository
768762 on the CPU platform, and Python & numpy versions. The CPU & Python
@@ -783,11 +777,15 @@ def getGitBinaryLoc(npver=None,pyver=None,verbose=True):
783777 inpver = intver (np .__version__ )
784778 # get binaries matching the required install, approximate match for numpy
785779 URLdict = getGitBinaryReleases ()
780+ if debug :
781+ print ('URLdict:' )
782+ for k in URLdict : print (k ,URLdict [k ])
786783 versions = {}
787784 for d in URLdict :
788785 if d .startswith (bindir ):
789786 v = intver (d .rstrip ('/' ).split ('_' )[3 ].lstrip ('n' ))
790787 versions [v ] = d
788+ if debug : print ('versions:' ,versions )
791789 intVersionsList = sorted (versions .keys ())
792790 if not intVersionsList :
793791 print ('No binaries located to match' ,bindir )
@@ -844,6 +842,7 @@ def InstallGitBinary(tarURL, instDir, nameByVersion=False, verbose=True):
844842 print ('Unable to install binaries in InstallGitBinary():\n requests module not available' )
845843 return
846844 # download to scratch
845+ tarobj = None
847846 tar = tempfile .NamedTemporaryFile (suffix = '.tgz' ,delete = False )
848847 try :
849848 tar .close ()
@@ -873,9 +872,11 @@ def InstallGitBinary(tarURL, instDir, nameByVersion=False, verbose=True):
873872 # set file mode and mod/access times (but not ownership)
874873 os .chmod (newfil ,f .mode )
875874 os .utime (newfil ,(f .mtime ,f .mtime ))
876- if verbose : print (f'Created GSAS-II binary file { newfil } ' )
875+ if verbose : print (f'Created GSAS-II binary file { os .path .split (newfil )[1 ]} ' )
876+ if verbose : print (f'Binary files created in { os .path .split (newfil )[0 ]} ' )
877+
877878 finally :
878- del tarobj
879+ if tarobj : del tarobj
879880 os .unlink (tar .name )
880881
881882def GetRepoUpdatesInBackground ():
0 commit comments