用编译的 Julia 打包 Python?

2023-10-19Python开发问题
0

本文介绍了用编译的 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 构建你的库,你需要在调用时将共享库添加到 package_datasetup():

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

运行 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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

在xarray中按单个维度的多个坐标分组
groupby multiple coords along a single dimension in xarray(在xarray中按单个维度的多个坐标分组)...
2024-08-22 Python开发问题
15

Pandas中的GROUP BY AND SUM不丢失列
Group by and Sum in Pandas without losing columns(Pandas中的GROUP BY AND SUM不丢失列)...
2024-08-22 Python开发问题
17

GROUP BY+新列+基于条件的前一行抓取值
Group by + New Column + Grab value former row based on conditionals(GROUP BY+新列+基于条件的前一行抓取值)...
2024-08-22 Python开发问题
18

PANDA中的Groupby算法和插值算法
Groupby and interpolate in Pandas(PANDA中的Groupby算法和插值算法)...
2024-08-22 Python开发问题
11

PANAS-基于列对行进行分组,并将NaN替换为非空值
Pandas - Group Rows based on a column and replace NaN with non-null values(PANAS-基于列对行进行分组,并将NaN替换为非空值)...
2024-08-22 Python开发问题
10

按10分钟间隔对 pandas 数据帧进行分组
Grouping pandas DataFrame by 10 minute intervals(按10分钟间隔对 pandas 数据帧进行分组)...
2024-08-22 Python开发问题
11