Commit 6699ab4d authored by Ophélie Gagnard's avatar Ophélie Gagnard

WIP: Add a mechanism to replace the shebang of parse_link_errors.py when the...

WIP: Add a mechanism to replace the shebang of parse_link_errors.py when the main Makefile is called with $PYTHON_PATH defined.
Warning: this is a quick but dirty fix and it should be made more standard asap!
parent d7c4f3a9
ifeq ($(PREFIX),)
PREFIX := /usr
endif
ifneq ($(PYTHON_PATH),)
DUMB = $(shell sed "s|%PYTHON_PATH%|$(PYTHON_PATH)/bin/python3|g" installation/metadata-collect-agent/parse_link_errors.py.in > installation/metadata-collect-agent/parse_link_errors.py)
endif
all: no-dracut
install: install-no-dracut
......@@ -48,7 +51,12 @@ clean-no-dracut-local:
rm -rf build/
rm -rf bin/
rm -rf lib/
sed "s|%PYTHON_PATH%|#!/usr/bin/env python3|g" installation/metadata-collect-agent/parse_link_errors.py.in > installation/metadata-collect-agent/parse_link_errors.py
echo $(DUMB)
clean-no-dracut: uninstall-no-dracut clean-no-dracut-local
.PHONY: no-dracut install-no-dracut uninstall-no-dracut clean-no-dracut all install clean
dev:
echo $(DUMB)
.PHONY: no-dracut install-no-dracut uninstall-no-dracut clean-no-dracut all install clean dev
#INCLUDE_PYTHON=-I$(shell python3 -c "import sysconfig; print(sysconfig.get_path('include'))")
ifeq ($(INCLUDE_PYTHON),)
ifneq ($(PYTHON_PATH),) # this is for buildouts
#INCLUDE_PYTHON=-I$(shell python3 -c "import sysconfig; print(sysconfig.get_path('include'))")
INCLUDE_PYTHON=-I$(shell $(PYTHON_PATH)/bin/python3 -c "from sysconfig import get_paths; print(get_paths()['include'])")
endif
PYTHON_PATH = /usr/bin/python3
ifeq ($(INCLUDE_PYTHON),) # default behavior to get python includes path
# INCLUDE_PYTHON = $(shell pkg-config --cflags python3 | cut -f 1 -d " ")
INCLUDE_PYTHON=-I$(shell python3 -c "import sysconfig; print(sysconfig.get_path('include'))")
endif
endif
ifneq ($(FMTLIB_PATH),)
INCLUDE_FMTLIB = -I$(FMTLIB_PATH)/include
......
%PYTHON_PATH%
import sys
import re
def parse_input():
p = re.compile(r'undefined reference to `(.*(Py).*)\'')
functions_to_implement = set()
while True:
try:
m = p.search(input())
except EOFError:
break
if m != None:
functions_to_implement.update({m.group(1)})
return functions_to_implement
def produce_code(parsed_input, file_name='fake_python.c'):
f = open(file_name, "w")
for function in parsed_input:
f.write('void ' + function + '(){}\n')
f.close()
if __name__ == '__main__':
parsed_input = parse_input()
produce_code(parsed_input)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment