From: DongHun Kwak Date: Fri, 19 Jan 2018 02:35:07 +0000 (+0900) Subject: Fix macro.python script X-Git-Tag: submit/tizen_base/20180119.025108^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a21fd2b9f067ffd87d0fa773723470c6c5f56832;p=platform%2Fupstream%2Fpython3.git Fix macro.python script [Model] All [BinType] AP [Customer] OPEN [Issue#] N/A [Request] N/A [Occurrence Version] N/A [Problem] missing python3_sitelib macro [Cause & Measure] macro policy is changed at python 3.6 i fix spec file for using old python macro policy [Checking Method] [Team] Open Source Management and Setting Part [Developer] dh0128.kwak [Solution company] Samsung [Change Type] N/A Change-Id: Ibb249a709c261bed9ce6bc35adedb73ffcd38990 Signed-off-by: DongHun Kwak --- diff --git a/packaging/macros.python3 b/packaging/macros.python3 deleted file mode 100644 index 651ebfc6..00000000 --- a/packaging/macros.python3 +++ /dev/null @@ -1,26 +0,0 @@ -%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\ -} diff --git a/packaging/macros.python3.py b/packaging/macros.python3.py new file mode 100644 index 00000000..f137456d --- /dev/null +++ b/packaging/macros.python3.py @@ -0,0 +1,33 @@ +#!/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)) diff --git a/packaging/python3-base.spec b/packaging/python3-base.spec index 1034bfbd..95e104f5 100644 --- a/packaging/python3-base.spec +++ b/packaging/python3-base.spec @@ -84,7 +84,7 @@ Source3: baselibs.conf Source5: python3start Source6: python3.sh Source7: python3.csh -Source8: macros.python3 +Source8: macros.python3.py Source9: import_failed.py Source10: import_failed.map @@ -406,7 +406,7 @@ install -m 644 %{SOURCE6} %{SOURCE7} %{buildroot}%{_sysconfdir}/profile.d # pyth # 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