Skip to content

Replaced distutils module to sysconfig#21219

Merged
alalek merged 2 commits intoopencv:3.4from
asenyaev:asen/remove_distutils
Dec 8, 2021
Merged

Replaced distutils module to sysconfig#21219
alalek merged 2 commits intoopencv:3.4from
asenyaev:asen/remove_distutils

Conversation

@asenyaev
Copy link
Copy Markdown
Contributor

@asenyaev asenyaev commented Dec 8, 2021

This PR fixes following issue #21141.

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

@asenyaev asenyaev requested a review from alalek December 8, 2021 10:59
if(NOT ANDROID AND NOT IOS)
if(CMAKE_HOST_UNIX)
execute_process(COMMAND ${_executable} -c "from distutils.sysconfig import *; print(get_python_lib())"
execute_process(COMMAND ${_executable} -c "from sysconfig import *; print(get_python_lib())"
Copy link
Copy Markdown
Member

@alalek alalek Dec 8, 2021

Choose a reason for hiding this comment

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

Looks like this doesn't work as expected (Linux x64 / Mac):

-- Found PythonInterp: /usr/bin/python2.7 (found suitable version "2.7.6", minimum required is "2.7") 
-- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython2.7.so (found suitable exact version "2.7.6") 
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'get_python_lib' is not defined
-- Found PythonInterp: /usr/bin/python3 (found suitable version "3.4.3", minimum required is "3.2") 
-- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython3.4m.so (found suitable exact version "3.4.3") 
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'get_python_lib' is not defined

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm sorry, I didn't change the function here. Fixed it.

Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

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

Thank you 👍

@alalek alalek merged commit d6891c7 into opencv:3.4 Dec 8, 2021
@alalek alalek mentioned this pull request Dec 11, 2021
@alalek
Copy link
Copy Markdown
Member

alalek commented Dec 25, 2021

BTW, Looks like for Python <=3.9 patch changes binary names:

  • before: python-3.5/cv2.cp35-win_amd64.pyd
  • after: python-3.5/cv2.pyd

Name for Python 3.10 is wider: python-3.10/cv2.cp310-win_amd64.pyd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: replace deprecated 'distutils'

2 participants