用已编译的Julia打包Python? [英] Packaging Python with compiled Julia?

查看:142
本文介绍了用已编译的Julia打包Python?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究高度依赖Julia库的python软件包.实际上,我们没有使用PyCall,而是使用PackageCompiler.jl将Julia代码向下编译为共享对象.so文件.在python模块中使用ctypes进行引用.它还需要一个Julia系统映像.

I am working on a python package that relies heavily on a Julia library. Rather than use PyCall, we actually compile the Julia code down into shared objects .so files using PackageCompiler.jl. It is referenced using ctypes in the python module. It also requires a Julia systemimage.

有人对如何打包此包装有任何想法吗?我知道您可以在distutils内部构建C/C ++,但是我还没有真正找到在多个平台上都包含Julia的好地方.

Does anyone have any ideas on how to package this? I know that you can build C/C++ inside of distutils, but I haven't really found a good venue for including Julia across multiple platforms.

这里要清楚,对于要使用此Python软件包的用户,他们需要安装Julia,并且需要其系统使用适当的共享库.这些可以通过运行Julia编译器juliac.jl来获得.其他所有内容都在Python中.

To be clear here, for someone to use this Python package they need a Julia installation and they need the appropriate shared object libraries for their system. Those can be gotten by running the Julia compiler juliac.jl. Everything else is in Python.

推荐答案

假设您正在使用setup.py来构建库,则在调用setup()时需要将共享库添加到package_data:

Assuming you are using setup.py to build your library, you need to add the shared library(s) to package_data when calling setup():

setup.py

# call out to build system to build the shared library

setup(
  name="my-extension",
  ext_modules="..."
  package_data="/path/to/mylib.so"
)

在此处查看更多文档: https://docs. python.org/3/distutils/setupscript.html#installing-package-data

See further documentation here: https://docs.python.org/3/distutils/setupscript.html#installing-package-data

运行python setup.py bdist_wheel创建.whl文件后,您可能还需要运行 auditwheel ,它将兼容标签(例如manylinux1)并隔离(使用哈希,修复链接重命名)共享库.

After running python setup.py bdist_wheel to create a .whl file, you may also want to run auditwheel, which will compatibility tag (e.g. manylinux1) and isolate (rename with hash, fix-up linkages) the shared libraries.

这篇关于用已编译的Julia打包Python?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆