Products Resources Support About Us

Rocket Software

Creating a native python extension for z/OS

I am following: and haven’t been able to get the example to build correctly on z/OS with python 3.6.1

I noticed a few oddities:

  • the code was trying to run a script xlc_echocmd which I don’t have. I created a dummy one that just forwarded to xlc as a hack
  • the code was referencing libraries and packages out of /u/pdharr/anaconda-build. I created a dummy user of that name and then created symbolic links over to my installation tree directories
  • xlc was being driven with a -o option at the end of the command. xlc doesn’t like that and wants the -o option at the start. I manually did the link to see what would happen and ended up with SYMBOL Py_InitModule3 UNRESOLVED.

My question - has anyone successfully built a native python extension for z/OS with python 3.6.1? If so, what am I missing in my config?

The last of the 3 issues (link failure) I sorted out by switching the example source code at the URL I provided to one that seems to work for 3.6.1:

#include <Python.h>

static PyObject* helloworld(PyObject* self) {
return Py_BuildValue(“s”, “Hello, Python extensions!!”);

static char helloworld_docs[] =
“helloworld( ): Any message you want to put here!!\n”;

static PyMethodDef helloworld_funcs[] = {
{“helloworld”, (PyCFunction)helloworld,
METH_NOARGS, helloworld_docs},

static struct PyModuleDef HelloWorldDef =
“helloworld”, /* name of module /
“usage: whatever\n”, /
module documentation, may be NULL /
-1, /
size of per-interpreter state of the module, or -1 if the module keeps state in global variables. */

PyMODINIT_FUNC PyInit_helloworld(void)
return PyModule_Create(&HelloWorldDef);

Just to be clear… The generated library I created did indeed ‘work’ (I was able to invoke helloworld from python) but the hacks I had to do make me nervous…

I ended up substituting this with

PyMODINIT_FUNC PyInit_myModule(void)
    return PyModule_Create(&myModule);

to get it to work since apparently that class doesn’t exist in the Python 3 version.

I’m seeing these issues with the public version of the Rocket Python for z/OS install as well. Looks like it occurs because is missing.

#>python3 build  
CEE3501S The module was not found.
         From compile unit RS25:/u/pdharr/anaconda-build/build/python/python-3.6.1/Programs/python.c at entry point main at statement 78 at compile unit offset +000000000E00A800 at entry offset +00000000000006C0 at address 000000000E00A800.

@pfandel is this a similar issue to Installing/running R 3.3.1?