Open YKdvd opened 3 years ago
Sorry, my bad. I have never used it with Python 2. Since Python 2 (and even Python 3.5) is end-of-life, I don't plan on working on it. However, I think it works with Python 2 too. Feel free to submit a pull-request.
Unfortunately, the VFX/3D animation industry has been especially recalcitrant in supporting Python 3, and major applications like Autodesk's Maya, Pixar's Renderman, and Nuke are only now just releasing versions incorporating Python 3 (generally 3.7). So I'll need to support Python 2 in our codebase for another year or so for current productions, but I wanted to use the nifty __init_subclass__ feature from 3.6+, and this module was what I came across.
I've forked this and done some patches that seem to work to support 2.7. I had to change a couple of super() calls to the old 2.7 two-parm version, and explicitly derive PEP487Base from "object". The metaclass syntax is different in 2.7 and 3.x, so I borrowed inline the "with_metaclass" helper from the "six" project (with attribution) so as not to create a dependency on the actual six package.
It seemed to pass the tests, including one I added to cover the __init_subclass__ usage explicitly. I'll keep trying it out in our code, and if it seems okay I can do a pull request if you're interested.
diff of initial changes in my fork: https://github.com/YKdvd/pep487/commit/6f9b265cd2b0623c887262a62c9dbc6c8778853b
Yes, init_subclass
is quite nice!
I have added some comments in above diff. If you address these, I would like to merge your pull request.
My only Python 3.x<6 interpreter handy is a 3.5 over on a linux box, which my Pycharm no longer seems to like, so I forgot to merge some cleanup into what I pushed to the fork here. I've got that consolidated now, and pushed to the fork. I'll see if anything crops up, and will do a PR later this week when I get a chance.
1.0.2b2+iom in my fork: https://github.com/zaehlwerk/pep487/compare/master...YKdvd:py27_support
The code docs and README say "This is a backport of PEP487's simpler customisation ... for Python versions before 3.6.", which implies 2.x support. The setup.cfg has "universal=1" in "[bdist.wheel]", which produces a "pep487-1.0.1-py2.py3-none-any.whl " wheel for PyPi, which explicitly promises py2 support, and which installs on Python 2.7 systems via pip.
However, the actual code seems to be for Python 3+ only, as it uses the new "super()" and "metaclass=" syntax from Python 3. It would be nice if this could be cleaned up to be clear that Python 2.7 is not supported.
But, would this backport work with Python 2.7 if the super() calls were changed to the old format, and the six.with_metaclass() wrapper used in the definitions of the PEP487Object and ABC classes, and PEP487Base explicitly inherited from object?