Django's manage.py shows old commands
Asked Answered
A

1

2

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?

Alby answered 22/8, 2018 at 12:57 Comment(0)
A
3

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
Alby answered 22/8, 2018 at 12:57 Comment(1)
You're right, I forgot the --all option: python setup.py clean --all bdist_wheel. I have all=1 in setup conf of my project template, thus often forgetting to include it in commands.Vasiliu

© 2022 - 2024 — McMap. All rights reserved.