Why does `setup.py develop` not work?

2019-06-16 11:39发布

问题:

I would like to install my Python module in development mode. As I have seen in many examples python setup.py develop is supposed to do that. But the develop command does not exist for my setup.py file:

from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize
from Cython.Distutils import build_ext

import os

src = ["_NetworKit.pyx"]    # list of source files
modules = [Extension("_NetworKit",
                    src,
                    language = "c++",
                    extra_compile_args=["-fopenmp", "-std=c++11", "-O3", "-DNOGTEST"],
                    extra_link_args=["-fopenmp", "-std=c++11"],
                    libraries=["NetworKit-Core-O"],
                    library_dirs=["../"])]

for e in modules:
    e.cython_directives = {"embedsignature" : True}

setup(name="_NetworKit",
     cmdclass={"build_ext": build_ext},
     ext_modules=modules,
     py_modules = ["NetworKit.py"])

(Note the Cython extension module).

What am I missing? Do I need to modify the setup.py?

回答1:

The develop command is a part of setuptools. Install setuptools and replace the first line in setup.py with this:

from setuptools import setup