Created
November 11, 2021 10:22
-
-
Save RobertKolner/f97871624323c00902a72326886557a0 to your computer and use it in GitHub Desktop.
Use poetry to write requirements.txt. Potentially useful with pre-commit in cases when the project is deployed to a service that assumes existence of requirements.txt (for instance Google Cloud Functions).
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
#!/usr/bin/env bash | |
NEW_REQUIREMENTS=$(poetry export -f requirements.txt --without-hashes | cut -d';' -f1) | |
if [ ! -f requirements.txt ]; then | |
echo "requirements.txt does not exist!" | |
poetry export --without-hashes | cut -d';' -f1 > requirements.txt | |
exit 1 | |
fi | |
REQUIREMENTS=$(cat requirements.txt) | |
if [ "$NEW_REQUIREMENTS" = "$REQUIREMENTS" ]; then | |
exit 0 | |
else | |
echo "requirements.txt is not up to date!" | |
poetry export --without-hashes | cut -d';' -f1 > requirements.txt | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment