cython写的python包,带so/带ddl的包打包到pypi上,上传

Posted 72 months ago python cython linux

由于python版本的混乱- - 打包上传第三方包的教程也是坑的很 这里踩坑一下

cython 的程序 编译成so文件


from distutils.core import setup as cysetup
from Cython.Build import cythonize
cysetup(ext_modules = cythonize("lib.py",language_level=3),)

编译脚本

python ./setup.py build_ext  --inplace

让setup.py支持打包so文件

新建 MANIFEST.in

写入

recursive-include src *

这样打包的时候就会跟进保存

打包时候的setup.py


from setuptools import setup, find_packages


setup(
    name='pythonGroupMsg',
      version='0.0.1',
      description='This is a packet that broadcasts redis multiple queues',
      url='https://github.com/zhenruyan/pythonGroupMsg',
      author='zhenruyan',
      author_email='[email protected]',
      license='WTFPL',
      packages=find_packages(),
      zip_safe=False,
      platforms=["linux"],
      long_description=open('README.rst').read(),
classifiers=[
        'Operating System :: OS Independent',
        'Intended Audience :: Developers',
        'Programming Language :: Python :: 3.7',
        'Topic :: Software Development :: Libraries'
    ],include_package_data=True,
          )

打包需要安装两个包


pip install wheel
pip install twine

打包脚本

python setup.py sdist build
python setup.py bdist_wheel --universal

上传


twine upload ./dist/*

点击评论