-
Notifications
You must be signed in to change notification settings - Fork 1
Weekly Report IX (July 23~July 29)
As planned last week, the process of this week is listed as follows.
- Update the
travis-ci
automatic build matrix of the project. Now the build matrix is as follows. - Finish the pending module migration. Now all the modules have been migrated to Python 3. In addition, all of the modules have passed the test on both Python 2 and 3, see the build report on https://travis-ci.org/kbandla/dpkt/builds/72835972 for details.
- Solve the problems and suggestions Kiran mentioned during last discussion.
- Update the migration notes. See https://github.com/kbandla/dpkt/blob/migrate_py3/MigrationNotes.md for details.
Some technical details for last weeks are listed as follows.
Test related
The build failure problem we met last week is due to the mechanism of travis
. First it will config the tox
environment, then the tox
will run on the virtual machine. In addition, tox
will first build every module in the package and dpkt3.py
cannot be interpreted on Python 3.
The solution is to update the metaclass migration approach.
Metaclass migration
Based on http://python-3-patterns-idioms-test.readthedocs.org/en/latest/Metaprogramming.html.
The equivalent of:
class C: pass
is:
C = type('C', (), {})
Thus the metaclass syntax in dpkt.py
module can be modified, which is both Python 2 and 3 compatible, as follows.
class Packet(_MetaPacket("Temp", (object,), {}))
Import related
Python 3 changes the syntax for imports from within a package, requiring you to use the relative import syntax, saying
from . import mymodule
instead of the justimport mymodule
.
Kiran mentioned a problem when setup on Python 3 (See below). The relative import is the key point. After fixing the import statements, this issue has been fixed.
Traceback (most recent call last):
File "setup.py", line 18, in <module>
package = __import__(package_name)
File "/home/travis/build/kbandla/dpkt/dpkt/__init__.py", line 11, in <module>
import ah
ImportError: No module named 'ah'
ERROR: FAIL could not package project - v = InvocationError('/home/travis/virtualenv/python3.4.2/bin/python /home/travis/build/kbandla/dpkt/setup.py sdist --formats=zip --dist-dir /home/travis/build/kbandla/dpkt/.tox/dist (see /home/travis/build/kbandla/dpkt/.tox/log/tox-0.log)', 1)
- Now the
migrate_py3
branch is 9 commits behindmaster
. I need to update the recent change to the migration branch. - Send a PR for the migration. Ask for code review and update the code based on the comments.
- Continue updating the migration notes.
- If there's extra time, I'll add some documentation to the project, which is also planned several weeks ago.