File: testenv

package info (click to toggle)
spigot 0.2017-01-15.gdad1bbc6-1
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, buster, forky, sid, stretch, trixie
  • size: 904 kB
  • ctags: 1,521
  • sloc: cpp: 9,516; sh: 1,225; python: 643; makefile: 24
file content (33 lines) | stat: -rwxr-xr-x 1,119 bytes parent folder | download
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
#!/usr/bin/env python

import sys
import os
import glob
import pipes

# Set up PYTHONPATH to use the output of 'setup.py build', which will
# be in a subdirectory called 'lib.<something>' of the 'build'
# directory. The <something> will depend on the particular host
# architecture, so we use glob to find it, and hope to find only one
# of them.

builddir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "build")
libdirs = glob.glob(os.path.join(builddir, "lib.*"))
if len(libdirs) > 1:
    sys.stderr.write("Found multiple possible lib directories:" + "".join(
            ["\n  %s" % libdir for libdir in libdirs]) + "\n")
    sys.exit(1)
if len(libdirs) == 0:
    sys.stderr.write("Found no possible lib directory in %s\n" % builddir)
    sys.exit(1)
if "PYTHONPATH" in os.environ:
    os.environ["PYTHONPATH"] = libdirs[0] + ":" + os.environ["PYTHONPATH"]
else:
    os.environ["PYTHONPATH"] = libdirs[0]

if len(sys.argv) > 1:
    os.execvp("python", ["python"] + sys.argv[1:])
else:
    sys.stdout.write(
        pipes.quote("PYTHONPATH=" + os.environ["PYTHONPATH"]) +
        "; export PYTHONPATH\n")