Python3 fixes (maintains python2 compatibility) - #214
Open
temetski wants to merge 2 commits into
Open
Conversation
Owner
|
Thanks for your contribution. I will have a look at my spare time. |
|
Some methods need replacing too, such as'has_key' |
|
Thank you for this PR, helped a lot! |
AlessandroGianfelici
approved these changes
Jan 4, 2024
AlessandroGianfelici
approved these changes
Jan 4, 2024
AlessandroGianfelici
left a comment
There was a problem hiding this comment.
makes the example work with python 3.x without breaking the compatibility with python 2.x. It's a small fix that could be merged
AlessandroGianfelici
approved these changes
Jan 4, 2024
AlessandroGianfelici
left a comment
There was a problem hiding this comment.
everithing works with python 2.x and 3.x
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After some digging, I think I may have resolved the segfault issue on Python>3.6.1 on MacOS (see #179). It has to do with
swig_link_libraries(see https://cmake.org/cmake/help/latest/module/UseSWIG.html in conjunction with https://cmake.org/cmake/help/latest/policy/CMP0078.html)PythonInterpandPythonLibs. Best way to pass libraries totarget_link_librariesis usingPython::ModuleofFindPythonThis PR changes
PythonInterpandPythonLibsto preferFindPython, which detects your python library (python 2 or 3) and sets up CMAKE appropriately. It then deprecatesswig_link_librariesin favor oftarget_link_librariesfor CMAKE versions 3.13 and above.Additionally, assuming the presence of conda indicates preference for the python conda version, added
fmm/CMakeLists.txt
Line 39 in 676ced5
following suggestions in https://gitlab.kitware.com/cmake/cmake/-/issues/21322. This addresses issues when conda's python version is less than that of the system python install.
The above changes seem to still be compatible with ubuntu-based python 2 and python 3 installs, while resolving the segfault issues encountered in the python3 install of
fmmon MacOS.CI testing might have to be changed a bit to test for python3 since
pythondefaults to the python 2 install in most systems.Edit: It seems most of your build configs for testing rely on ubuntu 16.04, which uses an old version of CMAKE. To maintain compatibility with the old and new CMAKE versions, we can use
PythonInterpandPythonLibsfor CMAKE<3.13, while using FindPython for newer CMAKE versions.