Bug 173079 - [NEW PORT] databases/pyspatialite Python interface to SQLite 3 + Spatialite
Summary: [NEW PORT] databases/pyspatialite Python interface to SQLite 3 + Spatialite
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Pawel Pekala
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-10-25 20:10 UTC by Loïc Bartoletti
Modified: 2013-03-27 17:00 UTC (History)
0 users

See Also:


Attachments
file.shar (3.43 KB, text/plain)
2012-10-25 20:10 UTC, Loïc Bartoletti
no flags Details
pyspatialite.shar (4.38 KB, application/x-shar)
2013-03-09 09:30 UTC, Loïc Bartoletti
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Loïc Bartoletti freebsd_committer freebsd_triage 2012-10-25 20:10:00 UTC
pyspatialite is an interface to the SQLite 3.x embedded relational database engine with spatialite extensions. It is almost fully compliant with the Python database API version 2.0 also exposes the unique features of SQLite and spatialite.

WWW : https://code.google.com/p/pyspatialite/

Python PyPi : http://pypi.python.org/pypi/pyspatialite/3.0.1

Fix: Patch attached with submission follows:
How-To-Repeat: portlint -Nabt : OK
port test : OK
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2012-10-25 20:10:30 UTC
Class Changed
From-To: sw-bug->change-request

Fix category (new ports should be change-requests) (via the GNATS Auto 
Assign Tool)
Comment 2 Loïc Bartoletti freebsd_committer freebsd_triage 2013-03-09 09:30:54 UTC
Here, new version of the port.

Add one correction into patch for spatialite.

Regards.
Comment 3 Pawel Pekala freebsd_committer freebsd_triage 2013-03-21 19:11:20 UTC
State Changed
From-To: open->feedback

Tries to download additional distfile during build: 

http://people.freebsd.org/~pawel/buildlogs/py27-pyspatialite-3.0.1.log
Comment 4 Pawel Pekala freebsd_committer freebsd_triage 2013-03-26 17:42:06 UTC
Hello,

Dnia 2013-03-26, o godz. 07:23:58
lbartoletti <coder@tuxfamily.org> napisa=B3(a):

>What do you think of this:
>I bypassed the downloading of "amalgamation" by including it directly
>in the "FILESDIR." I took the opportunity to make corrections to the
>Makefile.
>
>Tinderlog via Redports:
>https://redports.org/buildarchive/20130325220239-80680/

Thanks for the update. I don't think this is a good idea, files are too
big to be hosted in ports tree. Is there any problems with downloading
amalgamation file, extracting it and copying files to ${WRKSRC} before
build ? It contains all needed files (at first glimpse at least):

http://www.gaia-gis.it/gaia-sins/libspatialite-sources/libspatialite-amalga=
mation-3.0.1.tar.gz

I think it should be doable using DISTFILES and copying files after
extract target.

--=20
pozdrawiam / with regards
Pawe=B3 P=EAkala
Comment 5 Pawel Pekala freebsd_committer freebsd_triage 2013-03-27 16:17:55 UTC
Responsible Changed
From-To: freebsd-ports-bugs->pawel

I'll take it.
Comment 6 dfilter service freebsd_committer freebsd_triage 2013-03-27 16:59:27 UTC
Author: pawel
Date: Wed Mar 27 16:59:17 2013
New Revision: 315396
URL: http://svnweb.freebsd.org/changeset/ports/315396

Log:
  pyspatialite is an interface to the SQLite 3.x embedded relational database
  engine with spatialite extensions.
  It is almost fully compliant with the Python database API version 2.0 also
  exposes the unique features of SQLite and spatialite.
  
  WWW: https://code.google.com/p/pyspatialite/
  
  PR:		ports/173079
  Submitted by:	lbartoletti <coder@tuxfamily.org>

Added:
  head/databases/pyspatialite/
  head/databases/pyspatialite/Makefile   (contents, props changed)
  head/databases/pyspatialite/distinfo   (contents, props changed)
  head/databases/pyspatialite/files/
  head/databases/pyspatialite/files/patch-setup.py   (contents, props changed)
  head/databases/pyspatialite/files/patch-src-connection.h   (contents, props changed)
  head/databases/pyspatialite/pkg-descr   (contents, props changed)
  head/databases/pyspatialite/pkg-plist   (contents, props changed)
Modified:
  head/databases/Makefile

Modified: head/databases/Makefile
==============================================================================
--- head/databases/Makefile	Wed Mar 27 16:53:05 2013	(r315395)
+++ head/databases/Makefile	Wed Mar 27 16:59:17 2013	(r315396)
@@ -767,6 +767,7 @@
     SUBDIR += pydbdesigner
     SUBDIR += pydbx
     SUBDIR += pymongo
+    SUBDIR += pyspatialite
     SUBDIR += qdbm
     SUBDIR += qdbm-plus
     SUBDIR += qt-mysql-plugin

Added: head/databases/pyspatialite/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/databases/pyspatialite/Makefile	Wed Mar 27 16:59:17 2013	(r315396)
@@ -0,0 +1,29 @@
+# Created by: lbartoletti <coder@tuxfamily.org>
+# $FreeBSD$
+
+PORTNAME=	pyspatialite
+PORTVERSION=	3.0.1
+CATEGORIES=	databases python
+MASTER_SITES=	CHEESESHOP:pyspatialite \
+		http://www.gaia-gis.it/gaia-sins/libspatialite-sources/:amalgam
+PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
+DISTFILES=	${DISTNAME}${EXTRACT_SUFX}:pyspatialite \
+		${AMALGAMATION_NAME}${EXTRACT_SUFX}:amalgam
+
+MAINTAINER=	coder@tuxfamily.org
+COMMENT=	DB-API 2.0 interface for SQLite 3.x with Spatialite 3.x
+
+LIB_DEPENDS=	spatialite:${PORTSDIR}/databases/spatialite
+
+USE_PYTHON=	yes
+USE_PYDISTUTILS=yes
+PYDISTUTILS_PKGNAME=	pyspatialite
+
+AMALGAMATION_NAME=	libspatialite-amalgamation-${PORTVERSION}
+
+post-patch:
+	@${REINPLACE_CMD} -e "s|pyspatialite-doc|${DOCSDIR}|g" \
+		-e "s|%%LOCALBASE%%|${LOCALBASE}|g" ${WRKSRC}/setup.py
+	@${MV} ${WRKDIR}/${AMALGAMATION_NAME} ${WRKSRC}/amalgamation
+
+.include <bsd.port.mk>

Added: head/databases/pyspatialite/distinfo
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/databases/pyspatialite/distinfo	Wed Mar 27 16:59:17 2013	(r315396)
@@ -0,0 +1,4 @@
+SHA256 (pyspatialite-3.0.1.tar.gz) = 81a3e4966fb6348802a985486cbf62e019a0fcb0a1e006b9522e8b02dc08f238
+SIZE (pyspatialite-3.0.1.tar.gz) = 75099
+SHA256 (libspatialite-amalgamation-3.0.1.tar.gz) = 51f08c6c9180b1f8979d0469960a5c20a79a574c08fe032ae292042245ad46b6
+SIZE (libspatialite-amalgamation-3.0.1.tar.gz) = 2485779

Added: head/databases/pyspatialite/files/patch-setup.py
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/databases/pyspatialite/files/patch-setup.py	Wed Mar 27 16:59:17 2013	(r315396)
@@ -0,0 +1,85 @@
+--- setup.py.orig	2012-01-11 23:54:57.000000000 +0100
++++ setup.py	2013-03-24 09:52:46.000000000 +0100
+@@ -44,7 +44,7 @@
+ 
+ include_dirs = []
+ library_dirs = []
+-libraries = ['geos','geos_c','proj']
++libraries = ['geos','geos_c','proj','iconv']
+ runtime_library_dirs = []
+ extra_objects = []
+ define_macros = []
+@@ -86,29 +86,30 @@
+ 
+ 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("https://www.gaia-gis.it/fossil/libspatialite/index").read()
+-    pattern = re.compile("(libspatialite-amalgamation.*?\.zip)")
+-    download_file = pattern.findall(download_page)[0]
+-    amalgamation_url = "http://www.gaia-gis.it/gaia-sins/" + download_file
+-    zip_dir = string.replace(download_file,'.zip','')
+-    # and download it
+-    urllib.urlretrieve(amalgamation_url, "tmp.zip")
+-
+-    zf = zipfile.ZipFile("tmp.zip")
+-    files = ["sqlite3.c", "headers/spatialite/sqlite3.h", "spatialite.c", "headers/spatialite/sqlite3ext.h","headers/spatialite/spatialite.h","headers/spatialite/gaiaaux.h","headers/spatialite/gaiaexif.h","headers/spatialite/gaiageo.h"]
+-    for fn in files:
+-        print "Extracting", fn
+-        outf = open(AMALGAMATION_ROOT + os.sep + string.split(fn,'/')[-1], "wb")
+-        outf.write(zf.read(zip_dir + '/' + fn))
+-        outf.close()
+-    zf.close()
+-    os.unlink("tmp.zip")
++#   into ${FILESDIR} for FreeBSD
++#    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/gaia-sins/libspatialite-sources/").read()
++#    pattern = re.compile("(libspatialite-amalgamation.*?\.zip)")
++#    download_file = pattern.findall(download_page)[-1]
++#    amalgamation_url = "http://www.gaia-gis.it/gaia-sins/libspatialite-sources/" + download_file
++#    zip_dir = string.replace(download_file,'.zip','')
++#    # and download it
++#    urllib.urlretrieve(amalgamation_url, "tmp.zip")
++#
++#    zf = zipfile.ZipFile("tmp.zip")
++#    files = ["sqlite3.c", "headers/spatialite/sqlite3.h", "spatialite.c", "headers/spatialite/sqlite3ext.h","headers/spatialite/spatialite.h","headers/spatialite/gaiaaux.h","headers/spatialite/gaiaexif.h","headers/spatialite/gaiageo.h"]
++#    for fn in files:
++#        print "Extracting", fn
++#        outf = open(AMALGAMATION_ROOT + os.sep + string.split(fn,'/')[-1], "wb")
++#        outf.write(zf.read(zip_dir + '/' + fn))
++#        outf.close()
++#    zf.close()
++#    os.unlink("tmp.zip")
+ 
+ class MyBuildExt(build_ext):
+ 
+@@ -119,8 +120,10 @@
+           ext.libraries.append("iconv")
+ 
+         #Default locations for Mac
++        ext.include_dirs.append("%%LOCALBASE%%/include/")
+         ext.include_dirs.append("/Library/Frameworks/GEOS.framework/unix/include/")
+         ext.include_dirs.append("/Library/Frameworks/PROJ.framework/unix/include/")
++        ext.library_dirs.append("%%LOCALBASE%%/lib")
+         ext.library_dirs.append("/Library/Frameworks/GEOS.framework/unix/lib")
+         ext.library_dirs.append("/Library/Frameworks/PROJ.framework/unix/lib")
+ 
+@@ -132,7 +135,7 @@
+         ext.sources.append(os.path.join(AMALGAMATION_ROOT, "spatialite.c"))
+         ext.include_dirs.append(AMALGAMATION_ROOT)
+         build_ext.build_extension(self, ext)
+-        
++
+ 
+ #    def __setattr__(self, k, v):
+ #        # Make sure we don't link against the SQLite library, no matter what setup.cfg says

Added: head/databases/pyspatialite/files/patch-src-connection.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/databases/pyspatialite/files/patch-src-connection.h	Wed Mar 27 16:59:17 2013	(r315396)
@@ -0,0 +1,11 @@
+--- src/connection.h.bak	2012-10-25 19:40:06.000000000 +0200
++++ src/connection.h	2012-10-25 19:40:25.000000000 +0200
+@@ -33,8 +33,6 @@
+ #include "sqlite3.h"
+ #include "spatialite.h"
+ 
+-int spatialite_init(int verbose);
+-
+ typedef struct
+ {
+     PyObject_HEAD

Added: head/databases/pyspatialite/pkg-descr
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/databases/pyspatialite/pkg-descr	Wed Mar 27 16:59:17 2013	(r315396)
@@ -0,0 +1,6 @@
+pyspatialite is an interface to the SQLite 3.x embedded relational database
+engine with spatialite extensions.
+It is almost fully compliant with the Python database API version 2.0 also
+exposes the unique features of SQLite and spatialite.
+
+WWW: https://code.google.com/p/pyspatialite/

Added: head/databases/pyspatialite/pkg-plist
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/databases/pyspatialite/pkg-plist	Wed Mar 27 16:59:17 2013	(r315396)
@@ -0,0 +1,52 @@
+%%PYTHON_SITELIBDIR%%/pyspatialite/__init__.py
+%%PYTHON_SITELIBDIR%%/pyspatialite/__init__.pyc
+%%PYTHON_SITELIBDIR%%/pyspatialite/__init__.pyo
+%%PYTHON_SITELIBDIR%%/pyspatialite/_spatialite.so
+%%PYTHON_SITELIBDIR%%/pyspatialite/dbapi2.py
+%%PYTHON_SITELIBDIR%%/pyspatialite/dbapi2.pyc
+%%PYTHON_SITELIBDIR%%/pyspatialite/dbapi2.pyo
+%%PYTHON_SITELIBDIR%%/pyspatialite/dump.py
+%%PYTHON_SITELIBDIR%%/pyspatialite/dump.pyc
+%%PYTHON_SITELIBDIR%%/pyspatialite/dump.pyo
+%%PYTHON_SITELIBDIR%%/pyspatialite/test/__init__.py
+%%PYTHON_SITELIBDIR%%/pyspatialite/test/__init__.pyc
+%%PYTHON_SITELIBDIR%%/pyspatialite/test/__init__.pyo
+%%PYTHON_SITELIBDIR%%/pyspatialite/test/dbapi.py
+%%PYTHON_SITELIBDIR%%/pyspatialite/test/dbapi.pyc
+%%PYTHON_SITELIBDIR%%/pyspatialite/test/dbapi.pyo
+%%PYTHON_SITELIBDIR%%/pyspatialite/test/dump.py
+%%PYTHON_SITELIBDIR%%/pyspatialite/test/dump.pyc
+%%PYTHON_SITELIBDIR%%/pyspatialite/test/dump.pyo
+%%PYTHON_SITELIBDIR%%/pyspatialite/test/factory.py
+%%PYTHON_SITELIBDIR%%/pyspatialite/test/factory.pyc
+%%PYTHON_SITELIBDIR%%/pyspatialite/test/factory.pyo
+%%PYTHON_SITELIBDIR%%/pyspatialite/test/hooks.py
+%%PYTHON_SITELIBDIR%%/pyspatialite/test/hooks.pyc
+%%PYTHON_SITELIBDIR%%/pyspatialite/test/hooks.pyo
+%%PYTHON_SITELIBDIR%%/pyspatialite/test/py25/__init__.py
+%%PYTHON_SITELIBDIR%%/pyspatialite/test/py25/__init__.pyc
+%%PYTHON_SITELIBDIR%%/pyspatialite/test/py25/__init__.pyo
+%%PYTHON_SITELIBDIR%%/pyspatialite/test/py25/py25tests.py
+%%PYTHON_SITELIBDIR%%/pyspatialite/test/py25/py25tests.pyc
+%%PYTHON_SITELIBDIR%%/pyspatialite/test/py25/py25tests.pyo
+%%PYTHON_SITELIBDIR%%/pyspatialite/test/regression.py
+%%PYTHON_SITELIBDIR%%/pyspatialite/test/regression.pyc
+%%PYTHON_SITELIBDIR%%/pyspatialite/test/regression.pyo
+%%PYTHON_SITELIBDIR%%/pyspatialite/test/spatial.py
+%%PYTHON_SITELIBDIR%%/pyspatialite/test/spatial.pyc
+%%PYTHON_SITELIBDIR%%/pyspatialite/test/spatial.pyo
+%%PYTHON_SITELIBDIR%%/pyspatialite/test/transactions.py
+%%PYTHON_SITELIBDIR%%/pyspatialite/test/transactions.pyc
+%%PYTHON_SITELIBDIR%%/pyspatialite/test/transactions.pyo
+%%PYTHON_SITELIBDIR%%/pyspatialite/test/types.py
+%%PYTHON_SITELIBDIR%%/pyspatialite/test/types.pyc
+%%PYTHON_SITELIBDIR%%/pyspatialite/test/types.pyo
+%%PYTHON_SITELIBDIR%%/pyspatialite/test/userfunctions.py
+%%PYTHON_SITELIBDIR%%/pyspatialite/test/userfunctions.pyc
+%%PYTHON_SITELIBDIR%%/pyspatialite/test/userfunctions.pyo
+%%DOCSDIR%%/install-source.txt
+@dirrm %%DOCSDIR%%/code
+@dirrm %%DOCSDIR%%
+@dirrm %%PYTHON_SITELIBDIR%%/pyspatialite/test/py25
+@dirrm %%PYTHON_SITELIBDIR%%/pyspatialite/test
+@dirrm %%PYTHON_SITELIBDIR%%/pyspatialite
_______________________________________________
svn-ports-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-ports-all
To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
Comment 7 Pawel Pekala freebsd_committer freebsd_triage 2013-03-27 16:59:36 UTC
State Changed
From-To: feedback->closed

New port added, with minor changes. Thanks!