nallwhy

nallwhy

Doumi.Port - A helper library that facilitates the usage of Python in Elixir

Doumi.Port is a helper library that facilitates the usage of Python in Elixir powered by Erlport, NimblePool.

https://github.com/nallwhy/doumi_port

It’s inspired by Export, but not just a wrapper of Erlport, will be a toolchain for using Python, Ruby in Elixir.

defmodule MyApp.Application do
  ...

  @impl true
  def start(_type, _args) do
    children = [
      ...
      {Doumi.Port.Pool, port: {Doumi.Port.Python, python_path: [...]}, name: MyApp.PythonPool}
    ]

    Supervisor.start_link(children, strategy: :one_for_one, name: MyApp.Supervisor)
  end
end

defmodule MyApp.Native do
  def add(a, b) do
    Doumi.Port.Pool.command(MyApp.PythonPool, :operator, :add, [a, b])
  end
end

> MyApp.Native.add(1, 2)
3

Thanks!

Most Liked

nallwhy

nallwhy

v0.4.0 is released!

  • It supports Ruby also.
  • mix doumi.port.init, mix doumi.port.setup is added.

# Create requirements.txt, .gitignores to ./priv/python

mix doumi.port.init --port python

# Add Python dependency

echo "pypdf2==3.0.1" >> ./priv/python/requirements.txt

# Install Python dependecies

mix doumi.port.setup --port python

You can install Python dependencies to your release with mix doumi.port.setup.

defmodule MyApp.MixProject do
  defp aliases do
    [
      ...,
      "release.setup": ["doumi.port.setup --port python", ...]
    ]
  end
end
...

# release setup (ex. install Python dependencies, compile assets)
RUN mix release.setup

...
nallwhy

nallwhy

v0.2.0 is released!

use macro is added to make it easier.

defmodule MyApp.PythonPool do
  use Doumi.Port.Pool,
    port: {Doumi.Port.Python, python_path: [...]}
end

defmodule MyApp.Application do
  ...

  @impl true
  def start(_type, _args) do
    children = [
      ...
      MyApp.PythonPool
    ]

    Supervisor.start_link(children, strategy: :one_for_one, name: MyApp.Supervisor)
  end
end

defmodule MyApp.Native do
  def add(a, b) do
    MyApp.PythonPool.command(:operator, :add, [a, b])
  end
end
ivanhercaz

ivanhercaz

I will test it as soon as possible! :heart_eyes::heart_eyes:

I recommend you to link to the Doumi.Port repository and the Hex package in the post. It will be easier for the people to check them :smiling_face_with_three_hearts:.

Where Next?

Popular in Announcing Top

danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 29603 241
New
deadtrickster
I’ve just released stable versions of my Prometheus Elixir libs: Elixir client [docs]; Ecto collector [docs]; Plugs instrumenter/Export...
New
OvermindDL1
I created a new library (rather I pulled out a couple files from my big project), it manages an operating system PID file for the BEAM. ...
New
pkrawat1
Presenting Aviacommerce, open source e-commerce platform in Elixir Aviacommerce is an open source e-commerce platform in Elixir. We at...
New
aditya7iyengar
Rummage.Ecto and Rummage.Phoenix provide ways to perform Searching, Sorting and Pagination over Ecto queries and Phoenix collections. Fo...
New
achempion
Hi, I would like to tell about my initiative to further maintain and develop Waffle project which is the fork of Arc library. The progre...
New
alisinabh
Hey everyone i’ve developed a library for Jalaali calendar for elixir which supports converting Gregorian dates to Jalaali and vice vers...
New
kevinlang
Hey all, We have made an Ecto3 Adapter for SQLite3, ecto_sqlite3! We have successfully on-boarded the full suite of integration tests (...
New
wfgilman
I’ve cleaned up and open sourced three financial libraries I was using for my company. They are bindings for the APIs of these three comp...
New
trisolaran
Hi! :waving_hand: I would like to present LiveSelect, a little library that I wrote to easily add a dynamic selection input to your LV f...
198 10954 107
New

Other popular topics Top

mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement