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
#!/usr/bin/env bash | |
# The name of your project | |
PROJECT=my_project | |
# The name of your virtual environment | |
VIRTUAL_ENV=env | |
# The url of your s3 bucket, where the zip file will be uploaded | |
S3_BUCKET=s3://<my-s3-bucket>/ | |
# The path where your packages will be deployed | |
PYTHON_PATH=build/python/lib/python3.7/site-packages | |
# The version of the python that you will use | |
PYTHON_VERSION=python3 | |
# The pip version you will use | |
PIP_VERSION=pip3 | |
# Default commands | |
build: virtual copy_python remove_unused zip upload_to_s3 | |
virtual: | |
@echo "--> Setup and activate virtualenv" | |
if test ! -d "$(VIRTUAL_ENV)"; then \ | |
pip3 install virtualenv; \ | |
virtualenv -p $(PYTHON_VERSION) $(VIRTUAL_ENV); \ | |
. ./$(VIRTUAL_ENV)/bin/activate; \ | |
$(PIP_VERSION) install -r requirements.txt; \ | |
mkdir -p ./$(PYTHON_PATH); \ | |
fi | |
@echo "Done." | |
copy_python: | |
cp -a $(VIRTUAL_ENV)/lib/python3.7/site-packages/. ./$(PYTHON_PATH) | |
remove_unused: | |
rm -rf ./$(PYTHON_PATH)/wheel* | |
rm -rf ./$(PYTHON_PATH)/easy-install* | |
rm -rf ./$(PYTHON_PATH)/setuptools* | |
rm -rf ./$(PYTHON_PATH)/virtualenv* | |
rm -rf ./$(PYTHON_PATH)/pip* | |
zip: | |
cd ./build/ && zip -r ../$(PROJECT).zip . | |
upload_to_s3: | |
aws s3 cp $(PROJECT).zip $(S3_BUCKET) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment