Created
June 7, 2022 20:35
-
-
Save nmilosev/2f0090c4f86637f04ac83cbfe835f8bc to your computer and use it in GitHub Desktop.
ONNX recipe draft
This file contains hidden or 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.path import join | |
import os | |
import sh | |
class OnnxRecipe(PythonRecipe): | |
version = 'v1.11.0' | |
url = 'git://github.com/onnx/onnx' | |
depends = ['protobuf_cpp', 'pybind11', 'setuptools'] | |
site_packages_name = 'onnx' | |
call_hostpython_via_targetpython = False | |
def get_recipe_env(self, arch): | |
env = super().get_recipe_env(arch) | |
# Adding pointer to protobuf | |
protobuf_recipe = self.get_recipe('protobuf_cpp', self.ctx) | |
env['CMAKE_ARGS'] = " -DProtobuf_LIBRARIES=" + join(protobuf_recipe.get_build_dir(arch.arch), "src", ".libs", "libprotobuf.so") | |
env['CMAKE_ARGS'] += "-DONNX_USE_PROTOBUF_SHARED_LIBS=ON -DONNX_USE_LITE_PROTO=OFF " | |
# Taken from gevent recipe to fix "undefined reference to `[something]@LIBC'" | |
# CFLAGS may only be used to specify C compiler flags, for macro definitions use CPPFLAGS | |
regex = re.compile(r'(?:\s|^)-[DI][\S]+') | |
env['CPPFLAGS'] = ''.join(re.findall(regex, env['CFLAGS'])).strip() | |
env['CFLAGS'] = re.sub(regex, '', env['CFLAGS']) | |
info('Moved "{}" from CFLAGS to CPPFLAGS.'.format(env['CPPFLAGS'])) | |
# LDFLAGS may only be used to specify linker flags, for libraries use LIBS | |
regex = re.compile(r'(?:\s|^)-l[\w\.]+') | |
env['LIBS'] = ''.join(re.findall(regex, env['LDFLAGS'])).strip() | |
env['LIBS'] += ' {}'.format(''.join(re.findall(regex, env['LDLIBS'])).strip()) | |
env['LDFLAGS'] = re.sub(regex, '', env['LDFLAGS']) | |
info('Moved "{}" from LDFLAGS to LIBS.'.format(env['LIBS'])) | |
return env | |
recipe = OnnxRecipe() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment