如何将未更改的 C 扩展打包为新 Python 包的一部分?

发布于 2024-10-19 23:14:32 字数 99 浏览 8 评论 0原文

我已经向 pypi 发布了新版本的 Python 包,而没有更改 C 扩展名。由于我只更改了Python代码,没有更改C代码,那么如何将我为多个平台编译的共享库打包而不需要重新编译呢?

I've released a new version of a Python package to pypi without changing the C extension. Since I have only changed the Python code, not the C code, how do I package the shared libraries I have compiled for several platforms without having to recompile?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

痴意少年 2024-10-26 23:14:32

作为一个名为“somelib”的库的示例,其编译库位于两个子目录 lib-i386 和 lib-amd64 中:

MANIFEST.in 包含以下内容:

include __init__.py
include setup.py
include somelib/*
include somelib/lib-i386/*
include somelib/lib-amd64/*

setup.py 包含(我省略了对版本控制问题不必要的行):

# Determine machine arhitecture
arch = os.uname()[4]
libname = "lib-%s" % (arch,)
lib_files = glob.glob('./somelib/' + libname + '/*')
data_files = [('somelib', 
              lib_files + ['__init__.py', 'somelib/README.TXT']),]

setup(
   ... 
   data_files=data_files
)

All库对象位于包内,但仅安装特定于“arch”的库对象。

HTH。

As an example for a library called 'somelib' with compiled libraries in two subdirectories, lib-i386 and lib-amd64:

MANIFEST.in contains the following:

include __init__.py
include setup.py
include somelib/*
include somelib/lib-i386/*
include somelib/lib-amd64/*

setup.py contains (I've omitted lines unessential to the versioning issue):

# Determine machine arhitecture
arch = os.uname()[4]
libname = "lib-%s" % (arch,)
lib_files = glob.glob('./somelib/' + libname + '/*')
data_files = [('somelib', 
              lib_files + ['__init__.py', 'somelib/README.TXT']),]

setup(
   ... 
   data_files=data_files
)

All the library objects are inside the package, but only the ones specific to 'arch' are installed.

HTH.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文