-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4f82694
commit 3a870d4
Showing
1 changed file
with
3 additions
and
40 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,7 @@ | ||
#!/bin/bash | ||
|
||
# Set the project directory and requirements file paths | ||
PROJECT_DIR="lightorch" | ||
REQUIREMENTS_IN="requirements.in" | ||
REQUIREMENTS_TXT="requirements.txt" | ||
pipreqs lightorch --savepath=requirements.in | ||
|
||
# Check if pipreqs is installed | ||
if ! command -v pipreqs &> /dev/null; then | ||
echo "pipreqs could not be found. Please install it with 'pip install pipreqs'." | ||
exit 1 | ||
fi | ||
pip-compile requirements.in | ||
|
||
# Generate requirements.in using pipreqs | ||
echo "Generating ${REQUIREMENTS_IN} with pipreqs..." | ||
pipreqs "$PROJECT_DIR" --force --savepath="$REQUIREMENTS_IN" | ||
|
||
# Check if pipreqs succeeded | ||
if [[ $? -ne 0 ]]; then | ||
echo "pipreqs failed to generate ${REQUIREMENTS_IN}. Exiting." | ||
exit 1 | ||
fi | ||
|
||
# Check if requirements.in exists and is not empty | ||
if [[ ! -s "$REQUIREMENTS_IN" ]]; then | ||
echo "${REQUIREMENTS_IN} is empty or does not exist. Exiting." | ||
exit 1 | ||
fi | ||
|
||
# Compile requirements.in to requirements.txt using pip-compile | ||
echo "Compiling ${REQUIREMENTS_IN} to ${REQUIREMENTS_TXT} with pip-compile..." | ||
pip-compile --output-file="$REQUIREMENTS_TXT" "$REQUIREMENTS_IN" | ||
|
||
# Check if pip-compile succeeded | ||
if [[ $? -ne 0 ]]; then | ||
echo "pip-compile failed to generate ${REQUIREMENTS_TXT}. Exiting." | ||
exit 1 | ||
fi | ||
|
||
# Remove the intermediate requirements.in file | ||
echo "Removing ${REQUIREMENTS_IN}..." | ||
rm -f "$REQUIREMENTS_IN" | ||
|
||
echo "Requirements successfully generated in ${REQUIREMENTS_TXT}." | ||
rm -f requirements.in |