https://github.com/maxmekiska/cookiecutter-python-rust-maturin
Enhanced maturin python rust template.
https://github.com/maxmekiska/cookiecutter-python-rust-maturin
cookiecutter maturin python rust
Last synced: about 1 month ago
JSON representation
Enhanced maturin python rust template.
- Host: GitHub
- URL: https://github.com/maxmekiska/cookiecutter-python-rust-maturin
- Owner: maxmekiska
- License: mit
- Created: 2023-09-02T03:22:04.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-09-08T01:17:27.000Z (over 1 year ago)
- Last Synced: 2024-10-09T12:58:14.944Z (7 months ago)
- Topics: cookiecutter, maturin, python, rust
- Language: Python
- Homepage:
- Size: 21.7 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Cookiecutter Python Rust Maturin Template
Please run the following commands to use this template:
- `pip install cookiecutter`
- `cookicuter https://github.com/maxmekiska/cookiecutter-python-rust-maturin`## Overview
Enhanced maturin python rust template. The template supports two main modes:
1. python library mode
2. microservice modeBoth modes can be used with no changes.
## Run as a library
- install maturin via: `pip install maturin`
- Either:
- development mode
- build package in development mode via: `maturin develop`
- build wheel
- build package wheel via: `maturin build --interpreter python`
- `pip install .`You can still run the library in microservice mode via the command: `micro-launch`
## Build as a Microservice
- `docker build -t my-microservice .`
- `docker run -d -p 8000:8000 --name test-service my-microservice`### Send example requests via curl
`/heartbeat/`
```
curl http://127.0.0.1:8000/heartbeat/
````/run/sum/`
```
curl -X 'POST' \
'http://localhost:8000/run/sum/' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"a": 1,
"b": 2
}'
````/run/diff/`
```
curl -X 'POST' \
'http://localhost:8000/run/diff/' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"a": 2,
"b": 1
}'
```## Format and Test via tox
- install tox via: `pip install tox`
- run tox via: `tox`## Appendix
#### Core was build via Maturin
- create a vitual env: `python -m venev env`
- activate env: `.\env\Scripts\activate`
- pip install maturin
- run `maturin new --mixed `
- test via either:
- development mode
- build package in development mode via: `maturin develop`
- build wheel
- build package wheel via: `maturin build --interpreter python`
- `pip install .`