Skip to main content

A pip-installable package bundling AIML notebooks and scripts for offline access

Project description

AIML Bundle

A pip-installable package that bundles AIML notebooks and Python scripts for offline access. All files are included as package data in the wheel/sdist, so no internet connection is required after installation.

Features

  • ๐Ÿ“ฆ Bundle Jupyter notebooks (.ipynb) and Python scripts (.py) as package data
  • ๐Ÿ”Œ Works completely offline after installation
  • ๐Ÿ Simple Python API for listing, reading, and extracting resources
  • ๐Ÿ–ฅ๏ธ Command-line interface for quick access
  • โœ… No external dependencies (standard library only)

Installation

From Built Wheel

First, build the package:

python -m pip install build
python -m build

Then install the generated wheel:

pip install dist/aiml_bundle-0.1.0-py3-none-any.whl

For Development

pip install -e .

Python API

List Resources

import aiml_bundle

# Get list of all bundled files
files = aiml_bundle.list_resources()
print(f"Found {len(files)} files: {files}")

Read Resource Contents

import aiml_bundle

# Read a Python script (returns string)
script_content = aiml_bundle.read_resource("aiml2.py")
print(script_content[:100])

# Read a notebook (returns bytes)
notebook_bytes = aiml_bundle.read_resource("AIML2.ipynb")
print(f"Notebook size: {len(notebook_bytes)} bytes")

Extract Resources to Disk

import aiml_bundle

# Extract a single file
path = aiml_bundle.extract_resource("AIML2.ipynb", "output/")
print(f"Extracted to: {path}")

# Extract all files
paths = aiml_bundle.extract_all("output/all_files/")
print(f"Extracted {len(paths)} files")

Command-Line Interface

List Bundled Files

aiml-bundle list

Output:

Bundled resources (11 files):
  AIML2.ipynb
  AIML3.ipynb
  AIML4.ipynb
  ...

Read a File

# Display first 50 lines (default)
aiml-bundle read aiml2.py

# Display first 20 lines
aiml-bundle read AIML2.ipynb -n 20

# Display entire file
aiml-bundle read Exp1.py -n 0

Extract Files

# Extract a single file
aiml-bundle extract AIML2.ipynb output/

# Extract all files
aiml-bundle extract-all output/all_files/

# Extract all files with verbose output
aiml-bundle extract-all output/ --verbose

Bundled Resources

The package includes the following files:

  • AIML2.ipynb - Jupyter notebook
  • aiml2.py - Python script
  • AIML3.ipynb - Jupyter notebook
  • aiml3.py - Python script
  • AIML4.ipynb - Jupyter notebook
  • aiml4.py - Python script
  • AIML5.ipynb - Jupyter notebook
  • AIML6.ipynb - Jupyter notebook
  • AIML7 (1).ipynb - Jupyter notebook
  • AIML9.py - Python script
  • Exp1.py - Python script

Building and Testing

Build the Package

# Install build tools
pip install build pytest

# Build wheel and source distribution
python -m build

This creates:

  • dist/aiml_bundle-0.1.0-py3-none-any.whl (wheel)
  • dist/aiml_bundle-0.1.0.tar.gz (source distribution)

Run Tests

# Install the package first
pip install dist/aiml_bundle-0.1.0-py3-none-any.whl

# Run tests
pytest tests/

Verify Offline Availability

To confirm the package works offline:

# Install the package
pip install dist/aiml_bundle-0.1.0-py3-none-any.whl

# Disconnect from the internet, then run:
python -c "import aiml_bundle; print(aiml_bundle.list_resources())"

Or create a test script test_offline.py:

import aiml_bundle

# List all resources
resources = aiml_bundle.list_resources()
assert len(resources) > 0, "No resources found!"
print(f"โœ“ Found {len(resources)} resources")

# Read a resource
content = aiml_bundle.read_resource(resources[0])
assert content, "Empty resource content!"
print(f"โœ“ Read resource: {resources[0]} ({len(content)} bytes)")

# Extract a resource
import tempfile
from pathlib import Path

with tempfile.TemporaryDirectory() as tmpdir:
    path = aiml_bundle.extract_resource(resources[0], tmpdir)
    assert path.exists(), "Extracted file not found!"
    
    # Verify content matches
    extracted_content = path.read_bytes()
    original_content = aiml_bundle.read_resource(resources[0])
    if isinstance(original_content, str):
        original_content = original_content.encode('utf-8')
    
    assert extracted_content == original_content, "Content mismatch!"
    print(f"โœ“ Extracted and verified: {resources[0]}")

print("\nโœ… All offline tests passed!")

Run with:

python test_offline.py

Project Structure

aiml/
โ”œโ”€โ”€ pyproject.toml              # Package metadata and build configuration
โ”œโ”€โ”€ MANIFEST.in                 # Include rules for source distribution
โ”œโ”€โ”€ README.md                   # This file
โ”œโ”€โ”€ LICENSE                     # License file (create as needed)
โ”œโ”€โ”€ aiml_bundle/                # Main package directory
โ”‚   โ”œโ”€โ”€ __init__.py            # Package initialization, exports API
โ”‚   โ”œโ”€โ”€ api.py                 # Core API: list, read, extract functions
โ”‚   โ”œโ”€โ”€ cli.py                 # Command-line interface
โ”‚   โ””โ”€โ”€ resources/             # Package data directory
โ”‚       โ””โ”€โ”€ aiml_files/        # Bundled notebooks and scripts
โ”‚           โ”œโ”€โ”€ AIML2.ipynb
โ”‚           โ”œโ”€โ”€ aiml2.py
โ”‚           โ”œโ”€โ”€ AIML3.ipynb
โ”‚           โ”œโ”€โ”€ aiml3.py
โ”‚           โ”œโ”€โ”€ AIML4.ipynb
โ”‚           โ”œโ”€โ”€ aiml4.py
โ”‚           โ”œโ”€โ”€ AIML5.ipynb
โ”‚           โ”œโ”€โ”€ AIML6.ipynb
โ”‚           โ”œโ”€โ”€ AIML7 (1).ipynb
โ”‚           โ”œโ”€โ”€ AIML9.py
โ”‚           โ””โ”€โ”€ Exp1.py
โ””โ”€โ”€ tests/                      # Test suite
    โ””โ”€โ”€ test_bundle.py         # Tests for API functions

Development

Adding New Resources

  1. Place new files in aiml_bundle/resources/aiml_files/
  2. Rebuild the package: python -m build
  3. Reinstall: pip install --force-reinstall dist/aiml_bundle-0.1.0-py3-none-any.whl

Running Tests During Development

# Install in editable mode
pip install -e .

# Run tests
pytest tests/ -v

Requirements

  • Python 3.8 or higher
  • No external runtime dependencies
  • Build dependencies: setuptools>=61.0, wheel, build
  • Test dependencies: pytest>=7.0

License

MIT License - See LICENSE file for details.

Notes

  • All notebook files (.ipynb) are stored as binary data to preserve JSON structure
  • Text files (.py, .md) are stored as UTF-8 encoded text
  • The package uses importlib.resources for reliable resource access in installed packages
  • Files are bundled into the wheel at build time - no downloads occur during installation

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

aimlese-0.1.0.tar.gz (1.3 MB view details)

Uploaded Source

Built Distribution

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

aimlese-0.1.0-py3-none-any.whl (1.3 MB view details)

Uploaded Python 3

File details

Details for the file aimlese-0.1.0.tar.gz.

File metadata

  • Download URL: aimlese-0.1.0.tar.gz
  • Upload date:
  • Size: 1.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0

File hashes

Hashes for aimlese-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c574a66ef2066d9d68c07215331d3604962d6c26a029b63bfcb9735eef4558fb
MD5 0b09833f0ee79bc881359843fc20a278
BLAKE2b-256 bddfb731a5af2c188a5cbddb0e1866eb8005a6cd80fd9667b39c8a05259df517

See more details on using hashes here.

File details

Details for the file aimlese-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: aimlese-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0

File hashes

Hashes for aimlese-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1d4e3e478add9b7ff378d17ff4f04cd2c39ca05e688e8c4bc0512deda527c339
MD5 ef0c8eb1009c3652876049bb93d66ca7
BLAKE2b-256 b2f33682717e2ceb488a315e5d248cfaf817296fcb5c43abe522254b27906235

See more details on using hashes here.

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