问题
I am coding my own whl-package and after creating some new management-commands and deleting some old ones I was pretty happy with myself. Except after building my wheel-package (with setup.py bdist_wheel
) and installing it on my test server (with pip install -U project-2.0b3-py2.py3-none-any.whl
), I noticed that the help of manage.py
still show the old commands. It will even try to run the old commands, so there is some old stuff there, but I was not quite sure why or how.
I tried uninstalling instead of upgrading with pip uninstall project
and listing installed packages with pip freeze
to make sure it was all gone. Even tried to run the old commands, which would correctly fail when the package was not installed.
Where do these old commands come from?
回答1:
Tada. Found it. TL;DR: run setup.py clean --all bdist_wheel
.
So when the commands were gone after uninstalling the package, it must be something in the package. I confirmed that by doing
> strings project-2.0b3-py2.py3-none-any.whl | grep old_command
which indeed found traces of my old command. So they got built into my package from somewhere. I moved to my dev-box and ran
> find . -iname *old_command*
./build/lib/project/management/commands/old_command.py
While I had already deleted the file from my project, it was obviously still in the build
-directory. A simple clean will not get rid of it, but clean --all
does. Conveniently, it can be combined to
setup.py clean --all bdist_wheel
来源:https://stackoverflow.com/questions/51967441/djangos-manage-py-shows-old-commands