Location: OpenVMS/cpython27/vms/build_module.py

Jean-Francois Pieronne
OpenVMS patch, Python file to build a C module (single source file only).
import sys
import os
import tempfile
import vms.crtl
import vms.rtl.lib
template = """$ @python_vms:python_compiler_options
$ PYTHON_C_DEBUG = f$trnlnm("PYTHON_C_DEBUG")
$ PYTHON_C_FLOAT = f$trnlnm("PYTHON_C_FLOAT")
$ PYTHON_C_NAMES = f$trnlnm("PYTHON_C_NAMES")
$ PYTHON_C_OPTIM = f$trnlnm("PYTHON_C_OPTIM")
$ cc 'PYTHON_C_DEBUG' 'PYTHON_C_FLOAT' 'PYTHON_C_NAMES' 'PYTHON_C_OPTIM' -
/include=(python_include)/define=(_USE_STD_STAT=1,__USE_INO64=1,-
_LARGEFILE,__NEW_STARLET,_POSIX_EXIT=1) %s.c
$ link/share=%s.exe sys$input:/opt
GSMATCH=lequal,1,1000
case_sensitive=YES
SYMBOL_VECTOR = (init%s=PROCEDURE)
SYMBOL_VECTOR = (INIT%s/init%s=PROCEDURE)
case_sensitive=NO
%s.obj
pythonshr/share
$
$ delete %s;*
"""
p1 = sys.argv[1]
up1 = p1.upper()
fd, fn = tempfile.mkstemp(suffix=".com")
cmd = template % (p1, p1, p1, up1, p1, p1, vms.crtl.to_vms(fn))
os.write(fd, cmd)
os.close(fd)
cmd = '@%s' % (vms.crtl.to_vms(fn),)
print cmd
vms.rtl.lib.do_command(cmd)