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 notebookaiml2.py- Python scriptAIML3.ipynb- Jupyter notebookaiml3.py- Python scriptAIML4.ipynb- Jupyter notebookaiml4.py- Python scriptAIML5.ipynb- Jupyter notebookAIML6.ipynb- Jupyter notebookAIML7 (1).ipynb- Jupyter notebookAIML9.py- Python scriptExp1.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
- Place new files in
aiml_bundle/resources/aiml_files/ - Rebuild the package:
python -m build - 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.resourcesfor reliable resource access in installed packages - Files are bundled into the wheel at build time - no downloads occur during installation
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c574a66ef2066d9d68c07215331d3604962d6c26a029b63bfcb9735eef4558fb
|
|
| MD5 |
0b09833f0ee79bc881359843fc20a278
|
|
| BLAKE2b-256 |
bddfb731a5af2c188a5cbddb0e1866eb8005a6cd80fd9667b39c8a05259df517
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d4e3e478add9b7ff378d17ff4f04cd2c39ca05e688e8c4bc0512deda527c339
|
|
| MD5 |
ef0c8eb1009c3652876049bb93d66ca7
|
|
| BLAKE2b-256 |
b2f33682717e2ceb488a315e5d248cfaf817296fcb5c43abe522254b27906235
|