+++ /dev/null
-%have_python3 1
-
-# commented out legacy macro definitions
-#py3_prefix /usr
-#py3_incdir /usr/include/python3.5m
-#py3_ver 3.5
-
-# these should now be provided by macros.python_all
-#python3_sitearch /usr/lib64/python3.5/site-packages
-#python3_sitelib /usr/lib/python3.5/site-packages
-#python3_version 3.5
-
-# hard to say if anyone ever used these?
-#py3_soflags cpython-35m-x86_64-linux-gnu
-#py3_abiflags m
-%cpython3_soabi %(python3 -c "import sysconfig; print(sysconfig.get_config_var('SOABI'))")
-%py3_soflags %cpython3_soabi
-
-# compilation macros that might be in use somewhere
-%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\
-}
--- /dev/null
+#!/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 = {
+ "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))
Source5: python3start
Source6: python3.sh
Source7: python3.csh
-Source8: macros.python3
+Source8: macros.python3.py
Source9: import_failed.py
Source10: import_failed.map
# RPM macros
mkdir -p %{buildroot}%{_sysconfdir}/rpm
-install -m 644 %{SOURCE8} %{buildroot}%{_sysconfdir}/rpm # macros.python3
+LD_LIBRARY_PATH=. ./python %{S:8} > $RPM_BUILD_ROOT/etc/rpm/macros.python3 # macros.python3.py
# import_failed hooks
FAILDIR=%{buildroot}/%{sitedir}/_import_failed