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.

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:.

nallwhy

nallwhy

Oh, I forgot it. Thanks!!

kokolegorille

kokolegorille

Nice, I might use it soon too…

I use poolboy with erlport, but I see You use nimble_pool instead :slight_smile:

Where Next?

Popular in Libraries Top

scohen
Lexical Lexical is a next-generation language server for the Elixir programming language. Features Context aware code completion As-you...
New
hpopp
After just over two years in development, this latest version of Pigeon is what I finally consider done in regards to my original vision ...
New
mathieuprog
Hello :wave: Allow me to introduce you to Tz, an alternative time zone database support to Tzdata. Why another library? First and fore...
New
sasajuric
I’d like to announce a small library called boundaries. This is an experimental project which explores the idea of enforcing boundaries ...
New
tmbb
I’ve published the first version of my Makeup library. It’s a syntax highlighter for Elixir in the spirit of Pygments, Currently it highl...
New
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 27727 240
New
josevalim
Yes, yet another parser combinator library! Most of the parser combinators in the ecosystem are either compile-time, often using AST tra...
159 18262 141
New
mischov
import Meeseeks.CSS html = HTTPoison.get!("https://news.ycombinator.com/").body for story <- Meeseeks.all(html, css("tr.athing")) do...
New
wojtekmach
Hey everyone! Req is an HTTP client for Elixir that I’ve been working on for quite some time. There is already a lot of HTTP clients out...
New
mplatts
With HEEX released we decided to start a components library using Tailwind CSS - check it out here: Petal Components. We also have a boi...
New

Other popular topics Top

peerreynders
Manning 2016 Halloween weekend sale via Deal of the Day Friday, October 28 - Half off all MEAPs - code WM102816LT Saturday, October 29 ...
326 29600 154
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
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
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35421 110
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 42633 214
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
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
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

Sub Categories:

We're in Beta

About us Mission Statement