Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert to python 3 #41

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open

Convert to python 3 #41

wants to merge 17 commits into from

Conversation

aizvorski
Copy link

@aizvorski aizvorski commented Jan 7, 2024

This pull request converts pmx from python 2 to 3

Most of the conversion was automatic, the steps were as follows:

  • reindent --recurse . to fix the mixed tabs/spaces indentation
  • 2to3 --write . to make all the changes that 2to3 knows about: make print statements into functions, etc
  • update some relative imports: for example import _pmx becomes from . import _pmx
  • update C code: PyInt_AsLong becomes PyLong_AsLong, Py_InitModule3 becomes PyModule_Create, etc
  • a bunch of small fixes: replace string.join() and split() with python3 equivalents, remove __cmp__(), etc
  • modify the examples to be usable as a pytest test suite: run using inputs from protLig_benchmark where possible
  • add a Github workflow to build and test

This should work with essentially any version of python 3; tested on 3.10. There hasn't been much effort to keep backwards compatibility: python 3 has been around since 2008, and python 2.x was officially EOL in 2020. In some cases backwards compatibility would be relatively easy (the C API changes are probably already compatible), but it would be a substantial amount of work to really pull it off.

Testing:

  • the examples run successfully (except for ones for which I don't have the right input files)
  • the examples can be run with pytest; there’s also a GitHub workflow that does that automatically
  • not yet tested for correctness / regression

I'd really like to set up a regression test comparing old vs new outputs, and ideally on a larger/more complex example like building the edge files in protLig_benchmark. Please let me know if you have something like that that runs in the old version and I can set up the comparison.

Also please let me know if there is anything else you'd like to see before you consider merging this.

@zetadin
Copy link

zetadin commented Jan 8, 2024

I though the develop branch was already on python 3. The changes were just never merged to the main branch.

@aizvorski
Copy link
Author

@zetadin Hmm, you’re right! I didn’t know that. The 2 to 3 conversion is done in a very similar way there - I compared the C code and it’s almost exactly the same.

It also looks like the develop branch has a bunch of other feature changes as well as the 2 to 3 conversion. It might be nice to just do this (and thoroughly regression test) then apply the other changes on top. That sounds like probably two major version numbers, pmx 3.0 for python 3 (kinda rhymes) and 4.0 for the new features.

I’ll wait for @vgapsys to have a look. In any case happy to help port/package/test/etc

@vgapsys
Copy link
Member

vgapsys commented Jan 8, 2024

Hey @aizvorski, thanks for the interest in pmx.

As @zetadin wrote, the 'develop' branch is already in python 3. It also has many new functions and reworked mutation libraries. Unit testing is in part supported, but regression tests are not there. If you are interested in development, testing etc, it would be best to start with the 'develop' branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants