Skip to main content

A python wrapper for littlefs

Project description

Documentation Status https://badge.fury.io/py/littlefs-python.svg

littlefs-python provides a thin wrapper around littlefs, a filesystem targeted for small embedded systems. The wrapper provides a pythonic interface to the filesystem and allows the creation, inspection and modification of the filesystem or individual files. Even if this package uses Cython, the goal is not to provide a high performance implementation. Cython was chosen as an easy method is offered to generate the binding and the littlefs library in one step.

Quick Examples

Let’s create a image ready to transfer to a flash memory using the pythonic interface:

from littlefs import LittleFS

# Initialize the File System according to your specifications
fs = LittleFS(block_size=512, block_count=256)

# Open a file and write some content
with fs.open('first-file.txt', 'w') as fh:
    fh.write('Some text to begin with\n')

# Dump the filesystem content to a file
with open('FlashMemory.bin', 'wb') as fh:
    fh.write(fs.context.buffer)

The same can be done by using the more verbose C-Style API, which closely resembles the steps which must be performed in C:

from littlefs import lfs

cfg = lfs.LFSConfig(block_size=512, block_count=256)
fs = lfs.LFSFilesystem()

# Format and mount the filesystem
lfs.format(fs, cfg)
lfs.mount(fs, cfg)

# Open a file and write some content
fh = lfs.file_open(fs, 'first-file.txt', 'w')
lfs.file_write(fs, fh, b'Some text to begin with\n')
lfs.file_close(fs, fh)

# Dump the filesystem content to a file
with open('FlashMemory.bin', 'wb') as fh:
    fh.write(cfg.user_context.buffer)

Installation

This is as simple as it can be:

pip install littlefs-python

At the moment wheels (which require no build) are provided for the following platforms, on other platforms the source package is used and a compiler is required:

  • Linux: Python 3.6 - 3.11 / x86_64, arm64

  • MacOS: Python 3.6 - 3.11 / x86_64, arm64

  • Windows: Python 3.6 - 3.11 / 32- & 64-bit

Development Setup

Start by checking out the source repository of littlefs-python:

git clone https://github.com/jrast/littlefs-python.git

The source code for littlefs is included as a submodule which must be checked out after the clone:

cd <littlefs-python>
git submodule update --init

this ensures that the correct version of littlefs is cloned into the littlefs folder. As a next step install the dependencies and install the package:

pip install -r requirements.txt
pip install -e .

Development Hints

  • Test should be run before commiting: pytest test

  • Mypy is used for typechecking. Run it also on the tests to catch more issues: mypy src test test/lfs

  • Mypy stubs can be generated with stubgen src. This will create a out direcotry containing the generated stub files.

Creating a new release

  • Make sure the master branch is in the state you want it.

  • Create a tag with the new version number

  • Wait until all builds are completed. A new release should be created automatically on github.

  • Build the source distribution with python setup.py sdist

  • Download all assets (using ci/download_release_files.py)

  • Upload to pypi using twine: twine upload dist/*

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

littlefs-python-0.6.2.tar.gz (464.8 kB view hashes)

Uploaded Source

Built Distributions

littlefs_python-0.6.2-cp311-cp311-win_amd64.whl (143.2 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

littlefs_python-0.6.2-cp311-cp311-win32.whl (119.2 kB view hashes)

Uploaded CPython 3.11 Windows x86

littlefs_python-0.6.2-cp311-cp311-musllinux_1_1_x86_64.whl (930.7 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.1+ x86-64

littlefs_python-0.6.2-cp311-cp311-musllinux_1_1_i686.whl (876.5 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.1+ i686

littlefs_python-0.6.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (930.7 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

littlefs_python-0.6.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (923.8 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

littlefs_python-0.6.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (882.4 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

littlefs_python-0.6.2-cp311-cp311-macosx_11_0_arm64.whl (150.4 kB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

littlefs_python-0.6.2-cp311-cp311-macosx_10_9_x86_64.whl (162.7 kB view hashes)

Uploaded CPython 3.11 macOS 10.9+ x86-64

littlefs_python-0.6.2-cp310-cp310-win_amd64.whl (143.0 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

littlefs_python-0.6.2-cp310-cp310-win32.whl (118.8 kB view hashes)

Uploaded CPython 3.10 Windows x86

littlefs_python-0.6.2-cp310-cp310-musllinux_1_1_x86_64.whl (860.3 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

littlefs_python-0.6.2-cp310-cp310-musllinux_1_1_i686.whl (814.5 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ i686

littlefs_python-0.6.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (851.6 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

littlefs_python-0.6.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (844.6 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

littlefs_python-0.6.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (811.8 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

littlefs_python-0.6.2-cp310-cp310-macosx_11_0_arm64.whl (150.0 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

littlefs_python-0.6.2-cp310-cp310-macosx_10_9_x86_64.whl (162.0 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

littlefs_python-0.6.2-cp39-cp39-win_amd64.whl (143.1 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

littlefs_python-0.6.2-cp39-cp39-win32.whl (118.9 kB view hashes)

Uploaded CPython 3.9 Windows x86

littlefs_python-0.6.2-cp39-cp39-musllinux_1_1_x86_64.whl (861.2 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ x86-64

littlefs_python-0.6.2-cp39-cp39-musllinux_1_1_i686.whl (813.1 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ i686

littlefs_python-0.6.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (851.7 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

littlefs_python-0.6.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (845.1 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

littlefs_python-0.6.2-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (811.3 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

littlefs_python-0.6.2-cp39-cp39-macosx_11_0_arm64.whl (150.2 kB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

littlefs_python-0.6.2-cp39-cp39-macosx_10_9_x86_64.whl (162.3 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

littlefs_python-0.6.2-cp38-cp38-win_amd64.whl (143.1 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

littlefs_python-0.6.2-cp38-cp38-win32.whl (119.0 kB view hashes)

Uploaded CPython 3.8 Windows x86

littlefs_python-0.6.2-cp38-cp38-musllinux_1_1_x86_64.whl (886.2 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ x86-64

littlefs_python-0.6.2-cp38-cp38-musllinux_1_1_i686.whl (837.6 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ i686

littlefs_python-0.6.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (861.1 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

littlefs_python-0.6.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (853.1 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

littlefs_python-0.6.2-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (817.9 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

littlefs_python-0.6.2-cp38-cp38-macosx_11_0_arm64.whl (150.8 kB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

littlefs_python-0.6.2-cp38-cp38-macosx_10_9_x86_64.whl (162.7 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

littlefs_python-0.6.2-cp37-cp37m-win_amd64.whl (142.7 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

littlefs_python-0.6.2-cp37-cp37m-win32.whl (118.2 kB view hashes)

Uploaded CPython 3.7m Windows x86

littlefs_python-0.6.2-cp37-cp37m-musllinux_1_1_x86_64.whl (807.1 kB view hashes)

Uploaded CPython 3.7m musllinux: musl 1.1+ x86-64

littlefs_python-0.6.2-cp37-cp37m-musllinux_1_1_i686.whl (764.4 kB view hashes)

Uploaded CPython 3.7m musllinux: musl 1.1+ i686

littlefs_python-0.6.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (800.0 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

littlefs_python-0.6.2-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (790.6 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ ARM64

littlefs_python-0.6.2-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (757.0 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

littlefs_python-0.6.2-cp37-cp37m-macosx_10_9_x86_64.whl (160.4 kB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

littlefs_python-0.6.2-cp36-cp36m-win_amd64.whl (160.2 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

littlefs_python-0.6.2-cp36-cp36m-win32.whl (128.2 kB view hashes)

Uploaded CPython 3.6m Windows x86

littlefs_python-0.6.2-cp36-cp36m-musllinux_1_1_x86_64.whl (791.7 kB view hashes)

Uploaded CPython 3.6m musllinux: musl 1.1+ x86-64

littlefs_python-0.6.2-cp36-cp36m-musllinux_1_1_i686.whl (746.7 kB view hashes)

Uploaded CPython 3.6m musllinux: musl 1.1+ i686

littlefs_python-0.6.2-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (786.6 kB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.17+ x86-64

littlefs_python-0.6.2-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (772.6 kB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.17+ ARM64

littlefs_python-0.6.2-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (742.3 kB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

littlefs_python-0.6.2-cp36-cp36m-macosx_10_9_x86_64.whl (157.4 kB view hashes)

Uploaded CPython 3.6m macOS 10.9+ x86-64

Supported by

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