audiogen
audiogen copied to clipboard
Python3 compatibility
Hello, It would be nice to make audiogen compatible with python 3.x installing it with pip generates syntax errors :
Running setup.py install for audiogen
File "/usr/local/lib/python3.4/dist-packages/audiogen/util.py", line 28
print "cropping %d channel(s) to %d samples each" % (len(gens), seconds * sampler.FRAME_RATE)
^
SyntaxError: invalid syntax
File "/usr/local/lib/python3.4/dist-packages/audiogen/sampler.py", line 64
except IOError, e:
^
SyntaxError: invalid syntax
I tried to convert everything using 2to3, but I still have problems :
>>> import audiogen
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/konfiot/audiogen/audiogen/__init__.py", line 2, in <module>
from .sampler import frame_rate
File "/home/konfiot/audiogen/audiogen/sampler.py", line 21, in <module>
from .util import hard_clip
File "/home/konfiot/audiogen/audiogen/util.py", line 10, in <module>
from . import sampler
ImportError: cannot import name 'sampler'
It looks like an infinite inclusion problem : sampler.py includes util, which includes sampler, ...
it seems that util only uses the FRAME_RATE constant from sampler.py I just declared FRAME_RATE in util and removed util inclusions and it seems to work.
Thanks for your work with Python3 compatibility!
I've only had time to skim your patches, but I did see a few places that might cause Python2 compatibility issues. I think one of the biggest problems will be that range() etc. are not generators in Python 2, which is a blocker for audiogen, since it relies on infinitely long generators.
It'd be nice to avoid compatibility libraries like six, but it may be necessary for Python3 support. Let me know if you make any progress on this. When I have a bit more time, I'll try to go through the issues more closely and see if I can start fixing them.
I think I will move the constants to a separate module first, though – while the circular imports really ought to work, there's no need for it here.
Since python2 support is ending in a few months, you might consider just dropping support for python2. Once it is configured in setup.py
, python2 users will just get the last release that supported python2.