from setuptools import setup, Extension
import numpy as np # if using cimport numpy in pyx file
extensions = [
Extension(
“extention_name”, # name
sources=[“pyx_file_name.pyx”], # pyx file
include_dirs=[np.get_include()] # if using cimport numpy
)
]
setup(ext_modules=cythonize(extensions, language_level=3))
这个文件也可以是用pyx生成的
from setuptools import setup, Extension
extensions = [
Extension(
“test”, # name
sources=[“test.cpp”], # pyx file
language='c++',
include_dirs=['/usr/local/include', np.get_include(), 'some_package/include'], # folders that have all .h files, -I option
libraries=['EGL', 'glfw'], # -l option
library_dirs=['usr/local/lib'], # -L option
extra_compile_args=['-std=c++11'] # other options if needed
)
]
setup(
name='test-package',
version='1.0.0',
setup_requires=['numpy'],
install_requires=['numpy>=1.18.0'],
python_requires='~=3.6', # >= 3.6, < 4.0
ext_modules=extensions,
packages=find_packages(), # if has other py files in this package
include_package_data=True, # to include generated so file to directly use in other py files
description='test packaging...'
)
cython -3 --fast-fail -v --cplus file_name.pyx
python setup.py build_ext --inplace
python setup.py sdist bdist_wheel