Skip to content

Commit 180c5cc

Browse files
committed
rework binary download
1 parent 4cc3fc9 commit 180c5cc

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

install/gitstrap.py

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,8 @@
261261
import numpy as np
262262
msg += f"\nnumpy: {np.__version__}"
263263
except:
264-
pass
264+
msg += "\nnumpy: **not found!**"
265+
265266
print(msg)
266267
if not logfile:
267268
logfile = os.path.normpath(os.path.join(path2repo,'..','gitstrap.log'))
@@ -460,9 +461,30 @@ def gitResetGSASII(repo_path,verbose=True):
460461
if allBinaries:
461462
tarURLs = GSASIIpath.getGitBinaryReleases().values()
462463
else:
463-
tarURLs = [GSASIIpath.getGitBinaryLoc(verbose=True,
464-
npver=npVersion,pyver=pyVersion)]
465-
print('tarURLs=',tarURLs,npVersion,pyVersion)
464+
# try to load the exact binary collection we want
465+
bindir = GSASIIpath.GetBinaryPrefix(pyVersion)
466+
if npVersion:
467+
inpver = GSASIIpath.intver(npVersion)
468+
else:
469+
inpver = GSASIIpath.intver(np.__version__)
470+
tar = bindir + '_n' + GSASIIpath.fmtver(inpver)
471+
try:
472+
# lookup latest release
473+
URL = 'https://github.com/AdvancedPhotonSource/GSAS-II-buildtools/releases/latest'
474+
response = requests.get(URL, allow_redirects=False)
475+
if response.is_redirect or response.is_permanent_redirect:
476+
URL = response.headers.get('Location').replace('/tag/','/download/')
477+
if not URL.endswith('/'): URL += '/'
478+
tarURL = URL + tar + '.tgz'
479+
else:
480+
raise Exception
481+
GSASIIpath.InstallGitBinary(tarURL, installLoc, nameByVersion=True,
482+
verbose=True)
483+
tarURLs = []
484+
except:
485+
# exact match is not present, look something that is close
486+
tarURLs = [GSASIIpath.getGitBinaryLoc(verbose=True,
487+
npver=npVersion,pyver=pyVersion)]
466488
for tarURL in tarURLs:
467489
if not tarURL:
468490
print('no Binary URL found. Aborting installation')

0 commit comments

Comments
 (0)