/usr/lib/python3/dist-packages/pyutilib/dev/lpython.py is in python3-pyutilib 5.3.5-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | #!/usr/bin/env python
#
# This script searches for a local python installation, which is
# applied, rather than the python executable on the user's path.
#
# Additionally, this script sets the PATH environmental variable to
# point to the acro/bin directory.
#
import os
from os.path import abspath, basename, dirname, exists, join
import sys
import signal
def lpython(args):
sys.tracebacklimit=0
process = None
def signal_handler(signum, frame):
if not process is None:
if sys.platform == "win32":
# On Windows this calls the Win32 API function TerminateProcess()
process.terminate()
else:
process.send_signal(signal.SIGTERM)
sys.exit(-signum)
signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGHUP, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)
#
# Recurse up the current path, looking for a subdirectory that
# contains 'python/bin/python'
#
pexec = None
try:
# On unix, the shell's reported PWD may be different from the '.'
# inode's absolute path (e.g., when the cwd was reached through
# symbolic links.) This is a trivial way to defer to the shell's
# notion of the cwd and quietly fall back on Python's getcwd() for
# non-unix environments.
curr = os.environ['PWD']
except:
curr = abspath(os.getcwd())
while os.sep in curr:
if exists(join(curr,"python","bin","python")):
pexec = join(curr,"python","bin","python")
os.environ["PATH"] = join(curr,"bin")+os.pathsep+os.environ["PATH"]
break
if exists(join(curr,"python","bin","python.exe")):
pexec = join(curr,"python","bin","python.exe")
os.environ["PATH"] = join(curr,"bin")+os.pathsep+os.environ["PATH"]
break
if exists(join(curr,"bin","python")):
pexec = join(curr,"bin","python")
break
if exists(join(curr,"bin","python.exe")):
pexec = join(curr,"bin","python.exe")
break
if basename(curr) == "":
break
curr = dirname(curr)
if pexec is None:
pexec = 'python'
os.execvp(pexec, [pexec]+args)
#try:
# import subprocess
# process = subprocess.Popen(args)
# process.wait()
# return process.returncode
#
#except ImportError:
# #
# # For Python 2.3
# #
# if pexec is None:
# returncode = os.system(" ".join(["python"]+args))
# else:
# returncode = os.system(" ".join([pexec]+args))
# return returncode
# The [console_scripts] entry point requires a function that takes no
# arguments
def main():
sys.exit( lpython( sys.argv[1:] ) )
if __name__ == '__main__':
main()
|