zdevito / custom_loader Goto Github PK
View Code? Open in Web Editor NEWLicense: BSD 3-Clause "New" or "Revised" License
License: BSD 3-Clause "New" or "Revised" License
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.
cmake_minimum_required
.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.
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?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.