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

Windows path length limitations - gracefully handle ~260 char limit when present, #2660

Open
jsirois opened this issue Feb 4, 2025 · 1 comment

Comments

@jsirois
Copy link
Member

jsirois commented Feb 4, 2025

Although the Python windows installer has a final page that allows you to click to enable long path support, you have to actually click. Worse, this assumes you install Python on the target machine running a PEX. You may not; most sharply, in a PEX scie case.

@jsirois
Copy link
Member Author

jsirois commented Feb 5, 2025

Ok, so even on a system with long paths enabled, you get this:

>>> import os
>>> os.path.isdir(r"C:\Users\jsirois\AppData\Local\pex-tool.org\pex\Cache\pip\1\20.3.4-patched\pip.pex\cd68b6ca220083d5773ff357ed1c7e4cd1da0b40\no-extra-requirements\.deps\pip-20.3.4-py2.py3-none-any.whl")
>>> os.path.exists(r"C:\Users\jsirois\AppData\Local\pex-tool.org\pex\Cache\pip\1\20.3.4-patched\pip.pex\cd68b6ca220083d5773ff357ed1c7e4cd1da0b40\no-extra-requirements\.deps\pip-20.3.4-py2.py3-none-any.whl")
False
>>> os.path.islink(r"C:\Users\jsirois\AppData\Local\pex-tool.org\pex\Cache\pip\1\20.3.4-patched\pip.pex\cd68b6ca220083d5773ff357ed1c7e4cd1da0b40\no-extra-requireme
nts\.deps\pip-20.3.4-py2.py3-none-any.whl")
True
>>> os.readlink(r"C:\Users\jsirois\AppData\Local\pex-tool.org\pex\Cache\pip\1\20.3.4-patched\pip.pex\cd68b6ca220083d5773ff357ed1c7e4cd1da0b40\no-extra-requirements
\.deps\pip-20.3.4-py2.py3-none-any.whl")
'..\\..\\..\\..\\..\\..\\..\\installed_wheels\\0\\09de3454168e9999cc459c28a36ca0572466559839baa7cd17ddf7c830d5213b\\pip-20.3.4-py2.py3-none-any.whl'
>>> len(r"C:\Users\jsirois\AppData\Local\pex-tool.org\pex\Cache\pip\1\20.3.4-patched\pip.pex\cd68b6ca220083d5773ff357ed1c7e4cd1da0b40\no-extra-requirements\.deps\p
ip-20.3.4-py2.py3-none-any.whl")
183
>>> len('..\\..\\..\\..\\..\\..\\..\\installed_wheels\\0\\09de3454168e9999cc459c28a36ca0572466559839baa7cd17ddf7c830d5213b\\pip-20.3.4-py2.py3-none-any.whl')
136
>>> len(r"C:\Users\jsirois\AppData\Local\pex-tool.org\pex\Cache\pip\1\20.3.4-patched\pip.pex\cd68b6ca220083d5773ff357ed1c7e4cd1da0b40\no-extra-requirements\.deps\..\..\..\..\..\..\..\installed_wheels\0\09de3454168e9999cc459c28a36ca0572466559839baa7cd17ddf7c830d5213b\pip-20.3.4-py2.py3-none-any.whl")
288
>>> os.path.exists(r"C:\Users\jsirois\AppData\Local\pex-tool.org\pex\Cache\pip\1\20.3.4-patched\pip.pex\cd68b6ca220083d5773ff357ed1c7e4cd1da0b40\no-extra-requirements\.deps\..\..\..\..\..\..\..\installed_wheels\0\09de3454168e9999cc459c28a36ca0572466559839baa7cd17ddf7c830d5213b\pip-20.3.4-py2.py3-none-any.whl")
True
>>> os.path.isdir(r"C:\Users\jsirois\AppData\Local\pex-tool.org\pex\Cache\pip\1\20.3.4-patched\pip.pex\cd68b6ca220083d5773ff357ed1c7e4cd1da0b40\no-extra-requirements\.deps\..\..\..\..\..\..\..\installed_wheels\0\09de3454168e9999cc459c28a36ca0572466559839baa7cd17ddf7c830d5213b\pip-20.3.4-py2.py3-none-any.whl")
True
>>> os.path.isdir(os.path.normpath(r"C:\Users\jsirois\AppData\Local\pex-tool.org\pex\Cache\pip\1\20.3.4-patched\pip.pex\cd68b6ca220083d5773ff357ed1c7e4cd1da0b40\no-extra-requirements\.deps\pip-20.3.4-py2.py3-none-any.whl"))
False
>>> os.path.isdir(os.path.abspath(r"C:\Users\jsirois\AppData\Local\pex-tool.org\pex\Cache\pip\1\20.3.4-patched\pip.pex\cd68b6ca220083d5773ff357ed1c7e4cd1da0b40\no-extra-requirements\.deps\pip-20.3.4-py2.py3-none-any.whl"))
False
>>> os.path.isdir(os.path.realpath(r"C:\Users\jsirois\AppData\Local\pex-tool.org\pex\Cache\pip\1\20.3.4-patched\pip.pex\cd68b6ca220083d5773ff357ed1c7e4cd1da0b40\no-extra-requirements\.deps\pip-20.3.4-py2.py3-none-any.whl"))
True

So ... relative wheel symlinks in the PEX_ROOT will tend to run afoul of path length limitations in ~silent incorrect results for os.path.isXXX checks unless those paths are 1st resolved through symlinks with an os.path.realpath.

@jsirois jsirois changed the title Windows path length limitations - gracefully handle ~260 char limit when preset, Windows path length limitations - gracefully handle ~260 char limit when present, Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant