RDFLib / pyrdfa3

RDFa 1.1 distiller/parser library: can extract RDFa 1.1 (and RDFa 1.0, if properly set via a @version attribute) from (X)HTML, SVG, or XML in general. The module can be used to produce serialized versions of the extracted graph, or simply an RDFLib Graph.
http://www.w3.org/2012/pyRdfa/
Other
67 stars 22 forks source link

Error installing pyRdfaExtras due to tuple unpacking using Python 3.3 #7

Closed dbs closed 11 years ago

dbs commented 11 years ago

Although README.txt claims "The package has been adapted to Python 3", attempting to install pyrdfa3 under Python 3.3 fails with a syntax error in the pyRdfaExtras directory.

Steps to reproduce:

  1. Setting up the environment: virtualenv --python=/usr/bin/python3.3 ~/schema_rdfa git clone https://github.com/RDFLib/pyrdfa3.git cd pyrdfa3
  2. Installing the package: ~/schema_rdfa/bin/python setup.py install
  3. Error: ... byte-compiling /home/dan/schema_rdfa/lib/python3.3/site-packages/pyRdfaExtras/init.py to init.cpython-33.pyc File "/home/dan/schema_rdfa/lib/python3.3/site-packages/pyRdfaExtras/init.py", line 112 def add(self, (s,p,o)) : ^ SyntaxError: invalid syntax

It looks like Python 3 dropped support for using tuples directly in method signatures like this five years ago via PEP 3113 (http://www.python.org/dev/peps/pep-3113/) with warnings added as of Python 2.6. I expect the alternative would be something like "def add(self, triple)" and then checking to ensure that triple[0], [1], and [2] were all defined.

Looking over RDFlib itself, it seems that the API is rife with tuple unpacking behaviour :/

gromgull commented 11 years ago

Without checking, I believe the tuple unpacking is fixed by 2to3 - maybe pyrdfa3 lacks a proper setup script that includes running 2to3, but pyrdfa is included in rdflib>4, there the installation defn. works for 3.2 and 3.3

gromgull commented 11 years ago

Actually checking, looks like it's exactly what happened: http://www.python.org/dev/peps/pep-3113/#transition-plan

dbs commented 11 years ago

gromgull: Thanks. Yes, if setup.py included a 2to3 step in this repository, that would correct the problem here, but it doesn't. Alternately, given that manually unpacking the tuples works in both Python 2.x and 3.x, I could work up a branch that removes the need for 2to3 for that purpose (leading to more legible code for those used to Python 2.6+). Not requiring a transform step should also make it easier for new contributors to pull the code from git & test & run it.

iherman commented 11 years ago

Dan,

sorry about that; I took care of this (and updated github).

As for the RDFLib core package, I wonder why this problem has not manifested itself already. I will forward your mail to those who really maintain the package...

Cheers

Ivan

On Aug 12, 2013, at 17:58 , Dan Scott notifications@github.com wrote:

Although README.txt claims "The package has been adapted to Python 3", attempting to install pyrdfa3 under Python 3.3 fails with a syntax error in the pyRdfaExtras directory.

Steps to reproduce:

• Setting up the environment: virtualenv --python=/usr/bin/python3.3 ~/schema_rdfa git clone https://github.com/RDFLib/pyrdfa3.git cd pyrdfa3

• Installing the package: ~/schema_rdfa/bin/python setup.py install

• Error: ... byte-compiling /home/dan/schema_rdfa/lib/python3.3/site-packages/pyRdfaExtras/init.py to init.cpython-33.pyc File "/home/dan/schema_rdfa/lib/python3.3/site-packages/pyRdfaExtras/init.py", line 112 def add(self, (s,p,o)) : ^ SyntaxError: invalid syntax

It looks like Python 3 dropped support for using tuples directly in method signatures like this five years ago via PEP 3113 (http://www.python.org/dev/peps/pep-3113/) with warnings added as of Python 2.6. I expect the alternative would be something like "def add(self, triple)" and then checking to ensure that triple[0], [1], and [2] were all defined.

Looking over RDFlib itself, it seems that the API is rife with tuple unpacking behaviour :/

— Reply to this email directly or view it on GitHub.


Ivan Herman 4, rue Beauvallon, clos St Joseph 13090 Aix-en-Provence France http://www.ivan-herman.net

joernhees commented 11 years ago

@iherman i think @gromgull already explained this: in the core rdflib the setup.py does the 2to3 magic, while in this standalone it is not invoked. That's why it didn't manifest itself in rdflib core but here.

joernhees commented 11 years ago

i'll close this in favor of #9 for now, reopen if necessary