util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* libfdisk python bindings
@ 2022-04-06 14:24 Jose M. Guisado
  2022-04-11  8:15 ` Karel Zak
  0 siblings, 1 reply; 4+ messages in thread
From: Jose M. Guisado @ 2022-04-06 14:24 UTC (permalink / raw)
  To: util-linux

Hi, recently I've started working on python bindings for libfdisk. Just
a C extension for CPython, like the libmount python bindings.

Early WIP can be found at https://github.com/pvxe/python-libfdisk/

After reading the mailing list archive and previous github issues
related to python bindings, I'm wondering if patches would be accepted,
or python bindings are preferred separate from the util-linux tree.

As of now, I'm only using these bindings to fetch label information and
partition fields using fdisk_partition_to_string. But the idea is also
being able to modify the partition table in the future.

  >>> import fdisk
  >>> cxt = fdisk.Context(device="/dev/sda")
  >>> cxt.label
  <libfdisk.Label object at 0x7f609a8e4f90, name=gpt>
  >>> l = cxt.label
  >>> l.
  l.name  l.type
  >>> l.name
  'gpt'
  >>> l.type
  32
  >>> cxt.nsectors
  3907029168
  >>> cxt.sector_size
  512
  >>> cxt.parts
  [<libfdisk.Partition object at 0x7f8f69f64fb0>,
   <libfdisk.Partition object at 0x7f8f69f64fd0>]
  >>> p = cxt.parts[1]
  >>> cxt.partition_to_string(p, fdisk.FDISK_FIELD_FSTYPE)
  'LVM2_member'


Regards,
Jose

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: libfdisk python bindings
  2022-04-06 14:24 libfdisk python bindings Jose M. Guisado
@ 2022-04-11  8:15 ` Karel Zak
  2022-04-21 13:30   ` Jose M. Guisado
  0 siblings, 1 reply; 4+ messages in thread
From: Karel Zak @ 2022-04-11  8:15 UTC (permalink / raw)
  To: Jose M. Guisado; +Cc: util-linux

On Wed, Apr 06, 2022 at 04:24:34PM +0200, Jose M. Guisado wrote:
> Hi, recently I've started working on python bindings for libfdisk. Just
> a C extension for CPython, like the libmount python bindings.
> 
> Early WIP can be found at https://github.com/pvxe/python-libfdisk/
> 
> After reading the mailing list archive and previous github issues
> related to python bindings, I'm wondering if patches would be accepted,
> or python bindings are preferred separate from the util-linux tree.

Frankly, I'm not sure if adding bindings to the project is good.                                     

We already have libmount there, and it is terrible. It is not up to
date with the original libmount library, it requires some additional
stuff in the build system, extra dependencies, etc., and I have no
time to fix it. (So, my long-term plan is to mark it as obsolete and
remove it from the project.)                                                           

That's the reason why libsmartcols python binding has been maintained
out of the tree, and it would be probably better also for libfdisk.

If you plan to maintain the python binding, we can help you propagate
your project (in util-linux Release Notes, docs, ...).

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: libfdisk python bindings
  2022-04-11  8:15 ` Karel Zak
@ 2022-04-21 13:30   ` Jose M. Guisado
  0 siblings, 0 replies; 4+ messages in thread
From: Jose M. Guisado @ 2022-04-21 13:30 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux

On 11/4/22 10:15, Karel Zak wrote:
> On Wed, Apr 06, 2022 at 04:24:34PM +0200, Jose M. Guisado wrote:
>> Hi, recently I've started working on python bindings for libfdisk. Just
>> a C extension for CPython, like the libmount python bindings.
>>
>> Early WIP can be found at https://github.com/pvxe/python-libfdisk/
>>
>> After reading the mailing list archive and previous github issues
>> related to python bindings, I'm wondering if patches would be accepted,
>> or python bindings are preferred separate from the util-linux tree.
> 
> Frankly, I'm not sure if adding bindings to the project is good.
> 
> We already have libmount there, and it is terrible. It is not up to
> date with the original libmount library, it requires some additional
> stuff in the build system, extra dependencies, etc., and I have no
> time to fix it. (So, my long-term plan is to mark it as obsolete and
> remove it from the project.)
> 
> That's the reason why libsmartcols python binding has been maintained
> out of the tree, and it would be probably better also for libfdisk.

Makes sense. :-)

> If you plan to maintain the python binding, we can help you propagate
> your project (in util-linux Release Notes, docs, ...).
> 

That would be my intention, bindings are still in a very early stage of 
development but the moment they are in some more usable shape I would 
let you know.

Thank you for your time Karel.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* libfdisk python bindings
@ 2023-07-11 16:10 Jose M. Guisado
  0 siblings, 0 replies; 4+ messages in thread
From: Jose M. Guisado @ 2023-07-11 16:10 UTC (permalink / raw)
  To: util-linux; +Cc: kzak

Hi all,

I am developing a python binding for libfdisk, it is released under
the terms of the LGPL2.1+.

I have uploaded a simple website for the project, it is available at:
https://48k.eu/python-libfdisk/

I am using this for FOSS project to partition clients remotely.
The target computers run a Python client that uses python-libdisk to
partition the disks.

Any feedback is welcome, thanks!

P.S: Karel suggested [1] time ago that I could report progress here,
so here I am :-).

[1] 
https://lore.kernel.org/util-linux/20220411081504.izsddsnb4m3uguf5@ws.net.home/

--
Jose.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-07-11 16:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-06 14:24 libfdisk python bindings Jose M. Guisado
2022-04-11  8:15 ` Karel Zak
2022-04-21 13:30   ` Jose M. Guisado
2023-07-11 16:10 Jose M. Guisado

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).