I am trying to deploy a Python server to Heroku, and I need to execute a "g++" command on one of the libraries to install it on the server.
I want to create a gunicorn and Flask server hosting facebook's XLM model from cross-lingual model pretaining : https://github.com/facebookresearch/XLM
The model requires the "fastBPE" library (https://github.com/glample/fastBPE), which requires to be installed with the command : g++ -std=c++11 -pthread -O3 fastBPE/main.cc -IfastBPE -o fast
However, since the Heroku server is configured for Python, it doesn't recognize the "g++" command.
Here is what I tried so far : - adding the buildpack “heroku-buildpack-apt” in Heroku and creating an "Aptfile" in my source file, to write "g++" inside of it, as well as "build-essential" - inside the main python file, I create a subprocess to launch "apt-get install g++" :
import subprocess
process = subprocess.Popen("apt-get install g++", shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
(output, err) = process.communicate()
#This makes the wait possible
p_status = process.wait()
#This gives the output of the command being executed
print("Command apt-get output: ",output)
However, whenever I run the following subprocess to install the fastBPE package :
import subprocess
process = subprocess.Popen("g++ -std=c++11 -pthread -O3 tools/fastBPE/fastBPE/main.cc -IfastBPE -o tools/fastBPE/fast", shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
(output, err) = process.communicate()
p_status = process.wait()
print("Command apt-get output: ",output)
I systematically get "g++: not found" as output.
Also, the command "which g++" returns nothing, but "which gcc" returns "/usr/bin/gcc", so gcc is installed but not g++
Aptfileapproach is likely the place to start here. - Chris