0

My 2.x/3.x python module shows exceptions on install when installing with Python versions before 3.3.

Some files use yield from syntax introduced in Python 3.3, and setup.py tries to compile everything on install, resulting in syntax errors and stack trace displays under versions before 3.3

The 3.3+ code is isolated in its own files and conditionally imported, so the compile error has no impact on run-time use of the module under any version, but it displays ugly error messages on install, as described above.

I could wrap each 3.3+ code block in a triple-quoted string, eval it, and catch compile errors, but that makes maintenance arbitrarily harder, so I am hoping for a more elegant solution.

Rdbhost
  • 929
  • 2
  • 8
  • 20
  • Are you using virtual environments? With virtualenv you can use pip to install the correct version of a library depending on the version of the interpreter. – Apalala Jan 30 '14 at 15:21
  • That would require producing multiple versions of the library, for pip to choose from. I am trying to avoid that multiple version situation. – Rdbhost Jan 31 '14 at 21:45
  • Armin Ronacher wrote a [nice article](http://lucumr.pocoo.org/2013/5/21/porting-to-python-3-redux/) about how to support 2.7 and 3.x with the same source code. I wrote [Grako](https://pypi.python.org/pypi/grako/) using those techniques. For other apps, I've found some features of [Six](https://pypi.python.org/pypi/six/) useful, but I think it's best to avoid using it. – Apalala Feb 02 '14 at 14:30
  • As to "yield from", there's an answer at [here](http://stackoverflow.com/a/17581401/545637). – Apalala Feb 02 '14 at 14:35

0 Answers0