Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3 compatibility #5

Closed
funkyfuture opened this issue May 2, 2016 · 14 comments · May be fixed by #18
Closed

Python 3 compatibility #5

funkyfuture opened this issue May 2, 2016 · 14 comments · May be fixed by #18
Assignees

Comments

@funkyfuture
Copy link

ciao, i'm currently evaluating rdf-related libraries for Python. surf is feature- and documentation-wise my favorite atm. unfortunately it lacks Python 3 support.

if i'd give it a shot and refactored the code to support Python 2 and 3, would that be accepted by the maintainers? if so, would using six be okay?

@cosminbasca
Copy link
Owner

Hi @funkyfuture That would be great! Looking forward to it

@funkyfuture
Copy link
Author

and six as a dependency would be okay?

@cosminbasca
Copy link
Owner

yes, six is ok. Thanks!

@cosminbasca cosminbasca self-assigned this May 2, 2016
@funkyfuture
Copy link
Author

hm, when i run the tests with Python 2 i get 15 fails. it hardly makes sense to refactor in that state.

@cosminbasca
Copy link
Owner

@funkyfuture I am planning to streamline surf a bit and drop support for legacy versions of rdflib (2/3) and python (2.5) with the upcoming 1.1.9 version. There will be a couple of notable changes that will happen:

  1. tests will be migrated to pytest from unittest
  2. the surf.rdflib plugin will be integrated in surf directly (not installable as a separate plugin)

this will make testing easier, as for now one needs to install the surf.rdflib plugin in order to run some of the tests. I will spend the next couple of days bringing surf up to speed with these changes and will let you know when this is done.

in addition I am planning tox / travis support for integration tests on PRs. Stay tuned!

@funkyfuture
Copy link
Author

funkyfuture commented May 4, 2016 via email

@cosminbasca
Copy link
Owner

this is the first time I hear about dropbox' migration script. That will come in handy (at least for the plugin tests which I have not yet migrated). Thanks for the heads up!

the docker + tox helper script is most welcome and appreciated 👍

@cosminbasca
Copy link
Owner

ok, I've migrated the tests to py.test and added travis integration (all tests pass for now).
To simplify SuRF's usage, the rdflib and sparql_protocol plugins are now embedded within.

@mromanello
Copy link
Contributor

mromanello commented May 5, 2016

@cosminbasca +1 for the new release, I'm looking forward to trying it out. I'm also very pleased to see that this project is still being actively developed (within the limits of one's time availability, of course ;-) )

@PonteIneptique
Copy link

A potential fix has been proposed in #18

@subwaystation
Copy link

Please fix this.

from surf import *

store = Store(  reader='rdflib',
            writer='rdflib',
            rdflib_store = 'IOMemory')

session = Session(store)

print('Load RDF data')
store.load_triples(source='http://www.w3.org/People/Berners-Lee/card.rdf')

Person = session.get_class(ns.FOAF['Person'])

all_persons = Person.all()

print('Found %d persons that Tim Berners-Lee knows'%(len(all_persons)))
for person in all_persons:
    print(person.foaf_name.first)

#create a person object
somebody = Person()
somebody_else = Person()

somebody.foaf_knows = somebody_else

in python3.7 produces:

Traceback (most recent call last):
  File "../SuRF_TEST.py", line 1, in <module>
    from surf import *
  File "/home/heumos/.local/lib/python3.7/site-packages/surf/__init__.py", line 43, in <module>
    from surf.query import Query, select, ask, describe, construct, OptionalGroup, \
  File "/home/heumos/.local/lib/python3.7/site-packages/surf/query/__init__.py", line 82, in <module>
    class Filter(unicode):
NameError: name 'unicode' is not defined

@datamusee
Copy link

adding

patch pour python3

import sys
if sys.version_info.major >= 3:
unicode = str

to the
surf\query_init_.py
file, seems to solve the
name 'unicode' is not defined
error
But, another error appears in the namespace.py file
RuntimeError: dictionary changed size during iteration

@PonteIneptique
Copy link

Dear all,
I did this pull request a long time ago to help a friend who was using SurfRDF (I never used it) , and it seems this repository is stale. However, @franzist seems to have taken up the mantle and fixed what I did not in his own fork, much more up to date: https://github.com/franzlst/surfrdf/tree/master

I'd like to add that this might be the time where a new Pypi library should get registered, such as SurfingRDF, given how the developers here seem to have abandoned this repository (and this is life, I am definitely not complaining about the status of this repo, everyone can move on to something new)

@PonteIneptique
Copy link

(And honestly, from a personal point of view, I'd drop the support for 2.x Python)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants