当setup.py更改为Pip可编辑

时间:2018-06-26 08:33:35

标签: compilation cython

在以pip模式安装时,仅更改了setup.py,如何使editable重新编译Cython扩展。当前,它总是跳过扩展名。 distutils有很多与此相关的问题,但我找不到pip的任何答案。

要清楚,我有一个setup.py,如下所示

from distutils.core import setup, Extension
from Cython.Distutils import build_ext
import numpy

ext_modules = []

# simulate_fast
ext_modules += [
    Extension("adio.simulating.simulate_fast_c",
        sources=["./adio/simulating/simulate_fast/simulate_fast_c.pyx",
                 "./adio/simulating/simulate_fast/c/simulate_fast.c",
                 "./adio/simulating/simulate_fast/c/matrix.c"],
        include_dirs=[numpy.get_include()],
        extra_compile_args=["-Ofast", "-ffast-math", "-march=native"],
        language='c',
        libraries=["gsl", "openblas"],
        define_macros=[('FLOAT32', 1)]
        )
    ]

setup(
  name="adio",
  packages=["adio"],
  cmdclass={'build_ext': build_ext},
  ext_modules=ext_modules
)

现在,如果我删除('FLOAT32', 1)中的define_macros,我当然希望Cython扩展重新编译。

但是我跑步

python3 -m pip install --editable -U . -v

我收到以下输出作为输出的一部分

running develop
running egg_info
writing adio.egg-info/PKG-INFO
writing dependency_links to adio.egg-info/dependency_links.txt
writing top-level names to adio.egg-info/top_level.txt
reading manifest file 'adio.egg-info/SOURCES.txt'
writing manifest file 'adio.egg-info/SOURCES.txt'
running build_ext
skipping './adio/simulating/simulate_fast/simulate_fast_c.c' Cython extension (up-to-date)

我尝试使用-I来标记--force-reinstallpip,但是它总是跳过Cython扩展名。如果我不使用可编辑模式,则可以运行

python3 -m pip install -U . -v

,它将重新编译。使用--editable标志时,我该如何实现相同的目的。

相关

distutils ignores changes to setup.py when building an extension?

0 个答案:

没有答案