Coder Social home page Coder Social logo

cookiecutter-python-rust-maturin's Introduction

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 mode

Both 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 <your path\nameOfYourLibrary>
  • 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 .

cookiecutter-python-rust-maturin's People

Contributors

maxmekiska avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.