Repository navigation
Remove distutils from the TensorFlow version check - #2045
Open
Nas01010101 wants to merge 1 commit into
Open
Nas01010101 wants to merge 1 commit into
Nas01010101 wants to merge 1 commit into
Conversation
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.
Fixes #2044.
_validate_tf_environmentimportsdistutils.versionon every call. Python 3.12 removeddistutils, and tensorflow/tensorflow#116901 stopped installingsetuptools, which provided a shim. With tf-nightly ortensorflow==2.22.0rc1,import tensorflow_probabilitynow fails withModuleNotFoundError.distutilswas used only for version strings thatpackagingrejects, and that path raisedTypeErrorbecause it compared aLooseVersionwith aVersion.Changes:
__init__.py: for a version thatpackagingrejects, parse its leading release number (2.19.0from2.19.0-custom-build) withpackaging. Nodistutilsimport.BUILD: removed thedistutilsdep and added theinit_testtarget.init_test.py: checks that_validate_tf_environmentruns withdistutilsblocked insys.modules, accepts2.19.0-custom-build, and rejects2.17.0-custom-build.Testing (Python 3.12, tf-nightly 2.23.0.dev20261120, no
setuptools):bazel test //tensorflow_probability/python:init_test(Bazel 6.4.0): passes with this change and fails onmainwithModuleNotFoundError. Withsetuptoolsinstalled,mainfails 2 of the 3 tests withTypeError.tfp.distributions.Normal(0., 1.).log_prob(0.)returns -0.9189.pylint --rcfile=testing/pylintrcon both Python files: 10.00/10.