简体   繁体   中英

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

I have a setup.py file that builds an extension. If I change one of the source files, distutils recognizes this and rebuilds the extension, showing all the compile / link commands.

However, if the only thing I change is setup.py (I'm fiddling trying to make library dependencies work), then it doesn't seem to rebuild (eg, none of the compile/link commands show up). I've tested this by removing one of the source files in the line

sources = ['foo.c', 'bar.c' ...]

and when I pip install -e . or python setup.py install , it still creates a new file for the extension, but it must be a version cached somewhere, since it shouldn't compile.

How do I clear this cache? I have tried

python setup.py clean --all

or using the --ignore-installed and --no-cache-dir flags when doing pip install -e .

The only way I have found to make it rebuild is if I add garbage in a source file, triggering a rebuild and error, remove the garbage, and pip install -e . again...

  1. Just delete under site-packages path any file related to it, you may find sometimes more than one version or some files packaged as zip files or run the following command python setup.py clean --all .
  2. Recompile and install again.

But I will recommend to use python setup.py develop so you don't need to reinstall it with every change, you will be able to frequently edit your code and not have to re-install it again. python setup.py install is used to install typically a ready to use third-party packages.

Check here to better understand python packaging .

Summary :

python setup.py clean --all
python setup.py develop

I needed to run

python setup.py clean --all
python setup.py develop

Thanks to DhiaTN for getting me there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM