Skip to content
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

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

Merged
merged 1 commit into from Jun 28, 2019

Conversation

@vstinner
Copy link
Member

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 eryksun@gmail.com

https://bugs.python.org/issue37412

@vstinner

This comment has been minimized.

Copy link
Member Author

commented Jun 27, 2019

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

@vstinner

This comment has been minimized.

Copy link
Member Author

commented Jun 27, 2019

@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

This comment has been minimized.

Copy link
Member Author

commented Jun 28, 2019

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

This comment has been minimized.

Copy link
Member Author

commented Jun 28, 2019

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

This comment has been minimized.

Copy link
Member Author

commented Jun 28, 2019

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

This comment has been minimized.

Copy link
Member Author

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.

@eryksun

This comment has been minimized.

Copy link
Contributor

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.

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

Co-Authored-By: Eryk Sun <eryksun@gmail.com>

@vstinner vstinner force-pushed the vstinner:pythoninfo_long_paths branch from 8e334c6 to edcc55b Jun 28, 2019

@vstinner

This comment has been minimized.

Copy link
Member Author

commented Jun 28, 2019

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

5 checks passed

Azure Pipelines PR #20190628.22 succeeded
Details
bedevere/issue-number Issue number 37412 found
Details
bedevere/news "skip news" label found
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@vstinner vstinner deleted the vstinner:pythoninfo_long_paths branch Jun 28, 2019

@vstinner

This comment has been minimized.

Copy link
Member Author

commented Jun 28, 2019

I merged my PR. Thanks @eryksun for reviews!

LorenzMende added a commit to LorenzMende/cpython that referenced this pull request Aug 11, 2019
bpo-37412: pythoninfo: add Windows long paths (pythonGH-14434)
On Windows, test.pythoninfo now checks if support for long paths is
enabled using ntdll.RtlAreLongPathsEnabled() function.

Co-Authored-By: Eryk Sun <eryksun@gmail.com>
PatrikKopkan pushed a commit to PatrikKopkan/cpython that referenced this pull request Sep 6, 2019
bpo-37412: pythoninfo: add Windows long paths (pythonGH-14434)
On Windows, test.pythoninfo now checks if support for long paths is
enabled using ntdll.RtlAreLongPathsEnabled() function.

Co-Authored-By: Eryk Sun <eryksun@gmail.com>
lisroach added a commit to lisroach/cpython that referenced this pull request Sep 10, 2019
bpo-37412: pythoninfo: add Windows long paths (pythonGH-14434)
On Windows, test.pythoninfo now checks if support for long paths is
enabled using ntdll.RtlAreLongPathsEnabled() function.

Co-Authored-By: Eryk Sun <eryksun@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.