Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
CMake
CMake
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,183
    • Issues 3,183
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 14
    • Merge Requests 14
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI / CD
    • Repository
    • Value Stream
  • External Wiki
    • External Wiki
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • CMake
  • CMakeCMake
  • Issues
  • #19525

Closed
Open
Opened Jul 26, 2019 by Tony@Karnigen

FindPython3 does not find libraries in virtual environment

Trying to compile program and link it with python 374 libraries on OS Linux Mint 19.1 Tessa Mate, cmake 3.15.

Required libraries are: libpython3.7m.a -lcrypt -lpthread -ldl -lutil = python lib + dependent libs

But using find_package(Python3 COMPONENTS Interpreter Development) in virtual python environment is partially buggy. Results are (see below). Maybe using sysconfig is more appropriate, especially if development files are on different location as virtual directory. Virtual environment does not copy or link c-libraries and headers to virtual place. One way to find them is to ask python+sysconfig.

Furthermore static linking requires secondary dependent libraries of libpython_xxx.a.

python -m sysconfig gives:

  • LIBS = "-lcrypt -lpthread -ldl -lutil" - secondary dependent libraries
  • LIBRARY = "libpython3.7m.a"
  • LIBDIR = "/opt/python/python-3.7.4/lib"
  • INCLUDEPY = "/opt/python/python-3.7.4/include/python3.7m"
  • ...

and paths:

  • include = "/opt/python/python-3.7.4/include/python3.7m"
  • scripts = "/opt/venv/py374/bin"
  • ...

It seems to me that sysconfig should be more preferable for virtual environment, it correctly return executable in virtual path and development directories in static installation place. It is consistent with philosophy get executable and ask it where is its development environment.

I didn't check if find_package(Python) is working outside virtual environment and if secondary libraries are considered there. I also didn't check how sysconfig is reliable for other Python implementations and how is solved if both static and dynamic libraries are available.

Result of find_package(Python3 COMPONENTS Interpreter Development)

  • Python3_Development_FOUND=FALSE
  • Python3_EXECUTABLE=/opt/venv/py374/bin/python3.7
  • Python3_FOUND=FALSE
  • Python3_INCLUDE_DIR=Python3_INCLUDE_DIR-NOTFOUND
  • Python3_INCLUDE_DIRS=Python3_INCLUDE_DIR-NOTFOUND
  • Python3_INTERPRETER_ID=Python
  • Python3_Interpreter_FOUND=TRUE
  • Python3_LIBRARIES=Python3_LIBRARY-NOTFOUND
  • Python3_LIBRARY=Python3_LIBRARY-NOTFOUND
  • Python3_LIBRARY_DEBUG=Python3_LIBRARY_DEBUG-NOTFOUND
  • Python3_LIBRARY_RELEASE=Python3_LIBRARY_RELEASE-NOTFOUND
  • Python3_RUNTIME_LIBRARY=$Python3_RUNTIME_LIBRARY-NOTFOUND
  • Python3_RUNTIME_LIBRARY_DEBUG=
  • Python3_RUNTIME_LIBRARY_RELEASE=
  • Python3_SITEARCH=/opt/venv/py374/lib/python3.7/site-packages
  • Python3_SITELIB=/opt/venv/py374/lib/python3.7/site-packages
  • Python3_STDARCH=/opt/python/python-3.7.4/lib/python3.7
  • Python3_STDLIB=/opt/python/python-3.7.4/lib/python3.7
  • Python3_VERSION=3.7.4
  • Python3_VERSION_MAJOR=3
  • Python3_VERSION_MINOR=7
  • Python3_VERSION_PATCH=4
Edited Jul 26, 2019 by Tony
To upload designs, you'll need to enable LFS and have admin enable hashed storage. More information
Assignee
Assign to
3.16.0
Milestone
3.16.0 (Past due)
Assign milestone
Time tracking
None
Due date
None
Reference: cmake/cmake#19525