Use packaging.version for correct version parsing#4330
Closed
tjstum wants to merge 3 commits intofacebookresearch:mainfrom
Closed
Use packaging.version for correct version parsing#4330tjstum wants to merge 3 commits intofacebookresearch:mainfrom
tjstum wants to merge 3 commits intofacebookresearch:mainfrom
Conversation
Contributor
|
@junjieqi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Contributor
|
@junjieqi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Contributor
samanthawaters8882michaeldonovan
added a commit
to samanthawaters8882michaeldonovan/faiss
that referenced
this pull request
Oct 12, 2025
Summary: If you use a version of numpy that has non-numeric components to the version number (e.g. a [local version identifier](https://peps.python.org/pep-0440/#local-version-identifiers)), `faiss` will not import because the hand-rolled version parsing expects only digits: ``` $ /venv/bin/python -c 'import numpy; print(numpy.__version__)' 2.0.2+hrt0 $ /venv/bin/python -c 'import faiss' Traceback (most recent call last): File "<string>", line 1, in <module> File "/venv/lib/python3.12/site-packages/faiss/__init__.py", line 17, in <module> from .loader import * File "/venv/lib/python3.12/site-packages/faiss/loader.py", line 91, in <module> instruction_sets = supported_instruction_sets() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/venv/lib/python3.12/site-packages/faiss/loader.py", line 47, in supported_instruction_sets if Version(numpy.__version__) >= Version("1.19"): ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/venv/lib/python3.12/site-packages/faiss/loader.py", line 13, in Version return [int(x) for x in v.split('.')] ^^^^^^ ValueError: invalid literal for int() with base 10: '2+hrt0' ``` This project depends on `packaging`, but the use was removed in facebookresearch/faiss#3807 (though the metadata wasn't). This restores the correct parsing of `Version`. If you'd prefer not to add this dependency, what is your suggestion for correctly parsing the numpy version (also, the `install_requires` line should be updated) Pull Request resolved: facebookresearch/faiss#4330 Reviewed By: mnorris11 Differential Revision: D74592146 Pulled By: junjieqi fbshipit-source-id: 258c5b499d356040ff6e373b2b635efa355c50ea
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If you use a version of numpy that has non-numeric components to the version number (e.g. a local version identifier),
faisswill not import because the hand-rolled version parsing expects only digits:This project depends on
packaging, but the use was removed in #3807 (though the metadata wasn't). This restores the correct parsing ofVersion. If you'd prefer not to add this dependency, what is your suggestion for correctly parsing the numpy version (also, theinstall_requiresline should be updated)