Last active
April 21, 2020 14:05
-
-
Save mastrobirraio/a354b3805432834aa23329ccdc947085 to your computer and use it in GitHub Desktop.
Recreate project requirements script
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
Color_Off='\033[0m' # Text Reset | |
Red='\033[0;31m' # Red | |
Green='\033[0;32m' # Green | |
REQUIREMENTS_PATH="${PWD}/requirements.txt" | |
function print_out { | |
COLOR=$1 | |
MESSAGE=$2 | |
echo "${COLOR}${MESSAGE}${Color_Off}" | |
} | |
# Informations | |
echo "Local: $PWD" | |
echo "Python version: $(which python3)" | |
echo "PIP version: $(which pip3)" | |
echo "Target file: ${REQUIREMENTS_PATH}" | |
# Requirements recreation | |
unlink $REQUIREMENTS_PATH | |
pip3 freeze > $REQUIREMENTS_PATH | |
# Final check | |
if [ -f "$REQUIREMENTS_PATH" ]; then | |
print_out $Green "Requirements succesfully created at: ${REQUIREMENTS_PATH}" | |
else | |
print_out $Red "Error during requirements creation" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
mkrequirements
This script allows to create/rewrite using only a command a requirements.txt for a python project.
Getting Started
These instructions will get you a copy of the script running on your local machine.
Setup
Create a directory in your home
Get the script
Create an alias in your
.bashrc
or.zshrc
and load itUsage
Go to the directory containing
requirements.txt
or directory you want to create it. And start command:Author
Giuseppe "mastrobirraio" Matranga - mastrobirraio