Skip to main content

Cross-platform USB image burning library

Project description

Python Tests

libiso

libiso is Rust backed Python library for burning images on USB drives.

Installation

pip install libiso

  • Developed on Linux / Python 3.14
  • Tests are run on and wheels are available for Linux (+ Alpine) / Windows / MacOS / FreeBSD

Usage

import libiso

for drive in libiso.list_removable_drives():
   # Summary - drive.device_path, drive.display_name, drive.total_space_bytes
   print(drive)   

# Name:  USB Flash Disk - 239 GB (/dev/sda)
# Path:  /dev/sda
# Size:  256691404800 bytes

stats = libiso.inspect_image('/path/to/manjaro-kde-26.0.4-260327-linux618.iso')
print(stats)

# Volume Label:      MANJARO_KDE_2604
# Size:              5669099520 bytes
# ISOHybrid:         true
# Large File (>4GB): false
#
# --- Boot Info ---
# Bootable:          true (BIOS: true, UEFI: true)
# Secure Boot:       false
#
# --- Windows Metadata ---
# Is Windows:        False


import tempfile, os, time 

'''
- Unix and Windows treat physical block devices as files (e.g., /dev/sdb)
- libiso's Rust writing backend is abstracted via standard Read/Write/Seek traits
- These snippets use Tempfiles for demonstartion purposes, as do the tests
'''

with (tempfile.NamedTemporaryFile(delete=False) as dest_fd, 
      tempfile.NamedTemporaryFile(delete=False) as source_fd):
   dest_fd.write(b'\x00' * (128 * 1024 * 1024)) 
   source_fd.write(os.urandom(100 * 1024 * 1024))


def show_progress(total, written, mode, sleep_interval=0.05):

   time.sleep(0.05)   # For visual effect
   percent = (written / total) * 100 if total > 0 else 0
   bar = ('█' * int(40 * written / total)).ljust(40, '-')
   print(f'\r\033[K{mode} Mode Write:  |{bar}| {percent:.1f}% ({written}/{total} bytes)', end='')

# Writing in DD mode
for event in libiso.write_image_dd(source_fd.name, dest_fd.name):
    show_progress(event.total, event.written, 'DD')

# DD Mode Write:  |████████████████████████████████████████| 100.0% (209715200/209715200 bytes)


'''
           ---- Writing in ISO mode  ---
- has_large_file = True makes libiso utilize FAT32 + exFAT setup
- Pulling uefi-ntfs.img
-  libiso places the UEFI bridge image int the small FAT32 partition, that then loads the actual exFAT partition with the ISO
'''

with (tempfile.NamedTemporaryFile(delete=False) as dest_fd, 
      tempfile.NamedTemporaryFile(delete=False) as source_fd):
   dest_fd.write(b'\x00' * (128 * 1024 * 1024)) 
   source_fd.write(libiso.create_mock_iso(
      'TEST_ISO', ['EFI/BOOT/BOOTX64.EFI', 'KERNEL.BIN'], True, 50))   # 50Mb for each of the 2 files

uefi_bridge_path = libiso.ensure_uefi_bridge()
for event in libiso.write_image_iso(
   source_fd.name, dest_fd.name, True, 'GPT', uefi_bridge_path
   ):   
   show_progress(event.total, event.written, 'ISO')

# ISO Mode Write:  |████████████████████████████████████████| 100.0% (109051904/109051904 bytes)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

libiso-0.1.1.tar.gz (2.5 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

libiso-0.1.1-cp312-abi3-win_amd64.whl (4.3 MB view details)

Uploaded CPython 3.12+Windows x86-64

libiso-0.1.1-cp312-abi3-musllinux_1_2_x86_64.whl (4.7 MB view details)

Uploaded CPython 3.12+musllinux: musl 1.2+ x86-64

libiso-0.1.1-cp312-abi3-manylinux_2_28_x86_64.whl (4.5 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.28+ x86-64

libiso-0.1.1-cp312-abi3-manylinux_2_28_aarch64.whl (4.4 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.28+ ARM64

libiso-0.1.1-cp312-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (6.3 MB view details)

Uploaded CPython 3.12+macOS 10.12+ universal2 (ARM64, x86-64)macOS 10.12+ x86-64macOS 11.0+ ARM64

File details

Details for the file libiso-0.1.1.tar.gz.

File metadata

  • Download URL: libiso-0.1.1.tar.gz
  • Upload date:
  • Size: 2.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for libiso-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a34d013404a228862a2089d85b01d683f8bced08ccfe2603222485043ce6be06
MD5 7d74d0dd548dae3148804e342ccded78
BLAKE2b-256 021f61d988495747121e32e9714759750e5caabe553702d2162370f86cfd032a

See more details on using hashes here.

Provenance

The following attestation bundles were made for libiso-0.1.1.tar.gz:

Publisher: release.yml on h5rdly/libiso

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file libiso-0.1.1-cp312-abi3-win_amd64.whl.

File metadata

  • Download URL: libiso-0.1.1-cp312-abi3-win_amd64.whl
  • Upload date:
  • Size: 4.3 MB
  • Tags: CPython 3.12+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for libiso-0.1.1-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 1560353b0e44fde4c813696412166d13291f671ee434e1152e2f6fb78127017f
MD5 213dc7c538739217da88b37d845908a8
BLAKE2b-256 162729c3825a0da0e475697f5a95f1bbcb64f50fba93ff3f7beea0f5d20ad74f

See more details on using hashes here.

Provenance

The following attestation bundles were made for libiso-0.1.1-cp312-abi3-win_amd64.whl:

Publisher: release.yml on h5rdly/libiso

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file libiso-0.1.1-cp312-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for libiso-0.1.1-cp312-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 c1aec6417457b2073653332e194cd9f92fe57bc62324fd35be6d1522036acc55
MD5 4d6a0cbe0bc1ce526295d342b713af5f
BLAKE2b-256 914037542c980de5a3a8b76e3ae675c50043f3255530013b32ee0fd748441b1e

See more details on using hashes here.

Provenance

The following attestation bundles were made for libiso-0.1.1-cp312-abi3-musllinux_1_2_x86_64.whl:

Publisher: release.yml on h5rdly/libiso

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file libiso-0.1.1-cp312-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for libiso-0.1.1-cp312-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 58ffcaf8c8ef23afdf7dc6685419a052abcd7dfbbcd127cc9d0356e674f8c77e
MD5 1903fe039af82de7e9dca1a41be28007
BLAKE2b-256 bb394137d1c308b1ecf07e28c06e1002e5f097ef9d92aab93ee34057a2b7ff9f

See more details on using hashes here.

Provenance

The following attestation bundles were made for libiso-0.1.1-cp312-abi3-manylinux_2_28_x86_64.whl:

Publisher: release.yml on h5rdly/libiso

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file libiso-0.1.1-cp312-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for libiso-0.1.1-cp312-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 1e9896da28db1fa44ed9a272a89adfdc7874f6947904aff1a988e133c56671e4
MD5 ecceaeb6ea02dcfa44c89df8e30e3c6e
BLAKE2b-256 0213c94c693ec568150be835bc41c4dac5a9e7c335dffa3a50cb4c14230a7f13

See more details on using hashes here.

Provenance

The following attestation bundles were made for libiso-0.1.1-cp312-abi3-manylinux_2_28_aarch64.whl:

Publisher: release.yml on h5rdly/libiso

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file libiso-0.1.1-cp312-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for libiso-0.1.1-cp312-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 83f82ee40467df287fa10812ad14abf2c8389d4086736dd8e53b327e5fcf2611
MD5 4629d89bdc86ec3b29ebd6bdeb790547
BLAKE2b-256 2997a1b602ef08054103bfdd46f94df9918d626e5c196563da889f5aab2590c2

See more details on using hashes here.

Provenance

The following attestation bundles were made for libiso-0.1.1-cp312-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl:

Publisher: release.yml on h5rdly/libiso

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page