Giter VIP home page Giter VIP logo

custom_loader's People

Contributors

zdevito avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

custom_loader's Issues

Some corrections in CMake file

Hi, I'm interested in your great work on supporting multiple interpreters in one process.

After testing the sample code in this repo, I have two corrections to the CMake file.

  1. CMake complains about missing cmake_minimum_required.
  2. It seems that you missed src/loader.cpp in the find_shared_function library, which will give me an unresolved symbol error when running the main program.

I use the following CMakelists.txt to successfully build the sample code:

cmake_minimum_required(VERSION 3.17)

project(singleprocessmultiprocess)
set(CMAKE_CXX_STANDARD 17)
add_subdirectory(third_party/fmt)

find_package(Python COMPONENTS Development)
add_library(python_runner SHARED src/python_runner.cpp)
target_include_directories(python_runner PRIVATE third_party/pybind11/include ${Python_INCLUDE_DIRS})

add_library(find_shared_function SHARED src/find_shared_function.cpp src/loader.cpp)
target_link_libraries(find_shared_function PRIVATE fmt::fmt-header-only)

add_executable(main src/main.cpp src/loader.cpp)
target_compile_definitions(main PRIVATE PYTHON_SO_PATH=\"${Python_LIBRARIES}\")
target_link_libraries(main PRIVATE dl pthread fmt::fmt-header-only)

I recommend choosing 3.17 as the minimum required because it introduces the ability to resolve Python paths in an Anaconda environment.

I also have a question about the implementation, for which I will open a new issue.

Extension library loading only works on Python 3.8

I found that the sample code only works in Python 3.8 but not other versions.

When I compile and link with others like 3.7, 3.9 and 3.10, the main program will crash with the error

terminate called after throwing an instance of 'pybind11::error_already_set'
  what():  ImportError: /home/user/anaconda3/envs/customloader/lib/python3.10/lib-dynload/unicodedata.cpython-310-x86_64-linux-gnu.so: undefined symbol: _PyUnicode_Ready

At:
  /home/user/anaconda3/envs/customloader/lib/python3.10/site-packages/regex/_regex_core.py(18): <module>
  <frozen importlib._bootstrap>(241): _call_with_frames_removed
  <frozen importlib._bootstrap_external>(883): exec_module
  <frozen importlib._bootstrap>(703): _load_unlocked
  <frozen importlib._bootstrap>(1006): _find_and_load_unlocked
  <frozen importlib._bootstrap>(1027): _find_and_load
  /home/user/anaconda3/envs/customloader/lib/python3.10/site-packages/regex/regex.py(421): <module>
  <frozen importlib._bootstrap>(241): _call_with_frames_removed
  <frozen importlib._bootstrap_external>(883): exec_module
  <frozen importlib._bootstrap>(703): _load_unlocked
  <frozen importlib._bootstrap>(1006): _find_and_load_unlocked
  <frozen importlib._bootstrap>(1027): _find_and_load
  /home/user/anaconda3/envs/customloader/lib/python3.10/site-packages/regex/__init__.py(1): <module>
  <frozen importlib._bootstrap>(241): _call_with_frames_removed
  <frozen importlib._bootstrap_external>(883): exec_module
  <frozen importlib._bootstrap>(703): _load_unlocked
  <frozen importlib._bootstrap>(1006): _find_and_load_unlocked
  <frozen importlib._bootstrap>(1027): _find_and_load
  <string>(2): <module>

Aborted (core dumped)

It seems that the effort on supporting C extensions does not work at all. But with Python 3.8 the main program runs normally.

I'm not familiar with CPython, so I have no idea why this could happen. Could you please share some thoughts on this problem?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.