[python-package] prevent build-python.sh from modifying already-installed dependencies#6403
Merged
[python-package] prevent build-python.sh from modifying already-installed dependencies#6403
Conversation
…lled dependencies
jmoralez
approved these changes
Apr 4, 2024
Contributor
|
This pull request has been automatically locked since there has not been any recent activity since it was closed. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
The recommended workflow for building the Python package from source here uses the
build-python.shscript, like this:cmake -B build -S . cmake --build build --target _lightgbm -j4 sh ./build-python.sh install --precompileThe version for the library from any two unreleased commits is the same (e.g.
4.3.0.99). To ensure thatpipdoes not give up on successive runs and say "ohlightgbm==4.3.0.99is already installed, I'm not installing this wheel", in #5907 we added--force-reinstallto thepip install dist/*inbuild-python.sh.That has the unfortunate side-effect of also force-reinstalling all of
lightgbm's strong runtime dependencies (numpyandscipy). That's undesirable for 2 reasons:numpyversion upgraded by installinglightgbm, even whenlightgbmis compatible with the version ofnumpyyou already havecondaenvironment, this can result in anumpyconda package being replaced by anumpywheel, which can cause a variety of linking and loading problemsThis PR proposes avoiding that, by instead having
build-python.sh installrunpip uninstall --yes lightgbm.How I tested this
In a conda environment without
lightgbminstalled, but withscipyandnumpyinstalled, ran the following.cmake -B build -S . cmake --build build --target _lightgbm -j4 sh ./build-python.sh install --precompileSaw this in the logs, confirming that it didn't change my
numpyorscipyversions.