@@ -31,6 +31,7 @@ from cmsBuild_consts import *
31
31
from cmsdist_config import USE_COMPILER_VERSION
32
32
try : from monitor_build import run_monitor_on_command
33
33
except : run_monitor_on_command = None
34
+ import json
34
35
35
36
urlRe = re .compile (".*:.*/.*" )
36
37
logLevel = 10
@@ -605,6 +606,7 @@ def downloadPip(source, dest, options):
605
606
pack = pack + '==' + pkg [1 ].strip ()
606
607
pip_opts = "--no-deps --no-binary=:all:"
607
608
pip = "pip"
609
+ isSourceDownload = True
608
610
609
611
for opt in opts :
610
612
if opt .startswith ("pip=" ): pip = opt .split ('=' ,1 )[- 1 ]
@@ -619,6 +621,31 @@ def downloadPip(source, dest, options):
619
621
i = i + 1
620
622
else :
621
623
pip_opts = pip_opts + ' ' + spSrc [i ]
624
+ if "no-binary" in spSrc [i ] and "all" not in spSrc [i ]:
625
+ isSourceDownload = False #not totally robust - but basically use pip if source is overridden
626
+
627
+ if isSourceDownload :
628
+ log ("Looking for sources at https://pypi.org/pypi/" + pack .split ('=' )[0 ]+ "/json" )
629
+ fj = urlopen ("https://pypi.org/pypi/" + pack .split ('=' )[0 ]+ "/json" )
630
+ data = json .load (fj )
631
+ url = None
632
+ if "releases" in data and pack .split ('=' )[2 ] in data ["releases" ]:
633
+ for file in data ["releases" ][pack .split ('=' )[2 ]]:
634
+ if file ["packagetype" ] == "sdist" :
635
+ url = file ["url" ]
636
+ if url is not None :
637
+ log ("Found source on pypi - downloading" )
638
+ tempdir = createTempDir (options .workDir , options .tempDirPrefix )
639
+ precmd = "cd %s; " % tempdir
640
+ downloadUrllib2 (url , tempdir , options )
641
+ cmd = "/bin/ls " + tempdir + " | grep -v files.list > " + os .path .join (tempdir ,"files.list" )
642
+ getstatusoutput (cmd )
643
+ o ,e = getstatusoutput (precmd + "cat files.list" )
644
+ cmd = precmd + "tar cfz " + os .path .join (dest ,"source.tar.gz" )+ " `cat files.list` files.list"
645
+ o ,e = getstatusoutput (cmd )
646
+ getstatusoutput ("rm -rf %s" % tempdir )
647
+ return True
648
+
622
649
if not '--no-deps' in pip_opts : pip_opts = '--no-deps ' + pip_opts
623
650
if not '--no-cache-dir' in pip_opts : pip_opts = '--no-cache-dir ' + pip_opts
624
651
comm = pip + ' download ' + pip_opts + ' --disable-pip-version-check -d . ' + pack + '; /bin/ls | grep -v files.list > files.list'
@@ -825,6 +852,7 @@ def download(source, dest, options, pkg=None):
825
852
if success :
826
853
noCmssdtCache = True
827
854
break
855
+
828
856
if not success :
829
857
log ("Trying to fetch source file: %s" % source , DEBUG )
830
858
success = downloadHandler (source , downloadDir , downloadOptions )
0 commit comments