View previous topic :: View next topic |
Author |
Message |
jescab
Joined: 28 Jan 2008 Posts: 254
|
Posted: Wed Mar 13, 2013 1:34 am Post subject: Building the PyMQI package on VMS? |
|
|
Hi.
How hard would it be to get PyMQI going using the current Python port for OpenVMS?
http://pythonhosted.org/pymqi/
It seems as it needs the MQ client kit to be installed to build since the C module includes some MQ header files.
MQ client for OpenVMS is a free kit from IBM, FWIW...
I'm currently building applications using Cobol but having a Python interface also could
be a quicker way to run some tests or lower volume prod tasks. |
|
Back to top |
|
 |
jfp
Joined: 12 Jul 2004 Posts: 636
|
Posted: Thu Mar 14, 2013 3:42 pm Post subject: |
|
|
Hi,
I have take a look, it will be, probably, not very difficult to port it to VMS, just one source to compile.
You just need a C compiler and the necessary libraries.
You can use, as a example, any procedure used to build of any module in the source package.
JF |
|
Back to top |
|
 |
jescab
Joined: 28 Jan 2008 Posts: 254
|
Posted: Sat Mar 16, 2013 1:17 pm Post subject: |
|
|
I tried a simple compile of the PYMQE.C file in the kit.
I changed the include statements to include "python_include" and "mqs_include" (for MQ) in the filenames of the .h files.
When compiling with /standard=latest I get two informal messages:
Code: |
$ cc pymqe/stand=lat
typedef ssize_t Py_ssize_t;
........................^
%CC-I-DUPTYPEDEF, In this declaration, "Py_ssize_t" has a duplicate typedef at line number 629 in file PYTHON_ROOT:<Include>pyconfig.h;1.
This might not be portable.
at line number 192 in file PYTHON_ROOT:<Include>pyport.h;1
{NULL, (PyCFunction)NULL, 0, NULL} /* sentinel */
......................^
%CC-I-NONSTANDCAST, In the initializer for pymqe_methods[14].ml_meth, "((void ...)0)" of type "pointer to void",
is being converted to "pointer to function (pointer to struct _object, pointer to struct _object) returning pointer to struct _object".
Such a cast is not permitted by the standard.
at line number 1220 in file UTIL:<PYTHON.PYMQI.PYMQI-1_2>PYMQE.C;5
$ |
Then, I've no idea how this is going to be callable from within Python...
As far as I understand it also has to be linked against the MQ sharable images in sys$share.
I have on this system (my own labb system) this MQ kit:
Quote: |
Welcome to Websphere MQ for HP OpenVMS Alpha, Version 6.0
(hereafter described as Websphere MQ for OpenVMS) from IBM.
Websphere MQ Client Version = 6.0.2.10. |
On the target system (client/customer system) we are running
an older MQ client kit (2.2) that I hope will work to. Normaly there is
a very good compatibility between different MQ versions... |
|
Back to top |
|
 |
jfp
Joined: 12 Jul 2004 Posts: 636
|
Posted: Sun Mar 17, 2013 11:53 am Post subject: |
|
|
You can take a look at PYTHON_ROOT:[vms]build_module.py
which is a simple script to build a .exe module when the source name is the module name and there is no dependencies.
Also : http://forum.vmspython.org/viewtopic.php?t=258
JF |
|
Back to top |
|
 |
jescab
Joined: 28 Jan 2008 Posts: 254
|
Posted: Sun Mar 17, 2013 2:57 pm Post subject: |
|
|
OK.
I made a local copy of the build script and made two changes:
- Added "/include=(python_include, mqs_include)" to the CC command.
- Added "sys$share:mqic/share" to the link options.
That made it a bit longer. Now I get this LINK output:
Code: |
$ python build_pymqi.py pymqe
@SYS$SCRATCH:tmptC0rr4.com
%LINK-W-NUDFSYMS, 10 undefined symbols:
%LINK-I-UDFSYM, mqAddInteger
%LINK-I-UDFSYM, mqAddString
%LINK-I-UDFSYM, mqCountItems
%LINK-I-UDFSYM, mqCreateBag
%LINK-I-UDFSYM, mqDeleteBag
%LINK-I-UDFSYM, mqExecute
%LINK-I-UDFSYM, mqInquireBag
%LINK-I-UDFSYM, mqInquireInteger
%LINK-I-UDFSYM, mqInquireItemInfo
%LINK-I-UDFSYM, mqInquireString
%LINK-W-USEUNDEF, undefined symbol mqDeleteBag referenced in psect $LINK$ offset %X000001D0
in module PYMQE file UTIL:<PYTHON.PYMQI.PYMQI-1_2>PYMQE.OBJ;12
...
...
...
$ |
There is one USEUNDEF for each UDFSYM...
The symbols are available in the MQIC.EXE sharable image I'm linking against.
I do not know enough about the linking process to tell if these warnings are "errors" or not.
It does create an PYMQE.EXE anyway...
This was against a MQ client version 6 (the latest available from IBM for OpenVMS).
Now, I do not think this will build on my customers site anyway, they are on an
older client kit and a few of the .h files are lacking from mqs_include directory.
We have been talking about upgrading the customer site to the
latest MQ client, but that will probably be efter the current project. |
|
Back to top |
|
 |
jfp
Joined: 12 Jul 2004 Posts: 636
|
Posted: Sun Mar 17, 2013 7:31 pm Post subject: |
|
|
I think that you need to add some defines in the source like:
Code: | #define mqAddInteger MQADDINTEGER |
|
|
Back to top |
|
 |
jescab
Joined: 28 Jan 2008 Posts: 254
|
Posted: Mon Mar 18, 2013 12:47 am Post subject: |
|
|
OK.
I added 9 defines matching the message in the earlier post.
That fixed the old messages. Now I get a number of these instead:
Code: |
%CC-I-IMPLICITFUNC, In this statement, the identifier "MQADDINTEGER" is implicitly declared as a function.
at line number 887 in file UTIL:<PYTHON.PYMQI.PYMQI-1_2>PYMQE.C;4
mqAddString(adminBag, paramType, MQBL_NULL_TERMINATED, strArg, &compCode, &compReason);
........^ |
Still builds an EXE of the same size as before... |
|
Back to top |
|
 |
jfp
Joined: 12 Jul 2004 Posts: 636
|
Posted: Mon Mar 18, 2013 10:47 am Post subject: |
|
|
An "import pymqi" under Python should work.
Be sure that the exe name is pymqi.EXE |
|
Back to top |
|
 |
jescab
Joined: 28 Jan 2008 Posts: 254
|
Posted: Mon Mar 18, 2013 12:46 pm Post subject: |
|
|
OK.
First tried to simply copy the EXE but that gave:
Code: |
$ copy pymqe.exe pymqi.exe
$ python
Python 2.7.3+ (default, Mar 14 2013, 19:19:33) [DECC] on OpenVMS
Type "help", "copyright", "credits" or "license" for more information.
>>> import pymqi
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dynamic module does not define init function (initpymqi)
>>> |
As expected, I guess...
I then copied pymqe.c into pymqi.c and changed all "pymqe" into "pymqi" in the file and rerun the build script.
Now the import (and "help (pymqi)") works, but I get stuff like:
Code: |
$ python
Python 2.7.3+ (default, Mar 14 2013, 19:19:33) [DECC] on OpenVMS
Type "help", "copyright", "credits" or "license" for more information.
>>> import pymqi
>>> e = pymqi.MQMIError(2, 2209)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'MQMIError'
>>> |
This should return the text string "MQRC_NO_MSG_LOCKED" from a variable from one of the .py files:
Code: |
$ sea *.py 2209
******************************
UTIL:<PYTHON.PYMQI.PYMQI-1_2>CMQC.PY;2
MQRC_NO_MSG_LOCKED = 2209
$ |
I once had this test script (MQMESS.PY from the distribution) working using the pymqe exe... |
|
Back to top |
|
 |
jfp
Joined: 12 Jul 2004 Posts: 636
|
Posted: Mon Mar 18, 2013 2:51 pm Post subject: |
|
|
I have take a look at the distribution, you should have
CMQXC.py
pymqe.EXE
CMQCFC.py
CMQZC.py
pymqui.py
CMQC.py
Ihave done an error in the .EXE filename, it's pymqe.EXE, not pymqi.EXE
the pymqi module is a Python one.
Sorry. |
|
Back to top |
|
 |
jescab
Joined: 28 Jan 2008 Posts: 254
|
Posted: Mon Mar 18, 2013 7:07 pm Post subject: |
|
|
OK, seems to have been the PYMQI.EXE that messed up the "import pymqi" processing.
Python opened the EXE instead of the .PY file...
Code: |
$ python
Python 2.7.3+ (default, Mar 14 2013, 19:19:33) [DECC] on OpenVMS
Type "help", "copyright", "credits" or "license" for more information.
>>> import pymqi
>>> e = pymqi.MQMIError(2, 2209)
>>> print e
MQI Error. Comp: 2, Reason 2209: FAILED: MQRC_NO_MSG_LOCKED
>>> |
I guess that I have it built correctly now.
Now I need a MQ-server environment to run against...  |
|
Back to top |
|
 |
jescab
Joined: 28 Jan 2008 Posts: 254
|
Posted: Tue May 02, 2017 8:51 pm Post subject: |
|
|
Oh gosh, time flies...
I was just going to post a question about PyMQI and found that
there already was a discussion from 2013 initiated by me!
It actually looks like I was able to build PyMQI in some way before.
But besides of that (and I'm not sure I'm able to find that build at
the moment) is there any chance of seeing PyMQI being built into
the main distribution?
I will also try to look for those old files I used there. My test
Alpha system has been shut down the last 6 months... |
|
Back to top |
|
 |
|