mbox series

[0/1] Adjust odd Python bindings

Message ID cover.1650551486.git.ehem+xen@m5p.com (mailing list archive)
Headers show
Series Adjust odd Python bindings | expand

Message

Elliott Mitchell April 21, 2022, 2:31 p.m. UTC
First off, this isn't properly tested.  I know it compiles, but that may
not mean much when this encounters the Real World.

I'm doing initial exploration for a project involving Xen.  Python seems
a good language for the project, so I'm trying out the Python bindings
for Xen.

What I've noticed is the bindings seem wrong.  Importing xen.lowlevel.xc,
then creating a xen.lowlevel.xc.xc() object has too many layers.  The
extra ".xc" is a distinct mismatch for comparable tools.  As such I'm
trying to get rid of the duplicated layer for both xc and xs.

The Python documentation indicates the name given to Extension() should
be the full name, not just the package name.  As such that is being
adjusted too.

I haven't yet done testing beyond confirming this builds, since further
checking will take some time to do...

I'm unsure how widely the Python bindings are used.  Certainly they were
used for PyGRUB.  Have any other projects used them so far?  What I'm
doing is likely to be contributed to the Xen Project, and I suspect the
existence of other projects would be known...

Elliott Mitchell (1):
  tools/python: move lowlevel packages one level up

 tools/pygrub/src/pygrub                 |  4 ++--
 tools/python/setup.py                   | 12 ++++++------
 tools/python/xen/lowlevel/{xc => }/xc.c |  0
 tools/python/xen/lowlevel/{xs => }/xs.c |  0
 4 files changed, 8 insertions(+), 8 deletions(-)
 rename tools/python/xen/lowlevel/{xc => }/xc.c (100%)
 rename tools/python/xen/lowlevel/{xs => }/xs.c (100%)

Comments

Marek Marczykowski-Górecki April 22, 2022, 1:17 a.m. UTC | #1
On Thu, Apr 21, 2022 at 07:31:26AM -0700, Elliott Mitchell wrote:
> I'm unsure how widely the Python bindings are used.  Certainly they were
> used for PyGRUB.  Have any other projects used them so far?  What I'm
> doing is likely to be contributed to the Xen Project, and I suspect the
> existence of other projects would be known...

Yes, Python bindings are used outside of xen.git. I'm aware of few
places in Qubes OS, but I expect there are other users too. So, I'm
afraid breaking the current import method isn't really an option. What
you could try, is to make both versions work at the same time, but TBH
I'm not sure how to do that with C extension.
Elliott Mitchell April 22, 2022, 7:59 p.m. UTC | #2
On Fri, Apr 22, 2022 at 03:17:23AM +0200, Marek Marczykowski-G??recki wrote:
> On Thu, Apr 21, 2022 at 07:31:26AM -0700, Elliott Mitchell wrote:
> > I'm unsure how widely the Python bindings are used.  Certainly they were
> > used for PyGRUB.  Have any other projects used them so far?  What I'm
> > doing is likely to be contributed to the Xen Project, and I suspect the
> > existence of other projects would be known...
> 
> Yes, Python bindings are used outside of xen.git. I'm aware of few
> places in Qubes OS, but I expect there are other users too. So, I'm
> afraid breaking the current import method isn't really an option. What
> you could try, is to make both versions work at the same time, but TBH
> I'm not sure how to do that with C extension.

Simplest would have been to address this in 2004, when the Python
bindings had insignificant usage.  Another handy time when things could
have been broken was the Python 2->3 transition.  Yet now both of those
points have passed.

I suspect this could be done by adding some Python code to an __init__.py
file.  Simply redirect attempts to load the old path to the new path.

Other thing I noted is the Python documentation indicates the first
argument to Extension() was wrong.