classification
Title: Opt-out of MAX_PATH on Windows 10
Type: enhancement Stage: resolved
Components: Windows Versions: Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: steve.dower Nosy List: brett.cannon, eryksun, haypo, paul.moore, pitrou, python-dev, steve.dower, tim.golden, vinay.sajip, zach.ware
Priority: normal Keywords:

Created on 2016-08-10 23:09 by steve.dower, last changed 2016-09-07 05:44 by steve.dower. This issue is now closed.

Messages (12)
msg272385 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2016-08-10 23:09
According to https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx we can opt-out of MAX_PATH limitations on a selection of functions on the latest version of Windows 10. This will allow unprefixed paths (i.e. no "\\?\") to exceed 260 characters for many common functions.

I will enable this for Python 3.6.
msg272939 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2016-08-17 13:27
Hum, but we use the same binary (.exe) for all Windows versions. Does it mean that we drop support for Windows < 10 in Python 3.6?
msg272960 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2016-08-17 15:34
No, the flag that we add to the binary is backwards compatible. Earlier versions will just ignore it.
msg273054 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2016-08-18 18:31
This is great! Will it apply to third-party C extensions loaded into Python?
msg273060 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2016-08-18 19:10
Steve Dower added the comment:
> No, the flag that we add to the binary is backwards compatible. Earlier
versions will just ignore it.

Cool.
msg273061 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2016-08-18 19:16
> Will it apply to third-party C extensions loaded into Python?

Yes, anything running under the python.exe will get it for free.

(Non-standard entry points will need to add the flag themselves.)
msg273067 - (view) Author: Eryk Sun (eryksun) * Date: 2016-08-18 22:43
> anything running under the python.exe will get it for free.

py.exe may as well get the manifest setting, but it's not critical. It isn't common to store scripts in deeply nested paths. The same goes for the distlib launchers that pip uses for entry points since they have to open themselves.
msg274312 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2016-09-03 17:00
Just discovered that this actually requires enabling the group policy for long paths - specifically setting HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem@LongPathsEnabled to 1.

Apparently the manifest is also required, but in my testing the manifest is ignored and we just get long path support for free. So perhaps we should just add a message to file exceptions when the path is >260?
msg274313 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2016-09-03 17:01
More info at https://blogs.msdn.microsoft.com/jeremykuhne/2016/07/30/net-4-6-2-and-long-paths-on-windows-10/
msg274319 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2016-09-03 18:20
SGTM
msg274631 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2016-09-06 21:13
Just confirmed that the manifest not being required is a bug, so I'll add it, document it and complete this.
msg274743 - (view) Author: Roundup Robot (python-dev) Date: 2016-09-07 03:40
New changeset 26601191b368 by Steve Dower in branch 'default':
Issue #27731: Opt-out of MAX_PATH on Windows 10
https://hg.python.org/cpython/rev/26601191b368
History
Date User Action Args
2016-09-07 05:44:31steve.dowersetstatus: open -> closed
resolution: fixed
stage: needs patch -> resolved
2016-09-07 03:40:28python-devsetnosy: + python-dev
messages: + msg274743
2016-09-06 21:13:51steve.dowersetmessages: + msg274631
2016-09-03 18:20:47brett.cannonsetmessages: + msg274319
2016-09-03 17:01:31steve.dowersetmessages: + msg274313
2016-09-03 17:00:59steve.dowersetmessages: + msg274312
2016-08-18 22:43:48eryksunsetnosy: + eryksun, vinay.sajip
messages: + msg273067
2016-08-18 19:16:16steve.dowersetmessages: + msg273061
2016-08-18 19:10:31hayposetmessages: + msg273060
2016-08-18 18:31:28pitrousetnosy: + pitrou
messages: + msg273054
2016-08-17 15:34:31steve.dowersetmessages: + msg272960
2016-08-17 13:27:31hayposetnosy: + haypo
messages: + msg272939
2016-08-10 23:31:42brett.cannonsetnosy: + brett.cannon
2016-08-10 23:09:48steve.dowercreate