-
Notifications
You must be signed in to change notification settings - Fork 6
/
pythenv.sh
executable file
·54 lines (45 loc) · 1.9 KB
/
pythenv.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
#!/bin/sh
# Copyright (c) 2015 MIT Probabilistic Computing Project.
#
# This file is part of Venture.
#
# Venture is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Venture is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Venture. If not, see <http://www.gnu.org/licenses/>.
set -Ceu
: ${PYTHON:=python}
root=`cd -- "$(dirname -- "$0")" && pwd`
platform=`"${PYTHON}" -c 'import distutils.util as u; print u.get_platform()'`
version=`"${PYTHON}" -c 'import sys; print sys.version[0:3]'`
# The lib directory varies depending on
#
# (a) whether there are extension modules (here, no); and
# (b) whether some Debian maintainer decided to patch the local Python
# to behave as though there were.
#
# But there's no obvious way to just ask distutils what the name will
# be. There's no harm in naming a pathname that doesn't exist, other
# than a handful of microseconds of runtime, so we'll add both.
libdir="${root}/build/lib"
plat_libdir="${libdir}.${platform}-${version}"
# If distutils/setuptools did not find some libraries, it will install
# them in .eggs rather than modifying anything remotely global like
# the virtualenv we're using, by design. So include those eggs:
eggs=
for egg in ${root}/.eggs/*.egg; do
eggs="$eggs:$egg"
done
export PYTHONPATH="${libdir}:${plat_libdir}${eggs}${PYTHONPATH:+:${PYTHONPATH}}"
export MYPYPATH="${libdir}:${plat_libdir}${eggs}${MYPYPATH:+:${MYPYPATH}}"
bindir="${root}/build/scripts-${version}"
export PATH="${bindir}${PATH:+:${PATH}}"
exec "$@"