开发者

How do I package an unchanged C extension as part of my new Python package?

开发者 https://www.devze.com 2023-02-14 17:43 出处:网络
I开发者_JS百科\'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开发者_JS百科'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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消