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

fix cmake build error when install under virtualenv #1777

Closed
wants to merge 6 commits into from

Conversation

shinny-chengzhi
Copy link
Contributor

CMake's FindPythonLibs is not working very well under virtualenv. We need to set PYTHON_LIBRARY and PYTHON_INCLUDE_DIR to help CMake locate the relevant directories.

@finos-cla-bot
Copy link

finos-cla-bot bot commented Mar 31, 2022

Thank you for your contribution and Welcome to our Open Source Community!

To make sure your pull request is accepted successfully, we ask all our open source contributors to sign a Contributor License Agreement; having reviewed our contributor list, we require a CLA for the following people : (@shinny-chengzhi).

In order to sign a CLA with FINOS, just submit a Pull Request with a simple change to this file (adding an empty line, or some random text at the bottom); this will trigger the EasyCLA bot, which will post a comment to the Pull Request stating whether all PR contributors are covered by FINOS CLA; if not covered, the bot will post instructions on how to sign the CLA.

Thanks once again for your contribution. Let us work with you to make the CLA process quick, easy and efficient so we can move forward with reviewing and accepting your pull request. Feel free to email help@finos.org for any questions.

cc @maoo @TheJuanAndOnly99 @mcleo-d

Copy link
Member

@timkpaine timkpaine left a comment

Choose a reason for hiding this comment

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

This won't work for manylinux builds, and this stuff is handled by the FindPython cmake modules.

@shinny-chengzhi
Copy link
Contributor Author

It seems like the coding style check failed, and I'm not familiar with Lint Python. Could you shine any light on the error BLK100: Black would make changes?

I think the culprit is the FindPythonLibs module which can't find include&lib location in my case. Here is my setup:

  • compare python form source and install it to /home/cz/work/python-3.6
  • create virtualenv under /home/cz/work/py36env
  • run pip3 install perspective-python and encountered error:
...
  running build_ext
  -- The C compiler identification is GNU 6.3.0
  -- The CXX compiler identification is GNU 6.3.0
  -- Check for working C compiler: /usr/bin/cc
  -- Check for working C compiler: /usr/bin/cc -- works
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - done
  -- Detecting C compile features
  -- Detecting C compile features - done
  -- Check for working CXX compiler: /usr/bin/c++
  -- Check for working CXX compiler: /usr/bin/c++ -- works
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done
  -- Found Boost: /usr/include (found version "1.67.0")
  -- Found Python: /home/cz/work/py36env/bin/python3.6 (found suitable exact version "3.6.5") found components: Interpreter Development
  -- Found PythonInterp: /home/cz/work/py36env/bin/python3.6 (found suitable exact version "3.6.5")
  CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
    Could NOT find PythonLibs (missing: PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS)
    (Required is exact version "3.6")
  Call Stack (most recent call first):
    /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
    /usr/share/cmake-3.16/Modules/FindPythonLibs.cmake:310 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
    CMakeLists.txt:377 (find_package)
  
  
  -- Configuring incomplete, errors occurred!
  See also "/tmp/pip-install-ubkztp2d/perspective-python/build/temp.linux-x86_64-3.6/CMakeFiles/CMakeOutput.log".
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-install-ubkztp2d/perspective-python/setup.py", line 259, in <module>
...

Even though I can run python -c "import sysconfig; print(sysconfig.get_config_var('INCLUDEPY'), sysconfig.get_config_var('LIBDIR'))" to get /home/cz/work/python-3.6/bin/include/python3.6m /home/cz/work/python-3.6/bin/lib as include&lib location.

After applying this patch, I can finally install perspective in my environment.

@timkpaine
Copy link
Member

@shinny-chengzhi you can run black on the setup.py. One other thing, it looks like this may relate to a bug in CMake so you should check if you're able to build without this PR but with a newer Cmake version

@shinny-chengzhi
Copy link
Contributor Author

I tried building the latest CMake form source and the problem still preexist. Here is the log:

...
  running build_ext
  -- The C compiler identification is GNU 6.3.0
  -- The CXX compiler identification is GNU 6.3.0
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - done
  -- Check for working C compiler: /usr/bin/cc - skipped
  -- Detecting C compile features
  -- Detecting C compile features - done
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  -- Check for working CXX compiler: /usr/bin/c++ - skipped
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done
  -- Found Boost: /usr/include (found version "1.67.0")
  -- Found Python: /home/cz/work/py36env/bin/python3.6 (found suitable exact version "3.6.5") found components: Interpreter Development Development.Module Development.Embed
  -- Found PythonInterp: /home/cz/work/py36env/bin/python3.6 (found suitable exact version "3.6.5")
  CMake Error at /home/cz/work/CMake/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
    Could NOT find PythonLibs (missing: PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS)
    (Required is exact version "3.6")
  Call Stack (most recent call first):
    /home/cz/work/CMake/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
    /home/cz/work/CMake/Modules/FindPythonLibs.cmake:310 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
    CMakeLists.txt:377 (find_package)
  
  
  -- Configuring incomplete, errors occurred!
  See also "/tmp/pip-install-qhdxkse5/perspective-python/build/temp.linux-x86_64-3.6/CMakeFiles/CMakeOutput.log".
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-install-qhdxkse5/perspective-python/setup.py", line 259, in <module>
...

It's seem like this is a known bug: https://gitlab.kitware.com/cmake/cmake/-/issues/19525

@finos finos deleted a comment from finos-cla-bot bot Apr 2, 2022
@finos finos deleted a comment from finos-cla-bot bot Apr 2, 2022
@@ -176,7 +183,7 @@ def build_extension_cmake(self, ext):
"-DCMAKE_TOOLCHAIN_FILE={}".format(vcpkg_toolchain_file)
)

if sys.maxsize > 2 ** 32:
if sys.maxsize > 2**32:
Copy link
Member

Choose a reason for hiding this comment

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

needs spaces around operator for linting

@finos-cla-bot
Copy link

finos-cla-bot bot commented Apr 4, 2022

Thank you for your contribution and Welcome to our Open Source Community!

To make sure your pull request is accepted successfully, we ask all our open source contributors to sign a Contributor License Agreement; having reviewed our contributor list, we require a CLA for the following people : (@shinny-chengzhi).

In order to sign a CLA with FINOS, just submit a Pull Request with a simple change to this file (adding an empty line, or some random text at the bottom); this will trigger the EasyCLA bot, which will post a comment to the Pull Request stating whether all PR contributors are covered by FINOS CLA; if not covered, the bot will post instructions on how to sign the CLA.

Thanks once again for your contribution. Let us work with you to make the CLA process quick, easy and efficient so we can move forward with reviewing and accepting your pull request. Feel free to email help@finos.org for any questions.

cc @maoo @TheJuanAndOnly99 @mcleo-d

@shinny-chengzhi
Copy link
Contributor Author

Strange that when I run black it's constantly striping the space for me:

(py36env) cz@chengzhi:~$ black work/perspective/python/perspective/setup.py 
reformatted work/perspective/python/perspective/setup.py

All done! ✨ 🍰 ✨
1 file reformatted.

Is there any rules that need to be fed to black? Nevertheless, I have manually added these spaces back.

@shinny-chengzhi
Copy link
Contributor Author

I've create a new one #1779 Since github didn't support changing source branch for PR.

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.

3 participants