-
Notifications
You must be signed in to change notification settings - Fork 710
/
build_dependencies.sh
executable file
·52 lines (43 loc) · 1.41 KB
/
build_dependencies.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env bash
# check to see if pipenv is installed
if [ -x "$(which pipenv)" ]
then
# check that Pipfile.lock exists in root directory
if [ ! -e Pipfile.lock ]
then
echo 'ERROR - cannot find Pipfile.lock'
exit 1
fi
# use Pipenv to create a requirement.txt file
echo '... creating requirements.txt from Pipfile.lock'
pipenv lock -r > requirements.txt
# install packages to a temporary directory and zip it
touch requirements.txt # safeguard in case there are no packages
pip3 install -r requirements.txt --target ./packages
# check to see if there are any external dependencies
# if not then create an empty file to seed zip with
if [ -z "$(ls -A packages)" ]
then
touch packages/empty.txt
fi
# zip dependencies
if [ ! -d packages ]
then
echo 'ERROR - pip failed to import dependencies'
exit 1
fi
cd packages
zip -9mrv packages.zip .
mv packages.zip ..
cd ..
# remove temporary directory and requirements.txt
rm -rf packages
rm requirements.txt
# add local modules
echo '... adding all modules from local utils package'
zip -ru9 packages.zip dependencies -x dependencies/__pycache__/\*
exit 0
else
echo 'ERROR - pipenv is not installed --> run `pip3 install pipenv` to load pipenv into global site packages or install via a system package manager.'
exit 1
fi