Skip to content
This repository has been archived by the owner on May 13, 2020. It is now read-only.

Commit

Permalink
I'm sick of installing certs... added manual/cached downloads
Browse files Browse the repository at this point in the history
  • Loading branch information
agroszer committed Feb 19, 2017
1 parent f5fe0da commit 2adbd99
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 23 deletions.
20 changes: 10 additions & 10 deletions rackspace.ini
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fileEnding = win32-py2.6.exe

[py26_32LX]
# lxml
command = %(curdir)s\bin\lxml --notest %(curdir)s\rackspace.ini %(version)s py26_32
command = %(curdir)s\bin\lxml --notest --downloads d:\downloads %(curdir)s\rackspace.ini %(version)s py26_32
fileEnding = win32-py2.6.exe

[py26_64]
Expand All @@ -44,7 +44,7 @@ fileEnding = win-amd64-py2.6.exe

[py26_64LX]
# .exe
command = %(curdir)s\bin\lxml --notest %(curdir)s\rackspace.ini %(version)s py26_64
command = %(curdir)s\bin\lxml --notest --downloads d:\downloads %(curdir)s\rackspace.ini %(version)s py26_64
fileEnding = win-amd64-py2.6.exe

[py27_32]
Expand All @@ -65,7 +65,7 @@ fileEnding = win32-py2.7.exe

[py27_32LX]
# .exe
command = %(curdir)s\bin\lxml --notest %(curdir)s\rackspace.ini %(version)s py27_32
command = %(curdir)s\bin\lxml --notest --downloads d:\downloads %(curdir)s\rackspace.ini %(version)s py27_32
fileEnding = win32-py2.7.exe

[py27_64]
Expand All @@ -86,7 +86,7 @@ fileEnding = win-amd64-py2.7.exe

[py27_64LX]
# lxml
command = %(curdir)s\bin\lxml --notest %(curdir)s\rackspace.ini %(version)s py27_64
command = %(curdir)s\bin\lxml --notest --downloads d:\downloads %(curdir)s\rackspace.ini %(version)s py27_64
fileEnding = win-amd64-py2.7.exe

[py32_32]
Expand All @@ -107,7 +107,7 @@ fileEnding = win32-py3.2.exe

[py32_32LX]
# lxml
command = %(curdir)s\bin\lxml --notest %(curdir)s\rackspace.ini %(version)s py32_32
command = %(curdir)s\bin\lxml --notest --downloads d:\downloads %(curdir)s\rackspace.ini %(version)s py32_32
fileEnding = win32-py3.2.exe

[py32_64]
Expand All @@ -128,7 +128,7 @@ fileEnding = win-amd64-py3.2.exe

[py32_64LX]
# .exe
command = %(curdir)s\bin\lxml --notest %(curdir)s\rackspace.ini %(version)s py32_64
command = %(curdir)s\bin\lxml --notest --downloads d:\downloads %(curdir)s\rackspace.ini %(version)s py32_64
fileEnding = win-amd64-py3.2.exe

[py33_32]
Expand All @@ -149,7 +149,7 @@ fileEnding = win32-py3.3.exe

[py33_32LX]
# lxml
command = %(curdir)s\bin\lxml --notest %(curdir)s\rackspace.ini %(version)s py33_32
command = %(curdir)s\bin\lxml --notest --downloads d:\downloads %(curdir)s\rackspace.ini %(version)s py33_32
fileEnding = win32-py3.3.exe

[py33_64]
Expand All @@ -170,7 +170,7 @@ fileEnding = win-amd64-py3.3.exe

[py33_64LX]
# .exe
command = %(curdir)s\bin\lxml --notest %(curdir)s\rackspace.ini %(version)s py33_64
command = %(curdir)s\bin\lxml --notest --downloads d:\downloads %(curdir)s\rackspace.ini %(version)s py33_64
fileEnding = win-amd64-py3.3.exe


Expand All @@ -192,7 +192,7 @@ fileEnding = win32-py3.4.exe

[py34_32LX]
# lxml
command = %(curdir)s\bin\lxml --notest %(curdir)s\rackspace.ini %(version)s py34_32
command = %(curdir)s\bin\lxml --notest --downloads d:\downloads %(curdir)s\rackspace.ini %(version)s py34_32
fileEnding = win32-py3.4.exe

[py34_64]
Expand All @@ -213,7 +213,7 @@ fileEnding = win-amd64-py3.4.exe

[py34_64LX]
# .exe
command = %(curdir)s\bin\lxml --notest %(curdir)s\rackspace.ini %(version)s py34_64
command = %(curdir)s\bin\lxml --notest --downloads d:\downloads %(curdir)s\rackspace.ini %(version)s py34_64
fileEnding = win-amd64-py3.4.exe

#[ZODB3_2764]
Expand Down
42 changes: 29 additions & 13 deletions src/zope/wineggbuilder/lxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,27 +49,40 @@
# that helps with debugging
TEMP = tempfile.gettempdir()

DOWNLOADS = None


def addtmp(name):
return os.path.join(TEMP, name)


def download(url, fname):
target = addtmp(fname)
# we'll cache in temp
if DOWNLOADS:
# we'll cache
cached = os.path.join(DOWNLOADS, fname)
if os.path.exists(cached):
LOGGER.info("%s found in %s", fname, DOWNLOADS)
shutil.copy(cached, target)
return target

if os.path.exists(target):
LOGGER.info("%s already downloaded", fname)
return True
return target

LOGGER.info("Downloading %s", url)
remote = urllib2.urlopen(url)
localFile = open(target, 'wb')
localFile.write(remote.read())
localFile.close()

if DOWNLOADS:
cached = os.path.join(DOWNLOADS, fname)
shutil.copy(target, cached)

LOGGER.info("Downloaded %s", fname)

return True
return target


def extract(fname, target, targetname):
Expand Down Expand Up @@ -175,8 +188,7 @@ def run(self, lxmlver):
#####################
zlib = 'zlib-%s.tar.bz2' % ZLIBVER
zlibfolder = os.path.join(bdir, 'zlib')
download(ZLIBURL, zlib)
extract(addtmp(zlib), bdir, 'zlib')
extract(download(ZLIBURL, zlib), bdir, 'zlib')

cmd = r"nmake -f win32\Makefile.msc"
command = self.compiler.setup + '\r\n' + cmd
Expand All @@ -189,8 +201,7 @@ def run(self, lxmlver):
######################
iconv = 'libiconv-%s.tar.bz2' % ICONVVER
iconvfolder = os.path.join(bdir, 'libiconv')
download(ICONVURL, iconv)
extract(addtmp(iconv), bdir, 'libiconv')
extract(download(ICONVURL, iconv), bdir, 'libiconv')

cmd = r"nmake /a -f Makefile.msvc NO_NLS=1"
command = self.compiler.setup + '\r\n' + cmd
Expand All @@ -206,8 +217,7 @@ def run(self, lxmlver):
######################
libxml = 'libxml2-%s.tar.bz2' % LIBXMLVER
libxmlfolder = os.path.join(bdir, 'libxml2')
download(LIBXMLURL, libxml)
extract(addtmp(libxml), bdir, 'libxml2')
extract(download(LIBXMLURL, libxml), bdir, 'libxml2')

cmd1 = r"cscript configure.js compiler=msvc iconv=yes zlib=yes include=%s;%s\include lib=%s;%s\lib" % (
zlibfolder, iconvfolder, zlibfolder, iconvfolder)
Expand All @@ -222,8 +232,7 @@ def run(self, lxmlver):
######################
libxslt = 'libxslt-%s.tar.bz2' % LIBXSLTVER
libxsltfolder = os.path.join(bdir, 'libxslt')
download(LIBXSLTURL, libxslt)
extract(addtmp(libxslt), bdir, 'libxslt')
extract(download(LIBXSLTURL, libxslt), bdir, 'libxslt')

cmd1 = r"cscript configure.js compiler=msvc iconv=yes zlib=yes include=%s\include;%s;%s\include lib=%s\win32\bin.msvc;%s;%s\lib" % (
libxmlfolder, zlibfolder, iconvfolder, libxmlfolder, zlibfolder, iconvfolder)
Expand All @@ -239,8 +248,7 @@ def run(self, lxmlver):
lxml = 'lxml-%s.tar.gz' % lxmlver
url = project_file('lxml', lxml)
lxmlfolder = os.path.join(bdir, 'lxml')
download(url, lxml)
extract(addtmp(lxml), bdir, 'lxml')
extract(download(url, lxml), bdir, 'lxml')

# patch the include/lib folders for a static build
subst = dict(zlib=zlibfolder, iconv=iconvfolder,
Expand Down Expand Up @@ -359,6 +367,10 @@ def getOptions(args):
dest="notest", default=False,
help="When specified, tests are ignored.")

parser.add_option(
"--downloads", action="store", type="string", dest="downloads",
help="Specify a folder for download cache.")

return parser.parse_args(args)


Expand All @@ -380,6 +392,10 @@ def main(args=None):
print "Usage: %s [options] config-ini lxml-version lxml-target" % sys.argv[0]
sys.exit(1)

if options.downloads:
global DOWNLOADS
DOWNLOADS = options.downloads

# we want the compilers specification from (args[0])
builder = build.Builder(args[0], options)

Expand Down

0 comments on commit 2adbd99

Please sign in to comment.