Django

Code

Ticket #7414 (closed: fixed)

Opened 3 months ago

Last modified 1 month ago

OS X 10.5: setup.py copies admin templates to incorrect location

Reported by: Christopher Schmidt <crschmidt@crschmidt.net> Assigned to: jacob
Milestone: 1.0 alpha Component: Tools
Version: SVN Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

I'm pretty sure this is some kind of bug with OS X 10.5. The install puts the libraries in:

byte-compiling /Library/Python/2.5/site-packages/django/contrib/admin/templatetags/__init__.py to __init__.pyc

However, it installs the admin templates to:

copying django/contrib/admin/templates/admin/change_form.html -> /System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/contrib/admin/templates/admin

So, the templates end up in a different place, so they aren't included when django automatically adds an 'app_dir/templates' directory.

I don't remember this happening under 10.4.

The last comment on #653 appears to be the same issue.

This is with r7612.

Attachments

setup-data-files-macos-r7732.diff (2.2 kB) - added by ajs on 06/29/08 16:15:05.
fix for datafiles being installedin the wrong location

Change History

06/21/08 00:11:28 changed by Karen Tracey <kmtracey@gmail.com>

  • needs_better_patch changed.
  • component changed from Admin interface to Tools.
  • needs_tests changed.
  • milestone set to 1.0.
  • needs_docs changed.
  • stage changed from Unreviewed to Accepted.

We've been getting reports of problems like this on Mac OS X for a while so it's nice to finally have a concrete description of what is going wrong. Changing the component to Tools because I think that covers setup.py, and it is setup.py that will have to change to fix this. Unfortunately I have zero experience with Macs and none to access to test on, so I have no idea how to fix it. Also set milestone to 1.0 since this needs to be fixed by then (though I think earlier would be better, so as to get wider testing for install before 1.0 is frozen).

06/21/08 05:56:38 changed by ajs

#6695 mentions a similar problem and was closed as invalid, with the request to reopen it of someone else encounters it.

06/25/08 03:17:57 changed by Cai <cai@shwons.com>

Using OSX 10.5 on a Mac Book Pro, clean install, Python 2.5, I've also had this problem. The above work around works. When copying the files over, OSX prompts that the folder 'admin' cannot be modified and requests for authentication. I think this is the same as sudo. Either way, copying the templates and media folders into the admin folder fixes the problems.

06/26/08 23:04:39 changed by aezell

I just tried the install on my OS X 10.5 machine and the templates for the admin were copied no where. In this snippet from the install output, you can see that the django/contrib/admin/templates directory is completely skipped.

copying build/lib/django/contrib/admin/models.py -> /Library/Python/2.5/site-packages/django/contrib/admin
creating /Library/Python/2.5/site-packages/django/contrib/admin/templatetags
copying build/lib/django/contrib/admin/templatetags/__init__.py -> /Library/Python/2.5/site-packages/django/contrib/admin/templatetags

I verified that it does exist in the SVN checkout which I just updated. A search of the system seems to indicate that it wasn't copied in the wrong place. It just wasn't copied at all.

This is a slightly different symptom of the problem above, but perhaps the issue comes from the same bit of code. My hunch is that something in this directory walking which builds the list of data_files is going haywire in the templates directory:

for dirpath, dirnames, filenames in os.walk(django_dir):
    # Ignore dirnames that start with '.'
    for i, dirname in enumerate(dirnames):
        if dirname.startswith('.'): del dirnames[i]
    if '__init__.py' in filenames:
        packages.append('.'.join(fullsplit(dirpath)))
    elif filenames:
        data_files.append([dirpath, [os.path.join(dirpath, f) for f in filenames]])

My distutils knowledge is nonexistent, but I did notice that it does some special work for the "darwin" platform in distutils.command.install here:

if sys.platform == "darwin":
    sitepkg = os.path.join(sys.prefix, 'lib', 'python' + sys.version[:3], 'site-packages')
    libpy = os.path.join('/Library/Python', sys.version[:3], 'site-packages')
    if self.install_platlib == sitepkg:
        self.install_platlib = libpy
    if self.install_purelib == sitepkg:
        self.install_purelib = libpy
    if self.install_scripts == os.path.join(sys.prefix, 'bin'):
        self.install_scripts = get_config_var('BINDIR')

Just trying to throw some info out there to see if something jogs someone's brain. This is all with r7772.

06/28/08 15:23:30 changed by ajs

  • owner changed from nobody to ajs.

I'll see wether I can come up with a fix for this. I'm running 10.5 and 10.4 on a second mac.

06/29/08 16:15:05 changed by ajs

  • attachment setup-data-files-macos-r7732.diff added.

fix for datafiles being installedin the wrong location

06/29/08 16:18:31 changed by ajs

  • has_patch set to 1.

the attached patch installs the data files in the django source tree. Tested with 10.5 standard Python (2.5) and also works fine with MacPorts? Python on 10.5. I haven't had a chance to test on 10.4 but will try and get around to it this week, if nobody beats me to it. :)

07/19/08 16:03:57 changed by Karen Tracey <kmtracey@gmail.com>

#7802 was another report of this, though not apparent initially since reporter did not mention OS X. I know this is technically not an alpha item but personally I think it would be great if this install issue could get fixed before alpha. Any chance of that? Getting the fix out there sooner rather than later would get wider exposure and ensure all bases are covered by the fix.

07/20/08 13:26:18 changed by ajs

I just checked with a standard Python 2.4.3 on MacOSX 10.4, and the admin templates are under site-packages/django/contrib/admin.

07/20/08 20:11:23 changed by mtredinnick

  • stage changed from Accepted to Ready for checkin.

I'll commit this when I've done my other "more important than urgent" tasks, unless somebody else gets there first. It looks like it should be harmless on non-Mac platforms, so it shouldn't be a net loss even in the worst case.

07/21/08 11:07:40 changed by jacob

  • owner changed from ajs to jacob.
  • status changed from new to assigned.
  • milestone changed from 1.0 to 1.0 alpha.

07/21/08 11:30:32 changed by jacob

  • status changed from assigned to closed.
  • resolution set to fixed.

(In [8019]) Fixed #7414: fixed setup.py on OSX 10.5. Thanks, ajs.


Add/Change #7414 (OS X 10.5: setup.py copies admin templates to incorrect location)




Change Properties
Action