Skip to content

bpo-37412: pythoninfo: add Windows long paths #14434

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 28, 2019
Merged

bpo-37412: pythoninfo: add Windows long paths #14434

merged 1 commit into from
Jun 28, 2019

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Jun 27, 2019

On Windows, test.pythoninfo now checks if support for long paths is
enabled using ntdll.RtlAreLongPathsEnabled() function.

Co-Authored-By: Eryk Sun [email protected]

https://bugs.python.org/issue37412

@vstinner
Copy link
Member Author

The code comes from @eryksun, so I added him as a co-author:
#14424 (comment)

@vstinner
Copy link
Member Author

@eryksun: Would you mind to review this change?

I tested it manually on my Windows VM:

windows.long_paths_enabled: True

Maybe it was the Python installer who proposed me to enable this Windows feature, I don't recall.

@vstinner
Copy link
Member Author

  • AppVeyor: windows.long_paths_enabled: False
  • Azure Pipelines, win32: windows.long_paths_enabled: True
  • Azure Pipelines, win64: windows.long_paths_enabled: True

@vstinner
Copy link
Member Author

Oh, there is also a RtlIsLongPathAwareProcessByManifest() function which may be interesting to check:
https://stackoverflow.com/questions/40983329/are-long-path-behavior-per-app-can-be-enable-via-the-manifest

I updated my PR to also call this function. Result on my Windows 10 VM:

sys.windowsversion: sys.getwindowsversion(major=10, minor=0, build=17763, platform=2, service_pack='')
windows.RtlAreLongPathsEnabled: True
windows.RtlIsLongPathAwareProcessByManifest: <function not available>

Oh, RtlIsLongPathAwareProcessByManifest is not function not available in ntdll on my VM? :-(

@vstinner
Copy link
Member Author

Results on AppVeyor:

platform.platform: Windows-10-10.0.14393-SP0
sys.windowsversion: sys.getwindowsversion(major=10, minor=0, build=14393, platform=2, service_pack='')
windows.RtlAreLongPathsEnabled: False
windows.RtlIsLongPathAwareProcessByManifest: True

Results on Azure Pipeline, win32 and win64 (same values):

sys.windowsversion: sys.getwindowsversion(major=10, minor=0, build=14393, platform=2, service_pack='')
windows.RtlAreLongPathsEnabled: True
windows.RtlIsLongPathAwareProcessByManifest: True

@vstinner
Copy link
Member Author

RtlIsLongPathAwareProcessByManifest may be interesting when I will backport this change to old Python versions. I'm trying to keep the pythoninfo.py code the same in all branches.

@eryksun
Copy link
Contributor

eryksun commented Jun 28, 2019

RtlIsLongPathAwareProcessByManifest may be interesting when I will backport this change to old Python versions. I'm trying to keep the pythoninfo.py code the same in all branches.

I wouldn't worry about RtlIsLongPathAwareProcessByManifest. It only exists in older versions of Windows 10, and IIRC it's called only once at process startup. I'm pretty sure that RtlIsLongPathAwareProcessByManifest was removed because the scope of the long-path policy is the Windows base API, not the NT API. Thus the initial configuration should be, and now is, implemented completely in kernelbase.dll, using private functions.

KernelbasePostInit evaluates whether long paths are enabled, and if so it sets the IsLongPathAwareProcess flag in the Process Environment Block (PEB). This flag value is what RtlAreLongPathsEnabled checks.

KernelbasePostInit first calls BasepIsProcessLongPathAwareByPolicy to check the "LongPathsEnabled" registry value. If the policy is enabled, it calls BasepIsProcessLongPathAwareByGlobalOverride to check the "LPGO" registry value, which is a relatively new feature that globally overrides the application manifest. (I would recommend against setting this value.) If the global override isn't set, it calls BasepIsProcessLongPathAwareByManifest, which calls RtlQueryActivationContextApplicationSettings to check whether "longPathAware" is enabled in the application manifest. If so, it sets the IsLongPathAwareProcess flag in the PEB.

On Windows, test.pythoninfo now checks if support for long paths is
enabled using ntdll.RtlAreLongPathsEnabled() function.

Co-Authored-By: Eryk Sun <[email protected]>
@vstinner
Copy link
Member Author

I wouldn't worry about RtlIsLongPathAwareProcessByManifest

Ok ok. Anyway, this info can be retrieved indirectly from the Python version. I rebased my PR and squashed commits.

@eryksun: Would you mind to review the updated PR?

@vstinner vstinner merged commit 64580da into python:master Jun 28, 2019
@vstinner vstinner deleted the pythoninfo_long_paths branch June 28, 2019 16:05
@vstinner
Copy link
Member Author

I merged my PR. Thanks @eryksun for reviews!

lisroach pushed a commit to lisroach/cpython that referenced this pull request Sep 10, 2019
On Windows, test.pythoninfo now checks if support for long paths is
enabled using ntdll.RtlAreLongPathsEnabled() function.

Co-Authored-By: Eryk Sun <[email protected]>
DinoV pushed a commit to DinoV/cpython that referenced this pull request Jan 14, 2020
On Windows, test.pythoninfo now checks if support for long paths is
enabled using ntdll.RtlAreLongPathsEnabled() function.

Co-Authored-By: Eryk Sun <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants