[Scons-users] first builder / download
Philipp Kraus
philipp.kraus at flashpixx.de
Fri Aug 17 07:15:37 EDT 2012
On 2012-08-17 08:59:48 +0200, Dirk Bächle said:
> Hi Phil,
>
> On 17.08.2012 07:42, Philipp Kraus wrote:
>>
>>
>> For example I try to download the newest version of the LUA sources,
>> so I create a function for parsing the HTML page source
>>
>> def LUA_DownloadURL() :
>> # read download path of the LUA library (latest version)
>> f = urllib2.urlopen("http://www.lua.org/download.html")
>> html = f.read()
>> f.close()
>>
>> found = re.search("<a href=\"ftp/lua-(.*)\.tar\.gz\">", html,
>> re.IGNORECASE)
>> if found == None :
>> raise RuntimeError("LUA Download URL not found")
>>
>> downloadurl = found.group(0)
>>
>> downloadurl = downloadurl.replace("\"", "")
>> downloadurl = downloadurl.replace("<", "")
>> downloadurl = downloadurl.replace(">", "")
>> downloadurl = re.sub(r'(?i)a href=', "", downloadurl)
>> downloadurl = "http://www.lua.org/" + downloadurl
>>
>> filename = downloadurl.split("/")[-1]
>>
>> return downloadurl, filename
>>
>> The function must return first the URL of the download and on second
>> the target filename, the main scons script shows:
>>
>> x = env.ParseAndDownload( LUA_DownloadURL )
>>
>> and in x is the target filename stored (actually lua-5.2.1.tar.gz)
>>
>> Can you send me some tips to create better code?
>>
>> Thanks
>>
>> Phil
>>
>>
>> _______________________________________________
>> Scons-users mailing list
>> Scons-users at scons.org
>> http://four.pairlist.net/mailman/listinfo/scons-users
>>
>
> in total, wouldn't it be easier to simply check whether the target file
> from your download exists with Python?
> Something like:
>
> url, target = LUA_DownloadURL()
> if not os.path.isfile(target):
> # Download file here
>
> I fail to see what you are winning when you try to use SCons constructs
> for the download. Having the file "to download"
> (http://www.lua.org/whatever) connected to the dependency graph would
> mean that SCons has to download the file each and every time the user
> starts a build. Just to check whether the file changed,
> accidentally...you never know, better make sure.
> Is this really what you want to happen in the end?
The download is not started every time, it is a seperated target for download
and building the libraries. Scons does not download the source file every time.
It downloads only the HTML file and on the extracted data of the HTML file I
create a Value-target. The Value-target is the source for the download, so
if this changes / not exists the file is downloaded.
> Oh, and thanks a lot for "finally" telling us what you really intend to
> do with all that code of yours. ;)
*g* it is a request for my project, that I create a "build" script,
which download
all libraries and build them automatically in the "default options". I
picked up
the libraries my self and install them manually, so I need where they
are and which
options I have build them. But the request is to create an "easy
install option" for all too
(best way "double click and run").
Phil
More information about the Scons-users
mailing list