Support Py_LIMITED_API in separate package as a dependency to PyCall.jl
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Julia
- Star
- 1.5k
- Fork
- 186
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
The Python C ABI/API has stability guarantees for a limited number of structs and functions.
https://www.python.org/dev/peps/pep-0384/
It'd be nice to support this as a separate package and use that package as a dependency in PyCall.jl. This separate package can implement the Py_LIMITED_API structs and functions without invoking the Python interpreter.
A (very early) prototype is located here:
https://github.com/kdheepak/Python.jl/blob/33b98177b0e624588a3f46ccfa96b317d57f1201/src/Python.jl
The motivation for this is so that we can build a shared object from a Julia file using PackageCompiler.jl that is also a Python module. See screenshot below as an example:
No linking to the Python library occurs at compile time and the Python module does not embed a Python interpreter; it is a pure Julia shared library. This allows one to create a Python module without having Python installed and the structs and functions described in the Py_LIMITED_API would be sufficient to make this work.
Taking this a step further, we could allow for something like the following in the future (See https://github.com/yglukhov/nimpy and https://github.com/PyO3/PyO3 for similar projects in Nim and Rust):
Write Julia code
# hello.jl
using Python
@pycallable function hello(name::String)::Cvoid
println("Hello $name!")
end
Compile
$ julia --project juliac.jl -vasij `pwd`/hello.jl > /dev/null
Run in Python
$ ipython
Python 3.7.3 (default, Mar 27 2019, 16:54:48)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.8.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import hello
In [2]: hello.hello("John")
Hello John!
In [3]:
My understanding is that this would pose some challenges with the current setup in PyCall.jl since PyCall.jl initializes a interpreter in __init__ and when PackageCompiler runs, the references to that interpreter are embedded in the shared library.
Comments?
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 bằng cách đọc src/pyinit.jl của PyCall.jl tại init, sau đó so sánh hành vi khởi tạo của nó với prototype ban đầu src/Python.jl và limited API của PEP 384. Công việc được xem là hoàn tất khi có một dependency riêng được xác định rõ và một workflow PackageCompiler đã được chứng minh là tạo ra một module Python mà không nhúng hoặc liên kết một trình thông dịch Python.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- tooling
- Loại issue
- Tính năng
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- 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
- 25/100