I'm maintaining a python package which includes a cython-based c extention. The source code is on github: https://github.com/vlkit/vlkit.
Here is my setup.py
:
import os
from setuptools import setup, find_packages
from distutils.core import Extension
try:
import numpy
except ImportError: # We do not have numpy installed
os.system("pip install numpy")
try:
from Cython.Build import cythonize
except ImportError: # We do not have Cython installed
os.system("pip install Cython")
import numpy
from Cython.Build import cythonize
__version__ = "0.1.0-b3"
exts = [Extension(name='vltools.nms.nms_ext',
sources=["vltools/nms/nms_ext.pyx"],
include_dirs=[numpy.get_include()])
]
setup(name='vltools',
version=__version__,
description='vision and learning tools',
url='https://github.com/vltools/vltools',
author_email='a@b.c',
license='MIT',
packages=find_packages(),
ext_modules=cythonize(exts),
zip_safe=False,
data_files=[("data", ["data/imagenet1000_clsidx_to_labels.txt"])]
)
When building locally with python setup build && python setup.py install
, everything goes smoothly.
However, when I'm trying to create a source distribution with python setup.py sdist
and then install from the generated dist/vltools-0.1.0b3.tar.gz
it run into an error:
ValueError: 'vltools/nms/nms_ext.pyx' doesn't match any files
In my understanding, the one actually required for installation is nms_ext.c
which is indeed inside the generated dist/vltools-0.1.0b3.tar.gz
.
However, in my setup.py it's "nms_ext.pyx" in the sources:
exts = [Extension(name='vltools.nms.nms_ext',
sources=["vltools/nms/nms_ext.pyx"],
include_dirs=[numpy.get_include()])
]
So what should I do when creating a source distribution with python setup.py sdist
?