Ongoing attempt at Python 3 support (progress towards #203)#242
Ongoing attempt at Python 3 support (progress towards #203)#242rhalbersma wants to merge 6 commits intogambitproject:masterfrom rhalbersma:future
Conversation
|
@tturocy 4 weeks, no feedback so far, how can I improve this PR? |
|
Many thanks for taking this on. At present I'm on a secondment to a very heavy admin role, which leaves me no time or mindspace for computational game theory. So while I am looking forward to having a closer look at this, I don't quite know just when that might be. |
|
I have decided to abandon this effort. The remaining obstacles are a bit beyond my Python skills. As a Gambit user, it is considerably less work for me to continue using the existing Gambit Python 2 API and futurize my own user code scripts. I'll leave this pull request open so that any future attempt to port to Python 3 can use whatever is deemed necessary. |
|
Your efforts on this are appreciated. With the announcement that many of the main scientific python stack packages (like NumPy and pandas) are going to drop Python 2 support for new releases from the start of 2019, this is bubbling up higher in my priority list. However, it's tied up with a number of other packaging issues across the whole project which probably have to be looked at holistically. |
|
Python 2 itself will no longer be maintained in 12 months time: https://pythonclock.org/ |
|
b0f989d now introduces Python 3.7.2 support in the gambit package. |
Introduction
These 6 commits hopefully prepare the ground for a full Python 2 / 3 compatible code base.
Rationale
The commits do the following:
futurebranch.futurizebest practices by running the automated--stage1and--stage2steps, keeping all tests green.futurizedoes not touch Cython files, sofunctools.reduceneeds to be manually imported.python2 -3signalled quite a few deprecated warnings concerning user-defined__eq__functions without an accompanying__hash__function. I have added hash support consistent with equality: if equality is on a tuple/list of class members, then the hashing will be on the same data structure (tuple or list of the data members ofself).python3 setup.py buildbecause of the new Python 3 class system (see this Q&A on StackOverflow).Status
python2 -3 nosetestsgives no warnings in code fromgambit, and only a handful about system code.python3 setup.py buildalso builds without errors.nosetestsin Python3 mode fails on all unit tests, mostly because ofbyte/strincompatibility.Guidance needed
cythoninterface of talking to the C++ code throughstd::stringorchar *. This will keep callers using Python2 happy, but requires converting Python3 unicode string literals tobyte, e.g. using a.encode('utf-8')member function call.char *strings fromc_str()member functions. When those talk to users, then they need to be marshalled through.decode(). Separating the internalc_str()calls from the ones bubbling up to the interface seems quite a bit of work.file()andopen()incompatibilities between Python2 and Python3. The way forward is to useopen()everywhere, with the appropriatebflags for byte stream reading.If you agree with the approach taken so far, I can try and plough ahead with the string and file issues. Merging the pull request would eventually be best done in one squashed commit, or piece meal, whatever your preference is.