LD_LIBRARY_PATH and Python and Paiza.io problem or run mruby on paiza.io and communicate http2

background

Paiza.io can access the network and handle files.

That means you can run libtrusterd via Python's ctypes!

trouble

As expected, wget-like things could be easily implemented in Python.

context = ssl.create_default_context()
conn = http.client.HTTPSConnection(host, 443, context=context)
conn.request('GET',path)
res = conn.getresponse()
f = open(libname, "wb")
f.write(res.read())
f.close()

Even https is easy ™

libevent is not on paiza.io!

Well, it's OK if you bring this as well as libtrusterd.so.

But it doesn't work.

@Phi, famous for tmlib.js, wrote a Python article I knew it for the first time at this time, but thanks to this article Successfully added the intended path to LD_LIBRARY_PATH.

os.environ["LD_LIBRARY_PATH"] = os.environ.get("LD_LIBRARY_PATH") + ":."

But it still doesn't work. ..

Then, you should raise the process again.

It seems that dlopen only looks at the environment variables when the process is started.

To make matters worse, paiza.io does not output any results at least when the process is restarted! Maybe there is a way to work with child processes, but lack of python experience Therefore, the code I wrote is NG. If the standard output of the child process is absorbed by the parent process I feel like I can go.

Remember the man of dlopen

You can open the shared library as many times as you like, but it will not actually load after the second time. I feel like there was a description, which means that I remember the opened library.

Call the shared library that is said to be missing in advance with ctypes.CDLL, I ran libtrusterd.

dummy = ctypes.CDLL("./libevent-2.0.so.5")
dummy = ctypes.CDLL("./libevent_core-2.0.so.5")
dummy = ctypes.CDLL("./libevent_openssl-2.0.so.5")

Great success

Summary

--LD_LIBRARY_PATH is already late at dlopen even if it is rewritten in the code --In a situation where a child process or a process cannot be restarted, it is OK to dlopen a shared library that does not have a path.

Related article

-Introduction to node-ffi with Go and applying it using Electron -Calling the library made with Go from mruby on Windows and displaying the webcam image at the command prompt -How to write Cargo build.rs when using Go library with Rust

Recommended Posts

LD_LIBRARY_PATH and Python and Paiza.io problem or run mruby on paiza.io and communicate http2
Run mruby with Python or Blender
Install and run Python3.5 + NumPy + SciPy on Windows 10
Run pip install on MacOS Python 3.7 or later
Run Openpose on Python (Windows)
Python on Ruby and angry Ruby on Python
Run Tensorflow 2.x on Python 3.7
Run Python CGI on CORESERVER
Run unix command on python
Python bitwise operator and OR
Python or and and operator trap
How to install OpenCV on Cloud9 and run it in Python
Communicate with FX-5204PS with Python and PyUSB
Python 3.6 on Windows ... and to Xamarin.
Install and run dropbox on Ubuntu 20.04
Integrate Modelica and Python on Windows
Run Python on Schedule on AWS Lambda
Run TensorFlow Docker Image on Python3
[Python] return A [or / and] B
Periodically run Python on Heroku Scheduler
Install Python3 and Django on Amazon Linux (EC2) and run your web server