This repository has been archived by the owner on Jan 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup-vendor.sh
executable file
·63 lines (55 loc) · 1.87 KB
/
setup-vendor.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
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env bash
set -e
pyversion=2.7
basedir="$(python -c 'import os, sys;
print os.path.dirname(os.path.dirname(os.path.abspath(sys.argv[1])))' $BASH_SOURCE)"
if [ ! -e "$basedir/vendor/setup-vendor.sh" ] || [ ! -e "$basedir/setup.py" ] ; then
echo "Cannot find appsync/ directory (tried $basedir)"
exit 1
fi
if [ ! -d "$basedir/vendor/bin" ] ; then
echo "Creating vendor/bin/ dirrectory"
mkdir "$basedir/vendor/bin"
fi
if [ ! -e "$basedir/vendor/.gitignore" ] ; then
echo "Creating vendor/.gitignore file"
echo 'bin/python*
bin/easy_install*
bin/pip*
bin/activate*
bin/python*
setuptools-*.egg
pip-*.egg
setuptools.pth
binary-libs
' > "$basedir/vendor/.gitignore"
fi
if [ ! -e "$basedir/vendor/binary-libs.pth" ] ; then
echo 'import site, os; site.addsitedir(os.path.join(os.path.dirname(__file__), "site-packages/binary-libs"))' > $basedir/vendor/binary-libs.pth
fi
cd $basedir
echo "Recreating virtualenv environment"
rm -rf build-env
rm -rf vendor/setuptools-*.egg vendor/pip-*.egg vendor/setuptools.pth vendor/distribute-*.egg
virtualenv -q --python python$pyversion --no-site-packages build-env
# Move the default site-packages out of the way
mv build-env/lib/python$pyversion/site-packages/ build-env/lib/python$pyversion/orig-site-packages
# Symlink vendor/ to site-packages
(cd build-env/lib/python$pyversion
ln -s ../../../vendor site-packages
)
rm build-env/lib/python$pyversion/orig-site-packages/easy-install.pth
mv build-env/lib/python$pyversion/orig-site-packages/* build-env/lib/python$pyversion/site-packages/
rmdir build-env/lib/python$pyversion/orig-site-packages
# Use the vendor/bin bin directory
(cd build-env
mv bin bin-orig
ln -s ../vendor/bin bin
mv bin-orig/* bin/
rmdir bin-orig
)
# Use platlib to keep binary packages out
echo "[install]
install_platlib = $basedir/vendor/binary-libs
" >> build-env/lib/python2.7/distutils/distutils.cfg
echo "done."