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

ENH Support path length > MAX_PATH=260 on Windows #189

Merged
merged 4 commits into from
Mar 11, 2025

Conversation

jeremiedbb
Copy link
Contributor

@jeremiedbb jeremiedbb commented Mar 11, 2025

Closes #181

  • limit extended to 10 * MAX_PATH (2600)
  • kept a hard limit for security reasons
  • A warning is raised if a library has a path too long, and this lib is ignored

jeremiedbb and others added 4 commits March 11, 2025 13:57
@jeremiedbb
Copy link
Contributor Author

As discussed irl, setting up a test for this behavior seems overly complicated for such a very niche use case. Here's how it looks locally:

In [1]: from threadpoolctl import threadpool_info

In [2]: threadpool_info()
Out[2]: []

In [3]: import numpy

In [4]: threadpool_info()
Out[4]:
[{'user_api': 'blas',
  'internal_api': 'openblas',
  'num_threads': 16,
  'prefix': 'libscipy_openblas',
  'filepath': 'C:\\Users\\J\\miniconda3\\envs\\joblib-dev\\Lib\\site-packages\\numpy.libs\\libscipy_openblas64_-43e11ff0749b8cbe0a615c9cf6737e0e.dll',
  'version': '0.3.28',
  'threading_layer': 'pthreads',
  'architecture': 'Haswell'}]

In [5]: from ctypes import CDLL

# For the purpose of this local test I set the limit to a lower value than 2600 for convenience :) (but still higher than 260)
In [6]: CDLL("C:\\Users\\J\\R\\threadpoolctl\\aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\\libopenblas_tooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo_long.dll")
Out[6]: <CDLL 'C:\Users\J\R\threadpoolctl\aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\libopenblas_tooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo_long.dll', handle 7ffce4130000 at 0x22b7f1d08f0>

In [7]: threadpool_info()
C:\Users\J\R\threadpoolctl\threadpoolctl.py:1103: RuntimeWarning: Could not get the full path of a dynamic library (path too
long). This library will be ignored and threadpoolctl might not be able to control or display information about all loaded
libraries. Here's the truncated path: 'C:\\Users\\J\\R\\threadpoolctl
\aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\\libopenblas_toooooooooooooooooooooooooooooooooooooooooooooooooooooooooo'
  warnings.warn(
Out[7]:
[{'user_api': 'blas',
  'internal_api': 'openblas',
  'num_threads': 16,
  'prefix': 'libscipy_openblas',
  'filepath': 'C:\\Users\\J\\miniconda3\\envs\\joblib-dev\\Lib\\site-packages\\numpy.libs\\libscipy_openblas64_-43e11ff0749b8cbe0a615c9cf6737e0e.dll',
  'version': '0.3.28',
  'threading_layer': 'pthreads',
  'architecture': 'Haswell'}]

Copy link
Contributor

@ogrisel ogrisel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@ogrisel ogrisel merged commit 931a764 into joblib:master Mar 11, 2025
22 checks passed
@ogrisel ogrisel changed the title ENH Support path length > MAX_PATH on Windows ENH Support path length > MAX_PATH=260 on Windows Mar 11, 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

Successfully merging this pull request may close these issues.

Long paths on Windows causes: FileNotFoundError: Could not find module ... (or one of its dependencies).
2 participants