How to solve the failure of getting a python file from cpp extension of pytorch using setuptools?
I wanted to try a github project named deformable kernels, and followed the steps described in the README.md file:
conda env create -f environment.yml
 
cd deformable_kernels/ops/deform_kernel;
pip install -e .;

The structure of deformable_kernel/ops/deform_kernel is showed here:
.
csrc
    filter_sample_depthwise_cuda.cpp
    filter_sample_depthwise_cuda.h
    filter_sample_depthwise_cuda_kernel.cu
    nd_linear_sample_cuda.cpp
    nd_linear_sample_cuda.h
    nd_linear_sample_cuda_kernel.cu
functions
    filter_sample_depthwise.py
    __init__.py
    nd_linear_sample.py
__init__.py
modules
    filter_sample_depthwise.py
    __init__.py
setup.py

And the content of file setup.py is showed here:
from setuptools import setup
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
 
setup(
    name='filter_sample_depthwise',
    ext_modules=[
        CUDAExtension(
            'filter_sample_depthwise_cuda',
            [
                'csrc/filter_sample_depthwise_cuda.cpp',
                'csrc/filter_sample_depthwise_cuda_kernel.cu',
            ]
        ),
    ],
    cmdclass={'build_ext': BuildExtension}
)
 
setup(
    name=&quot;nd_linear_sample&quot;,
    ext_modules=[
        CUDAExtension(
            &quot;nd_linear_sample_cuda&quot;,
            [
                &quot;csrc/nd_linear_sample_cuda.cpp&quot;,
                &quot;csrc/nd_linear_sample_cuda_kernel.cu&quot;,
            ],
        )
    ],
    cmdclass={&quot;build_ext&quot;: BuildExtension},
)

When I install this directory using command pip install -e ., it failed and the result is:
Obtaining file:///home/xxx/Downloads/deformable_kernels/deformable_kernels/ops/deform_kernel
ERROR: More than one .egg-info directory found in /tmp/pip-pip-egg-info-pta6z__q

So I tried to separate the 2 setup()s in different setup.py files. It worked but I didn't get a python file. Instead a .so file was generated.
Does anyone know how to solve a problem like this?

Check your pip version. I've had the same error (when installing other things in dev mode with pip) and downgrading to pip version 20.0.2 worked. Unsure why, but I've seen other folks on the internet solve the problem similarly.
