Search code examples
ubuntupython-3.xtwisted

Why isn't serialport.py installed by default?


I'm using Ubuntu in several PCs (versions 12.04 and 14.04), and I noticed that serialprotocol.py is not being installed when I run "sudo python3 setup3.py install" in the default source tar package for twisted 14.0.0.

I had to manually copy the file in my computers. I also tried installing the default ubuntu package python3-twisted-experimental with the same results. So I always end up copying "serialprotocol.py" and "_posixserialport.py" manually. And they work fine after that.

As a side note: _posixserialport.py fails to import BaseSerialPort because it says: from serialport import BaseSerialPort but it should be: from twisted.internet.serialport import BaseSerialPort


Solution

  • Twisted has not been entirely ported to Python 3. Only parts of it have been ported. When you install Twisted using Python 3, only the parts that have been ported are installed. The unported modules are not installed because they are not expected to work.

    As you observed, this code does not actually work on Python 3 because it uses implicit relative imports - a feature which has been removed from Python 3.