https://github.com/systemvll/py-pack
A bundler for python and friends. Packs many python modules and project files into a few bundled python assets.
https://github.com/systemvll/py-pack
builder bundler packer
Last synced: 4 months ago
JSON representation
A bundler for python and friends. Packs many python modules and project files into a few bundled python assets.
- Host: GitHub
- URL: https://github.com/systemvll/py-pack
- Owner: SystemVll
- License: mit
- Created: 2025-02-25T13:03:03.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-12-29T22:46:45.000Z (5 months ago)
- Last Synced: 2026-01-02T05:50:18.086Z (5 months ago)
- Topics: builder, bundler, packer
- Language: Python
- Homepage:
- Size: 21.5 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Python Package Chunker (PyPack)
A webpack-like bundler for Python that splits code into optimized chunks.

## Features
- π¦ Code splitting into multiple chunks
- π Automatic dependency analysis
- πΊοΈ Chunk manifest generation
- π Dynamic chunk loading
- π Smart module assignment based on dependencies
- β‘ Webpack-like configuration
- π Regex-based file matching
## Installation
```bash
git clone https://github.com/SystemVll/py-pack.git
cd pypack
pip install -e .
```
## Usage
Create a configuration file (`main.py`):
```python
from src.ChunkConfig import ChunkConfig
from src.PythonPacker import PythonPacker
packer = PythonPacker("./src/main.py", "./dist")
# Configure chunks
chunks = [
ChunkConfig(
name="vendor",
entry_points=[],
includes=[r".*[/\\]vendor[/\\].*\.py"]
),
ChunkConfig(
name="features",
entry_points=["./src/features/feature1.py", "./src/features/feature2.py"],
includes=[r".*[/\\]features[/\\].*\.py"]
),
]
packer.configure_chunks(chunks)
packer.pack()
```
## Configuration
### ChunkConfig Options
- `name`: Name of the chunk
- `entry_points`: List of entry point files for the chunk
- `includes`: List of regex patterns to match files that should be included in the chunk
## Output
The bundler generates:
- Separate chunk files in the `dist` directory
- A `manifest.json` file containing chunk mapping information
- Each chunk includes a `load_chunk()` function for dynamic loading
## Dynamic Loading
You can dynamically load chunks in your code:
```python
def load_feature():
feature_module = load_chunk("features")
return feature_module.some_feature()
```
## Development
To contribute to the project:
1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Submit a pull request
## Requirements
- Python 3.7+
- pathlib
- typing
## License
MIT License
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.