[MacPorts] #41411: py27-spatialite: IndexError: list index out of range
MacPorts
noreply at macports.org
Fri Nov 22 14:55:37 PST 2013
#41411: py27-spatialite: IndexError: list index out of range
------------------------------+--------------------------
Reporter: aruminat@… | Owner: and.damore@…
Type: defect | Status: new
Priority: Normal | Milestone:
Component: ports | Version: 2.2.1
Resolution: | Keywords:
Port: py27-spatialite |
------------------------------+--------------------------
Comment (by svohara@…):
The problem with the current py27-spatialite port is that at one step in
running the setup.py, the script looks to download the latest version of
libspatialite-amalgamation-{VER}.zip from the hosting website. There are
two problems in the code for doing this, as I detail below. The problems I
found are located in the get_amalgamation() function below.
{{{
def get_amalgamation():
"""Download the Spatialite amalgamation if it isn't there, already."""
if os.path.exists(AMALGAMATION_ROOT):
return
os.mkdir(AMALGAMATION_ROOT)
print "Downloading amalgation."
# find out what's current amalgamation ZIP file
download_page = urllib.urlopen('''"http://www.gaia-
gis.it/spatialite-2.3.1/sources.html"''').read()
pattern = re.compile("(libspatialite-amalgamation.*?\.zip)")
download_file = pattern.findall(download_page)[0]
amalgamation_url = "http://www.gaia-gis.it/spatialite-2.3.1/" +
download_file
zip_dir = string.replace(download_file,'.zip','')
# and download it
urllib.urlretrieve(amalgamation_url, "tmp.zip")
}}}
1) The base url of the download page has changed. The correct url seems to
be as follows:
http://www.gaia-gis.it/gaia-sins/libspatialite-sources/. This affects the
line of code starting with download_page = ..., as well as
amalgamation_url = ... The result of this error is that the
pattern.findall() function returns an empty list, and thus we get the
invalid index exception.
2) The regular expression finds all zip files starting with
"libspatialite-amalgamation", which returns results like the following on
the webpage I retrieved from the updated url.
{{{
['libspatialite-amalgamation-2.3.0.zip',
'libspatialite-amalgamation-2.3.0.zip',
'libspatialite-amalgamation-2.3.1.zip',
'libspatialite-amalgamation-2.3.1.zip',
'libspatialite-amalgamation-2.4.0-3.zip',
'libspatialite-amalgamation-2.4.0-3.zip',
'libspatialite-amalgamation-2.4.0-4.zip',
'libspatialite-amalgamation-2.4.0-4.zip',
'libspatialite-amalgamation-2.4.0-5.zip',
'libspatialite-amalgamation-2.4.0-5.zip',
'libspatialite-amalgamation-2.4.0.zip',
'libspatialite-amalgamation-2.4.0.zip',
'libspatialite-amalgamation-3.0.0-beta.zip',
'libspatialite-amalgamation-3.0.0-beta.zip',
'libspatialite-amalgamation-3.0.0-beta1a.zip',
'libspatialite-amalgamation-3.0.0-beta1a.zip',
'libspatialite-amalgamation-3.0.0-beta1b.zip',
'libspatialite-amalgamation-3.0.0-beta1b.zip',
'libspatialite-amalgamation-3.0.0-stable.zip',
'libspatialite-amalgamation-3.0.0-stable.zip',
'libspatialite-amalgamation-3.0.1.zip',
'libspatialite-amalgamation-3.0.1.zip']
}}}
However, in the code, the first entry in this list is taken as the
"current" amalgamation zip file, which by looking at the version numbers
is wrong. Even after fixing the download and amalgamation urls, you still
have the problem that 2.3.0 will always be downloaded, even though it
appears there is a 2.4.0 version, as well as 3.x. Without knowing more, I
don't know which is the correct version for compatibility with the rest of
the port.
3) In addition, there is a spelling issue in the print statement which
follows the os.mkdir(AMALGAMATION_ROOT). The print statement outputs:
'amalgation' instead of 'amalgamation'. Obviously this is not a functional
defect, but you may wish to correct the spelling mistake in the same
commit.
--
Ticket URL: <https://trac.macports.org/ticket/41411#comment:4>
MacPorts <http://www.macports.org/>
Ports system for OS X
More information about the macports-tickets
mailing list