Metadata-Version: 2.1
Name: pkll
Version: 0.1.10
Summary: Python library for Apple's PKL.
Author-email: Jungwoo Yang <jwyang0213@gmail.com>
License: MIT License
        
        Copyright (c) 2024 Jungwoo Yang
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/jw-y/pkll
Project-URL: Bug Reports, https://github.com/jw-y/pkll/issues
Project-URL: Source, https://github.com/jw-y/pkll
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: msgpack >=1.0.8
Provides-Extra: dev
Requires-Dist: pre-commit ; extra == 'dev'
Requires-Dist: black ; extra == 'dev'
Requires-Dist: isort ; extra == 'dev'
Requires-Dist: mypy ; extra == 'dev'
Requires-Dist: pylint ; extra == 'dev'
Requires-Dist: pytest ; extra == 'dev'
Requires-Dist: pytest-cov ; extra == 'dev'
Requires-Dist: tox ; extra == 'dev'

> [!CAUTION]
> # This project has moved to a new location: [pkl-python on PyPI](https://pypi.org/project/pkl-python/).

---

# PKLL - PKL Language Python Binding
Python binding for [Apple's Pkl language](https://pkl-lang.org/index.html).

### Status
* Evaluator API: fully functional
* Code Generation: in development

### TODO
* [ ] (codgen) binary installation feature
* [ ] (codgen) fix class order
* [ ] (codgen) clean up code
* [x] (evaluator) change default to dataclasses

## Installation

``` bash
pip install pkll
```

## Usage
### Basic Usage
Here's how you can start using PKLL to load a PKL module:

```python
import pkll

config = pkll.load("path/to/pkl/example_module.pkl")
print(config)
```

## Advanced Features
For details on the parameters, refer [Message Passing API](https://pkl-lang.org/main/current/bindings-specification/message-passing-api.html).

```python
from pkll import load

# Advanced loading with custom environment and properties
result = load(
    "path/to/pkl/example_module.pkl"
    env={"CUSTOM_ENV": "value"},
    properties={"custom.property": "value"}
)
print(result)
```

### Custom Handler
It is possible to add custom resources or module handler:
```python
import pkll
from pkll.handler import (
    ListResponse,
    ReadModuleResponse,
    ReadResourceResponse,
    ResourcesHandler,
)
from pkll.msgapi.outgoing import ClientResourceReader

class CustomModuleHandler(ResourcesHandler):
    def list_response(self, uri: str) -> ListResponse:
        return ListResponse(
            pathElements=[{"name": "foo.pkl", "isDirectory": False}]
        )

    def read_response(self, uri: str) -> ReadResourceResponse:
        return ReadModuleResponse(
            contents="foo = 1",
        )

config = pkll.load(
    "./tests/myModule.pkl",
    allowedModules=["pkl:", "repl:", "file:", "customfs:"],
    clientModuleReaders=[
        {
            "scheme": "customfs",
            "hasHierarchicalUris": True,
            "isGlobbable": True,
            "isLocal": True,
        }
    ],
    debug=True,
    module_handler=CustomModuleHandler(),
)
```

## Contributing
Contributions are welcome! If you'd like to contribute, please fork the repository and submit a pull request. For major changes, please open an issue first to discuss what you would like to change.

## License
PKLL is released under the MIT License. See the LICENSE file for more details.

## Contact
For support or to contribute, please contact jwyang0213@gmail.com or visit our GitHub repository to report issues or submit pull requests.
