Code

Opened 5 years ago

Closed 5 years ago

Last modified 3 years ago

#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: UI/UX:

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)

managepath.diff (633 bytes) - added by icyhandofcrap 5 years ago.
managepath.2.diff (633 bytes) - added by icyhandofcrap 5 years ago.
managepath.3.diff (677 bytes) - added by icyhandofcrap 5 years ago.
test.py (261 bytes) - added by anonymous 5 years ago.

Download all attachments as: .zip

Change History (14)

Changed 5 years ago by icyhandofcrap

comment:1 Changed 5 years ago by icyhandofcrap

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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()

comment:2 Changed 5 years ago by Alex

This path uses the Python2.5 ternary conditional syntax, please write this in a way that is 2.3 compatible.

Changed 5 years ago by icyhandofcrap

Changed 5 years ago by icyhandofcrap

comment:3 Changed 5 years ago by icyhandofcrap

okay changed.

comment:4 Changed 5 years ago by ericholscher

  • Needs tests set

Changed 5 years ago by anonymous

comment:5 Changed 5 years ago by anonymous

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 Changed 5 years ago by UloPe

I can't reproduce the problem (Mac OS 10.5, Python 2.5, Django trunk r10697)

comment:7 Changed 5 years ago by anonymous

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 Changed 5 years ago by ericholscher

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 Changed 5 years ago by jacob

  • Resolution set to wontfix
  • Status changed from new to 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.

comment:10 Changed 3 years ago by jacob

  • milestone 1.1 deleted

Milestone 1.1 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.