Fix macro.python script 40/167640/1
authorDongHun Kwak <dh0128.kwak@samsung.com>
Fri, 19 Jan 2018 02:35:07 +0000 (11:35 +0900)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Fri, 19 Jan 2018 02:35:07 +0000 (11:35 +0900)
[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 <dh0128.kwak@samsung.com>
packaging/macros.python3 [deleted file]
packaging/macros.python3.py [new file with mode: 0644]
packaging/python3-base.spec

diff --git a/packaging/macros.python3 b/packaging/macros.python3
deleted file mode 100644 (file)
index 651ebfc..0000000
+++ /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 (file)
index 0000000..f137456
--- /dev/null
@@ -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))
index 1034bfbd2dd6f5af0ec75d31420ef0b7ab5b2c67..95e104f55e6504a014e99719b8d15f1859b22cf0 100644 (file)
@@ -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