realpython / realpython/materials
Mac Mojave and Python 3.8 working branch
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Jupyter Notebook
- Star
- 5.2k
- Fork
- 5.3k
- Merge trung bình
- 4 ngày 10 giờ
- Pull request đã merge (30 ngày)
- 10
Mô tả
Hi, I have a branch to push to you with a working version of the python binding module
with Mac Mojave and Python 3.8 using python.org version of python, (not brew)
Cheers Dave.
Notes here;
help on python c binding
dependencies
install python3.8 from python.org
pip3 install pybind11
pip3 install invoke
pip3 install Cython
security block
mac mojave blocks relative pathed libraries, here is the fix
def install_name_tool(dependent=None, depends=[]):
'''
make the lib full path to get around security blocking relative paths
'''
for dependson in depends:
full_path = os.path.abspath(dependson)
shell_str='install_name_tool -change {0} {1} {2}'.format(dependson, full_path, dependent)
print(' install_name_tool: {0}'.format(dependson))
invoke.run(shell_str)
mac G++ missing symbols
mac compile gets upset about missing symbols
ignore missing symbols on a mac
On Mac OS: the build command is almost the same but it also requires passing the -undefined dynamic_lookup flag so as to ignore missing symbols when building the module:
in task.py
def compile_python_module(cpp_name, extension_name):
invoke.run(
"g++ -O3 -Wall -Werror -shared -std=c++11 -fPIC "
"`python3.8-config --includes` "
"`python3 -m pybind11 --includes` "
"-undefined dynamic_lookup "
"-I . "
"{0} "
"-o {1}`python3.8-config --extension-suffix` "
"-L. -lcppmult -Wl,-rpath,.".format(cpp_name, extension_name)
)
compile and test
here is the output from a good compile and test run
$ invoke all
==================================================
= Building C Library
* Complete
==================================================
= Testing ctypes Module
In cmult : int: 6 float 2.3 returning 13.8
In Python: int: 6 float 2.3 return val 48.0
In cmult : int: 6 float 2.3 returning 13.8
In Python: int: 6 float 2.3 return val 13.8
==================================================
= Building CFFI Module
install_name_tool: libcmult.so
* Complete
==================================================
= Testing CFFI Module
In cmult : int: 6 float 2.3 returning 13.8
In Python: int: 6 float 2.3 return val 13.8
==================================================
= Building C++ Library
install_name_tool: libcmult.so
install_name_tool: cffi_example.cpython-38-darwin.so
* Complete
==================================================
= Building PyBind11 Module
install_name_tool: libcmult.so
install_name_tool: cffi_example.cpython-38-darwin.so
install_name_tool: libcppmult.so
* Complete
==================================================
= Testing PyBind11 Module
In cppmul: int: 6 float 2.3 returning 13.8
In Python: int: 6 float 2.3 return val 13.8
==================================================
= Building Cython Module
install_name_tool: libcmult.so
install_name_tool: cffi_example.cpython-38-darwin.so
install_name_tool: libcppmult.so
* Complete
==================================================
= Testing Cython Module
In cppmul: int: 6 float 2.3 returning 13.8
In Python: int: 6 float 2.3 return val 13.8
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với task.py và quy trình invoke all đã được tài liệu hóa, sau đó xem xét cách các mô-đun C, C++, CFFI, PyBind11 và Cython được build và kiểm thử. Tái hiện thiết lập Python 3.8 và Mac Mojave đã được báo cáo; công việc được xem là hoàn thành khi branch được yêu cầu hoặc các thay đổi đã được tài liệu hóa được tích hợp và tất cả các bản build cùng bài kiểm thử của các mô-đun được liệt kê đều đạt.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- cpp, python
- Lĩnh vực
- build-system, devtools
- Loại issue
- Tính năng
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 28/100