markgw / pimlico

The Pimlico Processing Toolkit
http://pimlico.readthedocs.org/
GNU Lesser General Public License v3.0
6 stars 1 forks source link

Make Python 2-3 compatible #8

Closed markgw closed 5 years ago

markgw commented 7 years ago

We really need Pimlico to be compatible with both Python 2 and Python 3. Otherwise, people who use Python 3 will be put off from using Pimlico because they'd have to write their own modules in Python 2, or even worse if they're using their previously existing Python 3 code within Pimlico modules. For the same reasons, compatibility is better than just moving to Python 3.

This is a major change that will affect every Python source file in the project. It should be carried out in a branch and probably only after I've implemented much more comprehensive testing (#7), so I can find where it breaks things.

I think that most of the libraries Pimlico uses are 2-3 compatible, but should check this: if there are much-used libraries that don't support Python 3, we'll end up with modules or features that only work if you're using Python 2, which would be nasty.

markgw commented 5 years ago

I plan to use the future library for this.

We will use the 2-stage conversion process. Run futurize --stage1 first on the entire codebase. Then run stage2 and check all of the changes.

Because of the complexity of the codebase and some of the fancy importing stuff we do, it's possible stage2 could break things, so it will be important to ensure that those changes are tested in Py2 and 3.

This change is becoming a high priority, as it's stopping people from using Pimlico.

markgw commented 5 years ago

To be addressed in python3 branch.

Module tests and other unit tests are far from comprehensive, but there's probably enough to get started on this and I need to get started asap, as it's blocking people from using Pimlico.

markgw commented 5 years ago

Steps carried out to get started:

The entire codebase is now Python 3-like, but not yet runnable in Python 3.

Next we'll need to run stage 2, which is more dangerous and will require a lot of work to make sure everything is working.

markgw commented 5 years ago

Work now continues on stage 2.

The command futurize --stage2 -w src/python applies potentially dangerous conversions to make the code Python 3 compatible. I'll be reviewing the changes it's made manually and committing them as I go.

After that, I will run pipeline and unit tests and get things working. This means that, until then, the code might not be usable.

markgw commented 5 years ago

Working through all the files now. To-do list:

markgw commented 5 years ago

About halway through the manual checks on stage 2 conversion at 4415c00e70448b9d3b83c92095a4f72bb5664e78.

Now got a lot of pipeline tests running. Some are still failing, of course:

markgw commented 5 years ago

Finished all manual checks of automatic stage 2 conversion in e0b888e.

Still the same pipeline tests failing given above.

Next steps:

markgw commented 5 years ago

863c43d does stage 1 futurize for unit tests.

44588b4 does stage 2 futurize.

markgw commented 5 years ago

All unit tests and test pipelines passing in Python 2, from d60fc0cbf457706826f94a01bc34360b36764c27.

Next step is to work out how to specify using Python 3 or 2 for virtualenv creation process.

Then allow tests (unit and pipeline) to be run for both Py 2 and 3.

Then run the tests in Py 3 and address issues.

markgw commented 5 years ago

All test pipelines passing in both Python 2 and 3, as of 8d7047f4e31c92fa47b158dd82ea6c640bb26a88!

Unit tests not working yet. (Mostly for Python 2, but not at all for Python 3.)

markgw commented 5 years ago

All tests now passing on Py 2 and 3!

markgw commented 5 years ago

There are still some modules that need to be updated to the new datatypes system and these also need to be tested in Python 2&3. However, other than these (which need to be fixed anyway), everything seems to be working and pretty stable now.

Merge python3 branch in afd2ff5db87321a96d4dee63b5da558dfc6eb7ee.

Closing this issue, since this project is pretty much done! Woopee!