Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#21482 closed New feature (fixed)

Can not collectstatic with symlink option in Windows Vista (and Windows 7 and 8) platform

Reported by: Vajrasky Kok Owned by: Vajrasky Kok
Component: contrib.staticfiles Version: dev
Severity: Normal Keywords: windows
Cc: sky.kok@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In Windows Vista,

C:\SuperSecretProject>python manage.py collectstatic -l
.....
Symlinking is not supported by this platform (Windows)

But I am an administrator. I have the power to create symlink.

http://en.wikipedia.org/wiki/NTFS_symbolic_link
http://en.wikipedia.org/wiki/Symbolic_link

Change History (11)

comment:1 by Vajrasky Kok, 11 years ago

Has patch: set
Owner: changed from nobody to Vajrasky Kok
Status: newassigned

PR to uplift this restriction: https://github.com/django/django/pull/1956

comment:2 by Florian Apolloner, 11 years ago

Patch needs improvement: set

The current checks in the PR aren't enough, if you are on python 2.x and run collectstatic on Vista with -l it will fail. Basically symlinking on windows is only supported on windows vista (and above) + admin account + python3.

Also can you clarify on the administrator bits, do you effectively log in as administrator or will every symlink call ask you if you want to allow it?

comment:3 by Vajrasky Kok, 11 years ago

In Windows Vista, to be able to create symlink, I need to right click the Command Line menu, then click "Run as Administrator". Without this, when I create symlink through os.symlink, I will get error that I don't have enough privileges.

Oh, yeah, I forgot that prior Python 3.2, os does not provide symlink in Windows. Sorry about that.

In Windows XP, you could have the ability to create symlink, but you must install third-party driver. According to Python core developers, they are against giving this feature to Windows XP in Python stdlib. http://bugs.python.org/issue19792

So here is the updated PR. https://github.com/django/django/pull/2011

Windows XP -> no symlink
Python 2.7 in Windows Vista -> no symlink
Python 3.3 in Windows Vista -> symlink (of course you must have administrator privilege)

comment:4 by Vajrasky Kok, 11 years ago

Patch needs improvement: unset

comment:5 by Vajrasky Kok, 11 years ago

It is possible to give symlink support in Python 2.x in Windows. But that requires ctypes and win api.
http://stackoverflow.com/questions/6260149/os-symlink-support-in-windows

But I think I would upset a lot of people in Django if I did that.

comment:6 by Aymeric Augustin, 11 years ago

I'm accepting the idea in general.

However the feature detection code in the current patch looks messy to me (~30 lines) and hard to get right.

I'd find it more pythonic to create the symlink and provide a suitable error message if that fails. Ask for forgiveness rather than permission :)

comment:7 by Aymeric Augustin, 11 years ago

Easy pickings: unset
Needs documentation: set
Patch needs improvement: set
Triage Stage: UnreviewedAccepted

Please add a line in the 1.7 release notes too!

comment:8 by Vajrasky Kok, 11 years ago

Cc: sky.kok@… added
Needs documentation: unset
Patch needs improvement: unset

Okay, I have updated the PR based on your request. Thanks!

https://github.com/django/django/pull/2011

comment:9 by Jannis Leidel <jannis@…>, 11 years ago

Resolution: fixed
Status: assignedclosed

In 5cc0555603167c7532b7b714e2672687da8f106e:

Fixed #21482 -- Uplifted restriction of collectstatic using symlink option in Windows NT 6.

Original patch by Vajrasky Kok. Reviewed by Florian Apolloner, Aymeric Augustin.

comment:10 by Claude Paroz <claude@…>, 11 years ago

In 18b3788401e823266a560b12000697da04490beb:

Cleaned temp dir in symlinks_supported()

Refs #21482.

comment:11 by Claude Paroz <claude@…>, 11 years ago

In a90f0e605e9a7c1b30ccdca222ee2a0e7a78043b:

[1.7.x] Cleaned temp dir in symlinks_supported()

Refs #21482.
Backport of 18b3788401 from master.

Note: See TracTickets for help on using tickets.
Back to Top