Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Python Path Configuration & Abort() Error #5644

Copy link
Copy link
Open
@NulledBird

Description

@NulledBird
Issue body actions

Required prerequisites

What version (or hash if on master) of pybind11 are you using?

2.13.6

Problem description

I have a setup where I am trying to compile a version of CPython (with a custom CMake) and use it in pybind11's embed mode.

Upon compiling, I get no errors, however running the compiled executable returns

Python path configuration:
  PYTHONHOME = (not set)
  PYTHONPATH = (not set)
  program name = 'python'
  isolated = 0
  environment = 1
  user site = 1
  import site = 1
  sys._base_executable = 'D:\\lime\\bin\\Debug\\lime.exe'
  sys.base_prefix = ''
  sys.base_exec_prefix = ''
  sys.platlibdir = 'lib'
  sys.executable = 'D:\\lime\\bin\\Debug\\lime.exe'
  sys.prefix = ''
  sys.exec_prefix = ''
  sys.path = [
    'D:\\lime\\bin\\Debug\\lime.zip',
    '',
    '.\\Lib',
    '.\\Lib\\lib-dynload',
    '.\\Lib\\lib-dynload\\Debug',
    '.\\Lib\\plat-win32',
    '.\\Lib\\lib-tk',
    'D:\\lime\\bin\\Debug',
  ]

And a popup window that says

Debug Error
Program:
abort() has been called
(Press Retry to debug the application)

The main.cpp file is copied directly from the tutorial.

Reproducible example code

cmake_minimum_required(VERSION 3.5...3.29)
project(test LANGUAGES CXX)

if (NOT DEFINED CMAKE_BUILD_TYPE OR "${CMAKE_BUILD_TYPE}" STREQUAL "")
    set(CMAKE_BUILD_TYPE "Debug")
endif()

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin")

set(PYTHON_VERSION "3.9.22" CACHE STRING "The version of Python to build." FORCE)
add_subdirectory(ext/python)
get_directory_property(PYTHONPATH DIRECTORY ext/python DEFINITION PYTHONHOME)
get_directory_property(BIN_INSTALL_DIR DIRECTORY ext/python DEFINITION BIN_INSTALL_DIR)
set(ENV{PYTHONPATH} "${CMAKE_CURRENT_BINARY_DIR}/ext/python/${PYTHONPATH}")
set(ENV{PYTHONHOME} "${CMAKE_CURRENT_BINARY_DIR}/ext/python/${BIN_INSTALL_DIR}/${CMAKE_BUILD_TYPE}/")

include_directories("${CMAKE_CURRENT_BINARY_DIR}/ext/python/include" "$ENV{PYTHONHOME}/PC/")
set(PYBIND11_NOPYTHON TRUE)
set(Python_EXECUTABLE "$ENV{PYTHONHOME}/python.exe")
set(ENV{PATH} "$ENV{PYTHONHOME}:$ENV{PATH}")
add_subdirectory(ext/pybind11)


file(GLOB_RECURSE SOURCES src/*.cpp)
file(GLOB_RECURSE HEADERS include/*.hpp)

add_executable(test src/main.cpp)
target_sources(test PRIVATE ${SOURCES} ${HEADERS})
include_directories(include)

target_link_libraries(test PRIVATE pybind11::embed libpython-static)

Is this a regression? Put the last known working version here if it is.

Not a regression

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageNew bug, unverifiedNew bug, unverified

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.