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
* 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).