#11016 closed (wontfix)
manage.py not finding custom commands when run from different directory (or through a symlink in a different directory)
Reported by: | icyhandofcrap | Owned by: | nobody |
---|---|---|---|
Component: | Core (Management commands) | Version: | 1.1-beta |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | yes | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
http://code.djangoproject.com/ticket/5825
Similar to the above case, but manage.py will not find custom commands if called through a symlink from a different directory or from a different directory other than the project directory.
Attachments (4)
Change History (14)
by , 16 years ago
Attachment: | managepath.diff added |
---|
comment:1 by , 16 years ago
comment:2 by , 16 years ago
This path uses the Python2.5 ternary conditional syntax, please write this in a way that is 2.3 compatible.
by , 16 years ago
Attachment: | managepath.2.diff added |
---|
by , 16 years ago
Attachment: | managepath.3.diff added |
---|
comment:4 by , 16 years ago
Needs tests: | set |
---|
by , 16 years ago
comment:5 by , 16 years ago
I'm not sure how I would do unit tests for this, but this is a demo of the code. Make symbolic links, run it from different directories, etc. and it will print out the parent directory of the script itself. Of course, doesn't work with hard links.
comment:6 by , 16 years ago
I can't reproduce the problem (Mac OS 10.5, Python 2.5, Django trunk r10697)
comment:7 by , 16 years ago
Well the issue is if under installed apps, you have:
'myproject.app',
instead of
'app'.
Then when you run manage.py from a different directory, manage.py doesn't detect that it is in the myproject directory already and fails to import app. Then it doesn't import the custom commands.
comment:8 by , 16 years ago
If that is the case, I think we can punt this to 1.2 with a "don't do this". We were talking about documenting that you should always import your apps with the full path at the sprints in Prague.
comment:9 by , 16 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Yes, you should always use absolute paths for INSTALLED_APPS, and everywhere else, too. This is really just another incarnation of the "project" abstracting being confusing and hurting users later on; in this case, a basic understanding of PYTHONPATH explains what's going on here.
The attached patch attempts to resolve the path of manage.py if it is a symbolic link, and also gets the parent directory of manage.py, not relying on getcwd()