Skip to content

Commit

Permalink
Use packaging instead of deprecated distutils for version handling (#…
Browse files Browse the repository at this point in the history
…3191)

Summary:
This PR replaces deprecated `distutils.version.LooseVersion` with [`packaging.version.Version`](https://packaging.pypa.io/en/stable/index.html). This change is needed to support CPython 3.12+.

Pull Request resolved: #3191

Reviewed By: algoriddle

Differential Revision: D52872218

Pulled By: mlomeli1

fbshipit-source-id: 336b2a618fde0a65d70b53c7d8a27aef3b62ece1
  • Loading branch information
kyamagu authored and facebook-github-bot committed Jan 18, 2024
1 parent 091f344 commit c540e76
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions conda/faiss-gpu-raft/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ outputs:
run:
- python {{ python }}
- numpy >=1.19,<2
- packaging
- {{ pin_subpackage('libfaiss', exact=True) }}
test:
requires:
Expand Down
1 change: 1 addition & 0 deletions conda/faiss-gpu/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ outputs:
run:
- python {{ python }}
- numpy >=1.19,<2
- packaging
- {{ pin_subpackage('libfaiss', exact=True) }}
test:
requires:
Expand Down
1 change: 1 addition & 0 deletions conda/faiss/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ outputs:
run:
- python {{ python }}
- numpy >=1.19,<2
- packaging
- {{ pin_subpackage('libfaiss', exact=True) }}
test:
requires:
Expand Down
4 changes: 2 additions & 2 deletions faiss/python/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

from distutils.version import LooseVersion
from packaging.version import Version
import platform
import subprocess
import logging
Expand All @@ -25,7 +25,7 @@ def supported_instruction_sets():
{"NEON", "ASIMD", ...}
"""
import numpy
if LooseVersion(numpy.__version__) >= "1.19":
if Version(numpy.__version__) >= Version("1.19"):
# use private API as next-best thing until numpy/numpy#18058 is solved
from numpy.core._multiarray_umath import __cpu_features__
# __cpu_features__ is a dictionary with CPU features
Expand Down
2 changes: 1 addition & 1 deletion faiss/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
license='MIT',
keywords='search nearest neighbors',

install_requires=['numpy'],
install_requires=['numpy', 'packaging'],
packages=['faiss', 'faiss.contrib'],
package_data={
'faiss': ['*.so', '*.pyd'],
Expand Down

0 comments on commit c540e76

Please sign in to comment.