Further constrain dependency versions in setup.py and requirements.txt #934
+68
−16
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.
This PR addresses three needs with respect to dependency management and updates both
setup.pyandrequirements.txtto add some constraints on a few dependencies in order to make installations trouble-free.In some environments, we need to constrain the versions of certain Python packages required to pip-install TFQ in order to avoid pip dependency resolution errors. The two problems that I'm seeing on Linux and Colab are (a) pip may try to install a version of the dependency that requires a higher version of Python than what the user is running, an (b) pip tries to install or build NumPy 2 because some dependency version constraints NumPy to be >2. To deal with this, this PR adds a few additional version constraints to
setup.pyfor packages that end up needing to be installed when installing TFQ. These additions tosetup.pyare the minimum version constraints that produced error-free installations in my testing.Similar dependency version constraints need to be specified for developers installing dependencies using
requirements.txt. However, a better approach forrequirements.txtis to use a minimalrequirements.infile in combination withpip-compileto write the finalrequirements.txt. The resultingrequirements.txtfile leads to more predictable build & test environments.A shortcoming of generating
requirements.txtwith version pins is that the versions of some transitive dependencies may need to be updated to address security releases. Simply re-runningpip-compileto produce a newrequirements.txtmay not update the versions because the dependencies that bring in the transitive dependencies have not themselves changed. The recommended practice for this situation is to put the version constraints into a separate constraint file and pass it as an argument topip-compile. (pip-compilehas explicit support for this.) Some additions to the scriptscripts/generate_requirements.shencapsulate and document this process.