[Goal]

  • Boost를 python 버전과 함께 install 할 때 발생하는 문제를 해결할 수 있다.

[Reference Site]


[Cause]

  • Boost python 라이브러리를 설치할 때, python version에 따른 경로를 찾지 못하여 문제가 발생하였기 때문에 boost package를 일부 수정

[Process]

  • [Step 1] boost package 내부 코드인 `~/boost_1_XX_X/libs/python/src/converter/builtin_converters.cpp`를 수정 (Line 38 ~ 47)
    • Before
// An lvalue conversion function which extracts a char const* from a
// Python String.
#if PY_VERSION_HEX < 0x03000000
void* convert_to_cstring(PyObject* obj)
{
  return PyString_Check(obj) ? PyString_AsString(obj) : 0;
}
#else
void* convert_to_cstring(PyObject* obj)
{
  return PyUnicode_Check(obj) ? _PyUnicode_AsString(obj) : 0;
}

 

    •  After
// An lvalue conversion function which extracts a char const* from a
// Python String.
#if PY_VERSION_HEX < 0x03000000
void* convert_to_cstring(PyObject* obj)
{
  return PyString_Check(obj) ? PyString_AsString(obj) : 0;
}
#elif PY_VERSION_HEX < 0x03070000
void* convert_to_cstring(PyObject* obj)
{
  return PyUnicode_Check(obj) ? _PyUnicode_AsString(obj) : 0;
}
#else
void* convert_to_cstring(PyObject* obj)
{
  return PyUnicode_Check(obj) ? const_cast<void*>(reinterpret_cast<const void*>(_PyUnicode_AsString(obj))) : 0;
}
#endif

 

+ Recent posts