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

Use python 3.9 #197

Merged
merged 25 commits into from
Jan 5, 2023
Merged

Use python 3.9 #197

merged 25 commits into from
Jan 5, 2023

Conversation

oyvindio
Copy link
Member

@oyvindio oyvindio commented Dec 16, 2022

Switch from python 2.7 to 3.9.

I picked python 3.9 to get up to python 3.x with the least amount of changes, as using 3.10 or 3.11 will require updating some dependencies since 3.10 removes a few things that have been deprecated for some time.

Summary of changes:

  • Automatically updated all code with 2to3. This is mostly removal of unicode literals and __future__ imports, wrapping calls to APIs which have changed to return a different iterable type in list() and a few other changes.
  • Replace hash() with py27hash for generating ApplicationStatus names to ensure the same names as python2 fiaas-deploy-daemon would generate.
  • Several fixes for transforming bytes to unicode and vice versa.
  • Use unittest.mock and time.monotonic from stdlib, drop 3rd party dependencies.
  • pin Flask related dependencies, upgrading from flask 1.x to 2.x should be done later.
  • Fix issue with running e2e tests requiring the same fiaas-deploy-daemon + kind cluster fixures on different worker processes. When this happens additional time is spent starting a kind cluster and fiaas-deploy-daemon combination which is already available in another test worker, which increased test duration. Total e2e test duration should now be a bit faster and more consistent.

closes #6

This is the result of `2to3 --write --nobackups fiaas_deploy_daemon/ setup.py tests/ bin/`
Flask should be upgraded to 2.x. For the purposes of switching to
python3, keep it at 1.x to minimize amount of changes at the same time.
Remove logic to set traceback and message explicitly in UpsertConflict,
rely on raise from.

Also add a test for UpsertConflict.__str__
How did this work before?
python3 dicts are ordered so some tests relying on this fails
The hash builtin function is used to create name suffixes for
ApplicationStatus resources. In Python 3 this function has changed to a
different algorithm which also uses a random seed set at interpreter
start. Use py27hash to "forward-port" the Python 2 hash function so that
Python 3 based fiaas-deploy-daemon can look up ApplicationStatus
resources created by Python 2 based fiaas-deploy-daemon and the other
way around
Recent versions of pip won't build wheels properly for releases that
don't have PEP440 compliant versions. Switch the development release tag
from `-SNAPSHOT` to `.dev`, which is the PEP440 compliant way of tagging
a development release[1].

[1]: https://peps.python.org/pep-0440/#developmental-releases
AssertionError (and other exceptions) no longer have the message
attribute. Use exception chaining to add the additional information
The order these appear in has changed because of changes in dict
ordering in python2 -> python3. It has no effect on the resulting
deployment, so just update the expected result for the tests
subprocess output is bytes. decode to string so it renders better in
error messages.
When using `sem-version python`, `python` is provided via a
virtualenv. Because of this `--user` install isn't necessary (and does
not work), so do a regular `pip install` into the virtualenv for CI
dependencies.
Mostly whitespace as well as a few unused imports after making code py3 compatible
@oyvindio oyvindio requested a review from a team as a code owner December 16, 2022 12:28
Copy link
Contributor

@henrik242 henrik242 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

@birgirst
Copy link
Contributor

Awesome work @oyvindio ! I’ll have a look through.

Copy link
Contributor

@birgirst birgirst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@oyvindio oyvindio merged commit 401e604 into master Jan 5, 2023
@oyvindio oyvindio deleted the python3-take-2 branch January 5, 2023 09:21
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.

Upgrade to python 3
3 participants