-
Notifications
You must be signed in to change notification settings - Fork 33
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
Add support for Python 3.11 #385
Conversation
Opening files with the 'U' mode is now the default behavior in Python 3, has been deprecated and removed in Python 3.11
It will make sense to adjust the tests under https://github.com/ome/openmicroscopy. We have several repositories using The Regarding the test mentioned above |
Line 61 in d22225f
|
|
Opened as ome/openmicroscopy#6369. I can open associated devspace PRs if needed but eventually defer to you guys on when/how these changes should be integrated into the CI environment.
The primary intent was to have OMERO working on Python 3.11. The |
Regarding |
Use mock.patch and mock.patch.object to patch the CLI methods associated with the admin subcommands Use mock asserts to confirm the right arguments are being passed to popen, call, err and out
As shown by the builds of 8360c3f, an unfortunate side-effect is that the d378c39 tackles the problem by rewriting these tests to use the mock package and get rid entirely of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Discussed today. Merging and tagging as 5.17.0 |
Python 3.11 has been released over a year ago and is available across several operating systems. This PR includes a minimal set of changes allowing OMERO.py to be functinal with Python 3.11.
Summary of changes
The biggest impact of the Python 3.11 was found to be in the dependencies of OMERO.py rather than the codebase itself
py311
environment totox.ini
and the GitHub workflow definition to allow the testing under Python 3.11path.py
uses the "universal newline" opening modeopen(<file>, 'U')
deprecated in Python 3.3. and removed in Python 3.11 1 . Eventually, there is probably a larger concerted effort to remove the usage of this fork in favor ofpathlib
available from the standard library. Within the context of this work, this was assessed to be a larger body of work. Instead e1d0fa4 simply adjustsomero_ext/path.py
to user
since "universal newline" mode is used by default since Python 3.mox3
dependency 2 used by the unit tests was an unofficial port of the Google mox framework to Python 3. This library is unmaintained, has seen no releases since 3+ years and its usage was found to be incompatible with some of the Python 3.11 changes. 614a2e2 deprecates its usage intestlib
and 986aa84 adjusts several tests to usepytest-mock
3, a thin-wrapper of themock
library available under the standard Python libraryTesting
With this PR included, all CI builds and tests should keep passing. In addition, tt should be possible to use OMERO.py as a client as well as deploying OMERO.server in a Python 3.11 virtual environment.
Impact & open questions
pytest-mock
. Unlike the GitHub worklow builds, this might require additional infrastructure work to install the new dependency in the Jenkins CI environment where the integration tests are executedtest/unit/clitest/test_admin.py
is still making heavy internal use ofmox3
to test theomero admin
subcommands. These tests are currently skipped in the GitHub workflow as they require 1- a valid OMERO.server environment referred byOMERODIR
, 2- Java installed. The re-activation of these tests has been captured in 4. In the context of this work, I see three options:ome/openmicroscopy
so that they are executed in a valid environmentomero-py
possibly looking into a more extensive usage of Pythonmock
library to remove the dependency on Java and maybe a valid server binaryI'll hold off on any work on the above until we reach a consensus.
Footnotes
https://docs.python.org/3/whatsnew/3.11.html#porting-to-python-3-11 ↩
https://pypi.org/project/mox3/ ↩
https://pytest-mock.readthedocs.io/en/latest/ ↩
https://github.com/ome/omero-py/issues/61 ↩