File macros.python3.py of Package python3

#!/usr/bin/python3

""" generate macros.python3 file from known values """

import sys,os
from sysconfig import get_path, get_config_var

version = "{}.{}".format(*sys.version_info)
abiflags = get_config_var("ABIFLAGS")

macros = {
    "have_python3":     "1",
    "py3_ver":          version,
    "python3_version":  version,
    "py3_prefix":       sys.prefix,
# hack-fix for bnc#787526 - get_path can't be used this way in python build dir
#    "py3_incdir":       get_path("include"),
    "py3_incdir":       "/usr/include/python" + version + abiflags,
    "py3_abiflags":     abiflags,
    "py3_soflags":      get_config_var("SOABI"),
    "python3_sitelib":  get_path("purelib"),
    "python3_sitearch": get_path("platlib"),
    "py3_compile(O)": """
find %1 -name '*.pyc' -exec rm -f {} ";"
python3 -c "import sys, os, compileall; br='%{buildroot}'; compileall.compile_dir(sys.argv[1], ddir=br and (sys.argv[1][len(os.path.abspath(br)):]+'/') or None)" %1
%{-O:
find %1 -name '*.pyo' -exec rm -f {} ";"
python3 -O -c "import sys, os, compileall; br='%{buildroot}'; compileall.compile_dir(sys.argv[1], ddir=br and (sys.argv[1][len(os.path.abspath(br)):]+'/') or None)" %1
}""",
}

for (macro,definition) in macros.items():
    definition = "\\\n".join(definition.split("\n"))
    print( "%{} {}".format(macro, definition))
openSUSE Build Service is sponsored by