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

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

Closed
dbs opened this issue Aug 12, 2013 · 6 comments
Closed

Comments

@dbs
Copy link

dbs commented Aug 12, 2013

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
Copy link
Member

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
Copy link
Member

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

@dbs
Copy link
Author

dbs commented Aug 13, 2013

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
Copy link
Contributor

iherman commented Aug 13, 2013

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
Copy link
Member

@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
Copy link
Member

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

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

No branches or pull requests

4 participants