RDFLib and Python 3

206 views
Skip to first unread message

Garu

unread,
Oct 19, 2010, 5:55:23 AM10/19/10
to rdflib-dev
Hello, I'm working on a project based on RDF and I'm using Python3.
Since I wanted to use your project to manage and manipulate RDF data,
I ported the code to Python3. Would you be interested to open a trunk
with that code for Python3?

Cheers
Michele

Niklas Lindström

unread,
Mar 11, 2011, 4:31:14 AM3/11/11
to rdfli...@googlegroups.com, Garu
Garu, all,

I recalled this mail (from october last year) when the question
regarding RDFLib 3.0 popped up again on the list just now.

Garu, do you have this port publicly somewhere; and have you tracked
the continued updates of rdflib trunk since?

Anyway, AFAIK, the proper way to port libraries to Python 3 is still
to make sure it works on 2.6+, and then use 2to3 to autogenerate a
Py3-compatible version (i.e. strive to never manually fix stuff in the
port, only in the 2.x-version, until the 2.x support eventually goes
away (in 5-10 years? ;D)).

I remember trying to do this on RDFLib about a year ago, and bumped
into a bunch of (sort of expected) unicode things.

.. Anyway, it would be very nice to have a 3-compatible
(autogenerated) rdflib! Of course. :)

Best regards,
Niklas

> --
> You received this message because you are subscribed to the Google Groups "rdflib-dev" group.
> To post to this group, send email to rdfli...@googlegroups.com.
> To unsubscribe from this group, send email to rdflib-dev+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/rdflib-dev?hl=en.
>
>

Gunnar Aastrand Grimnes

unread,
Mar 11, 2011, 4:36:41 AM3/11/11
to rdfli...@googlegroups.com, Niklas Lindström, Garu
I believe that having rdflib terms like URIRef, Literal etc.
sub-classing unicode gives us some interesting problems, that I doubt
2to3 will solve for us.
Anyone is of course welcome to try! :)

- Gunnar

2011/3/11 Niklas Lindström <linds...@gmail.com>:

--
http://gromgull.net

Roland Hedberg

unread,
Mar 11, 2011, 8:49:47 AM3/11/11
to rdfli...@googlegroups.com, Niklas Lindström, Garu

On Mar 11, 2011, at 10:36, Gunnar Aastrand Grimnes wrote:

> I believe that having rdflib terms like URIRef, Literal etc.
> sub-classing unicode gives us some interesting problems, that I doubt
> 2to3 will solve for us.
> Anyone is of course welcome to try! :)

I'm at Pycon right now, and here there is of course lots of talk about porting to Python 3.
Anyone of the rdflib core developers here ?

The consensus though is that 2to3 will only get you so far and that there is no way you can do a completely automagic porting.
As Gunnar brings up the major stumbling block is the split of strings into bytes and unicode.

--Roland

Garu

unread,
Mar 18, 2011, 4:30:39 AM3/18/11
to rdflib-dev
Hi all,
to answer quickly to your questions:
yes, I've done a porting of RDFLib to Python 3
I don't have any repo out on the net, just a zip file I can send you
or upload on some sites (google docs or dropbox)
2to3 is not enough, I had to manually fix many things, especially
string related problems as you mentioned
I haven't worked on the library since december, but it was working
quite good and I have even written a wrapper for CouchDB to use it as
a triple store
also, I remember that I was able to run almost all the tests
succesfully
Just let me know if you would like to have the code I've worked on,
I'll be glad to send it to you.

Michele (Garu is just the nickname) ;)

Micky Stawo

unread,
Mar 14, 2011, 10:07:32 AM3/14/11
to Roland Hedberg, rdfli...@googlegroups.com, Niklas Lindström
Hi all,
to answer quickly to your questions:
  1. yes, I've done a porting of RDFLib to Python 3
  2. I don't have any repo out on the net, just a zip file I can send you or upload on some sites (google docs or dropbox)
  3. 2to3 is not enough, I had to manually fix many things, especially string related problems as you mentioned
  4. I haven't worked on the library since december, but it was working quite good and I have even written a wrapper for CouchDB to use it as a triple store
  5. also, I remember that I was able to run almost all the tests succesfully
Just let me know if you would like to have the code I've worked on, I'll be glad to send it to you.

Michele (Garu is just the nickname) ;)

2011/3/11 Roland Hedberg <roland....@adm.umu.se>

Gunnar Aastrand Grimnes

unread,
Mar 22, 2011, 1:49:06 PM3/22/11
to rdfli...@googlegroups.com, Micky Stawo, Roland Hedberg, Niklas Lindström
Garu / Michele,

I would love to have the code - it should be small enough to send it
to gromgull <AT> gmail dot com ?

You do not mind if I upload it to google code I hope?

- Gunnar

Rajeev Sebastian

unread,
Mar 22, 2011, 3:57:06 PM3/22/11
to rdfli...@googlegroups.com
I would also like to see the code if possible. rajeev dot sebastian at gmail dot com

Gunnar Aastrand Grimnes

unread,
Mar 23, 2011, 6:17:51 AM3/23/11
to rdfli...@googlegroups.com, Rajeev Sebastian
All,

I have committed Michele's code to https://bitbucket.org/gromgull/rdflib-python3

I did not yet have a chance to look at it (first I have to install python 3:)

- Gunnar

Graham Higgins

unread,
Mar 23, 2011, 6:43:13 AM3/23/11
to rdfli...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 23 Mar 2011, at 10:17, Gunnar Aastrand Grimnes wrote:
> All,
>
> I have committed Michele's code to https://bitbucket.org/gromgull/rdflib-python3
>
> I did not yet have a chance to look at it (first I have to install
> python 3:)


Under Python 3.2, an hg clone and a nosetests yields:

> ======================================================================
> ERROR: testEvents (test.test_events.EventTestCase)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
> File "{src}/rdflib-python3/test/test_events.py", line 57, in
> testEvents
> assert ('bob' in c1) == False
> File "{src}/rdflib-python3/test/test_events.py", line 34, in
> __getitem__
> return self._data[key]
> KeyError: 0
>
> ======================================================================
> FAIL: testModel (test.test_n3.TestN3Case)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
> File "{src}/rdflib-python3/test/test_n3.py", line 148, in testModel
> self.assertEquals(i, 3)
> AssertionError: 0 != 3
>
> ======================================================================
> FAIL: test.test_n3_2.testN3Store
> ----------------------------------------------------------------------
> Traceback (most recent call last):
> File "{py3}/nose-1.0.0-py3.2.egg/nose/case.py", line 188, in runTest
> self.test(*self.arg)
> File "{src}/rdflib-python3/test/test_n3_2.py", line 32, in
> testN3Store
> assert type(formulaA)==QuotedGraph and type(formulaB)==QuotedGraph
> AssertionError
>
> ======================================================================
> FAIL: testIssue78 (test.test_nt.NTTestCase)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
> File "{src}/rdflib-python3/test/test_nt.py", line 13, in testIssue78
> self.assertTrue(r"R\u00E4ksm\u00F6rg\u00E5s" in s)
> AssertionError: False is not true
>
> ======================================================================
> FAIL: testSerialize (test.test_trix_serialize.TestTrixSerialize)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
> File "{src}/rdflib-python3/test/test_trix_serialize.py", line 59,
> in testSerialize
> self.assertTrue(q[0:3] in tg)
> AssertionError: False is not true
>
> ----------------------------------------------------------------------
> Ran 221 tests in 4.275s
>
> FAILED (errors=1, failures=4)

Looking /very/ good, props to Michele.

- --
Cheers,

Graham

http://bel-epa.com/gjh/


-----BEGIN PGP SIGNATURE-----

iEYEARECAAYFAk2JzsEACgkQOsmLt1NhivwZGQCdEImp05PaxP9lavSz8V69bNMc
H2MAn1XNVNJSY2oACzsa3FCsZqE6h1wWiQCVAgUBTYnOwVnrWVZ7aXD1AQKIsgP9
EiDXyER/+AnbSH8XvbTer66Lzc/SSNTsYciPiO+WMvZDxr1LrseMdK8rey55Q6uS
BErEFrznc27h2Hchl2zXvGSTIMrUNfnjsvg/T4MPNQQdu1dzaq/aBHGa3R91V9Z2
5Y2tOBmrubLPjqHSXwzdVgxCjLIxHBCygks/Tu726P4=
=JHun
-----END PGP SIGNATURE-----

Niklas Lindström

unread,
Mar 23, 2011, 11:52:28 AM3/23/11
to rdfli...@googlegroups.com, Gunnar Aastrand Grimnes, Rajeev Sebastian
Hi all!

This it great! Just a quick idea before I forget it. If is a solid
port (and it sounds like it by Graham's remark), consider this
scenario:

1. First off, converting rdflib at googlecode to mercurial (so
merging will be easy).
2. Create a branch there and copy over this code (e.g. py3compat).
3. Backport this entirely to work on Python 2.6, and then generate a
Py3 version with 2to3.
4. Diff and merge with master to make sure the branch is up to speed.
5. If the stuff also works on 2.5, merge this into rdflib master and
carry on from there.

This might prove less daunting than it sounds -- and if it works it'll
be a rock-solid path into the future. :)

Best regards,
Niklas
--
<http://neverspace.net/>

On Wed, Mar 23, 2011 at 11:17 AM, Gunnar Aastrand Grimnes

Chimezie Ogbuji

unread,
Mar 23, 2011, 12:02:17 PM3/23/11
to rdfli...@googlegroups.com
Hello,

On Fri, Mar 18, 2011 at 4:30 AM, Garu <stawo...@gmail.com> wrote:
> I haven't worked on the library since december, but it was working
> quite good and I have even written a wrapper for CouchDB to use it as
> a triple store

> ..snip..


> Just let me know if you would like to have the code I've worked on,
> I'll be glad to send it to you.

I would be very interested in seeing this CouchDB wrapper

-- Chime

Gunnar Aastrand Grimnes

unread,
Mar 23, 2011, 12:19:48 PM3/23/11
to rdfli...@googlegroups.com, Chimezie Ogbuji
Yes me to!

Google user fertapric also commented here :
http://code.google.com/p/rdflib/issues/detail?id=163

that he is working on a mongodb store - it would be nice to compare!

Also Garu/Michele - apologies for not answering your email back in october!

- Gunnar

Graham Higgins

unread,
Mar 24, 2011, 12:04:01 AM3/24/11
to rdfli...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 23 Mar 2011, at 15:52, Niklas Lindström wrote:

> 3. Backport this entirely to work on Python 2.6, and then generate a
> Py3 version with 2to3.
> 4. Diff and merge with master to make sure the branch is up to speed.
> 5. If the stuff also works on 2.5, merge this into rdflib master and
> carry on from there.
>
> This might prove less daunting than it sounds

Perhaps a diff produced by lib3to2 [1] could have a contribution to
make, either to the backporting to 2.6/5 or possibly to a third
approach - a unified package that runs under both Python 2 and 3.

[1] https://bitbucket.org/amentajo/lib3to2


- --
Cheers,

Graham

http://bel-epa.com/gjh/


-----BEGIN PGP SIGNATURE-----

iEYEARECAAYFAk2KwrEACgkQOsmLt1NhivynYwCgrho9jCU0ShFpIilSyy0cHbTN
th4AoLr+L5DW9zKReAuQVeroWzbfuYJliQCVAgUBTYrCsVnrWVZ7aXD1AQIM4gQA
roalUnFj9CBvWQUvRjcUvphTBX8HANiOkpPI/rodVNETNdvMr8nsDB0gzu8V0yOt
11Iiocj7S/UJP3zxeLvreXCYwdl8S7RPfZVl0Z2IZamAoYKDk9KJ+Fbs2OhVOQKJ
ZhGLe+ctRfGu730iFqBrijz1b1Aws8/5OzcX8ta7Q0A=
=UwQH
-----END PGP SIGNATURE-----

Reply all
Reply to author
Forward
0 new messages