Created
June 25, 2018 17:44
-
-
Save kassane/815e1e34a2d01ff5f13e994a5c421561 to your computer and use it in GitHub Desktop.
buiding boost.python3 extension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from os import system | |
from sys import argv | |
def Compile(arg): | |
#{arg:2} => remove directory ex: C:\ ou ./ | |
arg = arg.replace('.cpp','') #remove extension file | |
print('Compiling source code to object code:') | |
system(f'g++ -std=gnu++2a -c -fPIC {arg:2}.cpp -I /usr/include/python3.6m/') | |
print('Liking object code to machine code [Dynamic library]:|') | |
system(f'gcc -shared {arg:2}.o -L /usr/lib/python3.6/ -lboost_system -lboost_python3 -lpython3.6m -o {arg:2}.so') | |
system(f'rm {arg}.o') | |
if __name__ == '__main__': | |
print('============== Compile Boost.Python3 ================') | |
Compile(argv[1]) | |
print('Done!\nExecute Python for test.') | |
print(53*'=') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment