forum.vmspython.org Forum Index forum.vmspython.org
Forum system
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Cython - grouping extension modules into packages

 
Post new topic   Reply to topic    forum.vmspython.org Forum Index -> Python for OpenVMS
View previous topic :: View next topic  
Author Message
EvanJohn



Joined: 20 Oct 2014
Posts: 4
Location: Melbourne, Australia

PostPosted: Thu Oct 23, 2014 7:25 am    Post subject: Cython - grouping extension modules into packages Reply with quote

I have read that Cython will allow extension modules to be combined into packages. I am having a lot of trouble doing this in the VMS environment.

This is hot helped by the fact that the setup() and cythonize() functions are useless in the VMS environment. Perhaps if I could get them working it would solve my problem. Personally I find it much easier to simply use build command lines and MMS.

When I use "$ python setup.py build_ext -v -n" the link command generated is not usable, and the C compiler is invoked via "mc cc" - which is really weird. This does not worry me too much so that I can create a package and link it using the "cython", "cc" and "link" commands "au naturel".
Back to top
View user's profile Send private message
bisonmalembouche



Joined: 01 Jun 2005
Posts: 74

PostPosted: Thu Oct 23, 2014 9:23 am    Post subject: Reply with quote

You should have a look at

https://repos.sysgroup.fr/OpenVMS/vmspython/raw/7ebb52adc47ff89c9a25a6cc8bfec0688cd38283/python/local/vms/starlet/_starlet.c

and

https://repos.sysgroup.fr/OpenVMS/vmspython/files/dd352f166893e10ee6a1eed688e6c239400b2e04/python/local/vms/rtl/lib/build_lib_module.com
Back to top
View user's profile Send private message Send e-mail
EvanJohn



Joined: 20 Oct 2014
Posts: 4
Location: Melbourne, Australia

PostPosted: Mon Oct 27, 2014 2:48 am    Post subject: Thenk you for the links Reply with quote

I gather from the two links that starlet is a module and vms is a package.

I am interested in the package - which is vms, not starlet. My questions are:

Was the vmslib C code generated by Cython or was it hand coded? In either case I need to look at the source.

How are the individual modules - like starlet - linked to the vms package? Are they in the same image? It looks like they are not in the same C compilation (and the same object file) but I guess it is possible. If they are in separate images do they use the same "init..." symbol names?
Back to top
View user's profile Send private message
EvanJohn



Joined: 20 Oct 2014
Posts: 4
Location: Melbourne, Australia

PostPosted: Mon Oct 27, 2014 7:48 am    Post subject: I think I get it. Reply with quote

I had a look at the VMS package a bit more carefully. This is how I think it works:

Each extension module has a straight PY wrapper. E.g. the ptd extension module is called _vmsptd and has a wrapper which is __init__.py in the directory python_root:[local.vms.ptd]. This __init__ defines the wrapper class "Ptd".

The extension, meanwhile, is called _vmsptd and is provided by _vmsptd.exe in the same directory, with the entry-point init_vmsptd.

I think, therefore, the answer to my question is that extension modules are grouped into packages using standard py - directories and classes. The standard py wraps the underlying extension modules which reside in the same directories.
Back to top
View user's profile Send private message
bisonmalembouche



Joined: 01 Jun 2005
Posts: 74

PostPosted: Mon Oct 27, 2014 5:56 pm    Post subject: Reply with quote

There is a Python script: python_vms:build_module.py that takes a module name as P1 (case sensitive) , and generates the shareable for this C module.

latest version
https://repos.sysgroup.fr/OpenVMS/cpython27/files/5fe77cb382a7eea60bae2d89eead74360300e6ba/vms/build_module.py

You can adapt this module to automatically build Cython modules, it should not be difficult.
Back to top
View user's profile Send private message Send e-mail
EvanJohn



Joined: 20 Oct 2014
Posts: 4
Location: Melbourne, Australia

PostPosted: Wed Oct 29, 2014 2:39 am    Post subject: Reply with quote

Thanks for that. I discovered that the main thing I was missing was the __init__.py file in the package directory. This allows the module shareable images to be found using the package (directory) name. (I am a complete beginner at Python, unfortunately.)

All cool. It works really well. Thanks for the help.

PS I have previously tried to export "native" functionality to PHP. This is extremely tedious. Cython makes this kind of thing possible - and efficient.
Back to top
View user's profile Send private message
bisonmalembouche



Joined: 01 Jun 2005
Posts: 74

PostPosted: Wed Oct 29, 2014 1:59 pm    Post subject: Reply with quote

Hello

JFP has written a vms/build_cython_module.py that is available at

https://repos.sysgroup.fr/OpenVMS/cpython27/changeset/e30725302ec576c60ab0a9df7e74c89143cd2269

and will be in the next Python kit.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    forum.vmspython.org Forum Index -> Python for OpenVMS All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group