Hello community, here is the log from the commit of package python-rpm-macros for openSUSE:Factory checked in at 2017-07-04 13:33:16 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-rpm-macros (Old) and /work/SRC/openSUSE:Factory/.python-rpm-macros.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "python-rpm-macros" Tue Jul 4 13:33:16 2017 rev:7 rq:506276 version:2017.06.21.6641889 Changes: -------- --- /work/SRC/openSUSE:Factory/python-rpm-macros/python-rpm-macros.changes 2017-05-20 10:08:08.438702390 +0200 +++ /work/SRC/openSUSE:Factory/.python-rpm-macros.new/python-rpm-macros.changes 2017-07-04 13:33:17.695286011 +0200 @@ -1,0 +2,10 @@ +Wed Jun 21 13:16:38 UTC 2017 - jmatejek@suse.com + +- version bump to 2017.06.21.6641889 +- introduce smarter buildset support +- fix %python_files on nonstandard build sets +- introduce %python_for_executables in favor of magically taking + "last python in %pythons" +- fix %licence tag handling (gh#opensuse/python-rpm-macros#4) + +------------------------------------------------------------------- Old: ---- python-rpm-macros-2017.05.09.fc237de.tar.bz2 New: ---- python-rpm-macros-2017.06.21.6641889.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-rpm-macros.spec ++++++ --- /var/tmp/diff_new_pack.1M7WS1/_old 2017-07-04 13:33:19.459037649 +0200 +++ /var/tmp/diff_new_pack.1M7WS1/_new 2017-07-04 13:33:19.463037086 +0200 @@ -17,7 +17,7 @@ Name: python-rpm-macros -Version: 2017.05.09.fc237de +Version: 2017.06.21.6641889 Release: 0 Summary: RPM macros for building of Python modules License: WTFPL @@ -29,9 +29,9 @@ # Fedora compatibility Provides: python2-rpm-macros Provides: python3-rpm-macros -BuildRoot: %{_tmppath}/%{name}-%{version}-build #!BuildIgnore: python-rpm-macros BuildArch: noarch +BuildRoot: %{_tmppath}/%{name}-%{version}-build %description This package contains SUSE RPM macros for Python build automation. ++++++ python-rpm-macros-2017.05.09.fc237de.tar.bz2 -> python-rpm-macros-2017.06.21.6641889.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-rpm-macros-2017.05.09.fc237de/.gitignore new/python-rpm-macros-2017.06.21.6641889/.gitignore --- old/python-rpm-macros-2017.05.09.fc237de/.gitignore 2017-05-09 16:09:03.000000000 +0200 +++ new/python-rpm-macros-2017.06.21.6641889/.gitignore 2017-06-21 15:16:14.000000000 +0200 @@ -1,5 +1,6 @@ /macros.python_all /macros/020-flavor-* /macros/035-default-pythons -/macros/040-automagic +/macros/040-buildset +/macros/050-automagic *.swp diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-rpm-macros-2017.05.09.fc237de/README.md new/python-rpm-macros-2017.06.21.6641889/README.md --- old/python-rpm-macros-2017.05.09.fc237de/README.md 2017-05-09 16:09:03.000000000 +0200 +++ new/python-rpm-macros-2017.06.21.6641889/README.md 2017-06-21 15:16:14.000000000 +0200 @@ -33,29 +33,62 @@ Alternately, it is to take package `python-%{modname}` and generate subpackages for all flavors, leaving the top-level package empty. +### Build set + +The default build set is listed in the __`%pythons`__ macro. Every entry in `%pythons` generates a +requirement in `%python_module`, a subpackage from `%python_subpackages` (unless the top-level spec +file is for that flavor), and an additional run of loops like `%python_build`, `_install`, `_exec` +and `_expand`. + +In order to control the build set, you can either completely redefine `%pythons`, or exclude +particular flavor(s) by defining __`%skip_$flavor`__. For example, if you `%define skip_python2 1`, +then Python 2 will be excluded from the default build set. + +Skip-macros are intended __for per-package use only__. Never define a skip-macro in prjconf or +in any other sort of global config. Instead, redefine `%pythons`. + ### Macros The following macros are considered public API: -__`%pythons`__ - list of flavors we are building for. +__`%system_python`__ - flavor that is used for generic unflavored `%python_` macros. +Currently set to `python2`. + +__`%python_for_executables`__ - flavor that is used for installing executables into `%_bindir` and +other files in non-flavor-specific locations. By default, set to `python3`. -__`%have_python2`, `%have_python3`, `%have_pypy3`__. Defined as 1 if we are building for that -flavor. Undefined otherwise. +__`%pythons`__ - the build set. See above for details. + +__`%have_python2`, `%have_python3`, `%have_pypy3`__. Defined as 1 if the flavor is present in the +build environment. Undefined otherwise. +_Note:_ "present in build environment" does not mean "part of build set". Under some circumstances, +you can get a python flavor pulled in through dependencies, even if you exclude it from the build +set. In such case, `%have_$flavor` will be defined but packages will not be generated for it. + +__`%skip_python2`, `%skip_python3`, `%skip_pypy3`__. Undefined by default. Define in order to exclude +a flavor from build set. __`%{python_module modname [= version]}`__ expands to `$flavor-modname [= version]` for every flavor. Intended as: `BuildRequires: %{python_module foo}`. +__`%python_flavor`__ expands to the `%pythons` entry that is currently being processed. +Does not apply in `%prep`, `%build`, `%install` and `%check` sections, except when evaluated +as `%{$python_flavor}` in `%python_expand`. + __`%ifpython2`, `%ifpython3`, `%ifpypy3`__: applies the following section only to subpackages of that particular flavor. __`%ifpycache`__: applies the following section only to subpackages of flavors that generate a -`__pycache__` directory. +`__pycache__` directory. +_Note:_ These are shortcuts for `%if "%python_flavor" == "$flavor"`. Due to how RPM evaluates the +shortcuts, they will fail when nested with other `%if` conditions. If you need to nest your +conditions, use the full `%if %python_flavor` spelling. __`%python2_only`, `%python3_only`, `%pypy3_only`__: applies the contents of the line only to subpackages of that particular flavor. __`%pycache_only`__: applies the contents of the line only to subpackages of flavors that generate `__pycache__` directories. Useful in filelists: `%pycache_only %{python_sitelib}/__pycache__/*` -__`%python_build`__ expands to build instructions for all flavors. +__`%python_build`__ expands to build instructions for all flavors. __`%python_install`__ expands to install instructions for all flavors. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-rpm-macros-2017.05.09.fc237de/buildset.in new/python-rpm-macros-2017.06.21.6641889/buildset.in --- old/python-rpm-macros-2017.05.09.fc237de/buildset.in 1970-01-01 01:00:00.000000000 +0100 +++ new/python-rpm-macros-2017.06.21.6641889/buildset.in 2017-06-21 15:16:14.000000000 +0200 @@ -0,0 +1,9 @@ + +# This method for generating python_modules gets too deep to expand at about 5 python flavors. +# It is replaced by a Lua macro in macros.lua +# However, OBS has a much higher expansion depth, so this works fine. +%python_module_iter(a:) %{-a*}-%{args} %{expand:%%{?!python_module_iter_%1:%%{python_module_iter -a %*}}} +%python_module_iter_STOP stop +%python_module() %{expand:%%define args %{**}} %{expand:%%{python_module_iter -a %{pythons} STOP}} + +%add_python() %{expand:%%define pythons %pythons %1} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-rpm-macros-2017.05.09.fc237de/compile-macros.sh new/python-rpm-macros-2017.06.21.6641889/compile-macros.sh --- old/python-rpm-macros-2017.05.09.fc237de/compile-macros.sh 2017-05-09 16:09:03.000000000 +0200 +++ new/python-rpm-macros-2017.06.21.6641889/compile-macros.sh 2017-06-21 15:16:14.000000000 +0200 @@ -2,12 +2,27 @@ FLAVORS="python2 python3 pypy3" -# generate flavors from flavor.in +# order of BUILDSET is important, it is copied to order of %pythons, +# and that determines the last installed binary +BUILDSET="python2 python3" + + +### flavor-specific: generate from flavor.in for flavor in $FLAVORS; do sed 's/#FLAVOR#/'$flavor'/g' flavor.in > macros/020-flavor-$flavor done -# generate automagic from macros.in and macros.lua + +### buildset: generate %pythons, %skip_python? and %python_modules +pythons="" +for flavor in $BUILDSET; do + pythons="${pythons} %{?!skip_$flavor:$flavor}" +done +echo "%pythons $pythons" > macros/040-buildset +cat buildset.in >> macros/040-buildset + + +### Lua: generate automagic from macros.in and macros.lua ( # copy macros.in up to LUA-MACROS sed -n -e '1,/^### LUA-MACROS ###$/p' macros.in @@ -45,9 +60,8 @@ # copy rest of macros.in sed -n -e '/^### LUA-MACROS ###$/,$p' macros.in -) > macros/040-automagic +) > macros/050-automagic -# perl embed-macros.pl macros.in macros.lua > macros/040-automagic.orig -# cat macros/*, but with files separated by additional newlines +### final step: cat macros/*, but with files separated by additional newlines sed -e '$s/$/\n/' -s macros/* > macros.python_all diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-rpm-macros-2017.05.09.fc237de/macros/010-common-defs new/python-rpm-macros-2017.06.21.6641889/macros/010-common-defs --- old/python-rpm-macros-2017.05.09.fc237de/macros/010-common-defs 2017-05-09 16:09:03.000000000 +0200 +++ new/python-rpm-macros-2017.06.21.6641889/macros/010-common-defs 2017-06-21 15:16:14.000000000 +0200 @@ -1,4 +1,5 @@ %system_python python2 +%python_for_executables python3 ##### common functionality ##### diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-rpm-macros-2017.05.09.fc237de/macros.in new/python-rpm-macros-2017.06.21.6641889/macros.in --- old/python-rpm-macros-2017.05.09.fc237de/macros.in 2017-05-09 16:09:03.000000000 +0200 +++ new/python-rpm-macros-2017.06.21.6641889/macros.in 2017-06-21 15:16:14.000000000 +0200 @@ -1,8 +1,3 @@ -# order is important! if builds install the same binary, the last one is preferred -%pythons %{?have_python2:python2} %{?have_pypy3:pypy3} %{?have_python3:python3} - -%python_module() %{expand: %{?have_python2:%{python2_prefix}-%{**}} %{?have_python3:python3-%{**}} %{?have_pypy3:pypy3-%{**}}} - %python_flavor %{_python_macro_init}%{lua: print(flavor)} %if_python_kind() %if "%{python_flavor}" == "%1" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-rpm-macros-2017.05.09.fc237de/macros.lua new/python-rpm-macros-2017.06.21.6641889/macros.lua --- old/python-rpm-macros-2017.05.09.fc237de/macros.lua 2017-05-09 16:09:03.000000000 +0200 +++ new/python-rpm-macros-2017.06.21.6641889/macros.lua 2017-06-21 15:16:14.000000000 +0200 @@ -1,8 +1,18 @@ function _python_scan_spec() + local last_python = rpm.expand("%python_for_executables") + local insert_last_python = false + pythons = {} + -- make sure that last_python is the last item in the list for str in string.gmatch(rpm.expand("%pythons"), "%S+") do - table.insert(pythons, str) + if str == last_python then + insert_last_python = true + else + table.insert(pythons, str) + end end + -- ...but check that it is actually in the buildset + if insert_last_python then table.insert(pythons, last_python) end modname = rpm.expand("%name") local spec_name_prefix = "python" @@ -76,6 +86,14 @@ local function ignore_line(line) end + local function files_line(line) + -- unexpand %license at start of line + if line:startswith("%license") then + line = "%" .. line + end + return print_altered(line) + end + local PROPERTY_COPY_UNMODIFIED = lookup_table { "Summary:", "Version:", "BuildArch:" } local PROPERTY_COPY_MODIFIED = lookup_table { "Requires:", "Provides:", @@ -327,6 +345,8 @@ print(section_headline(newsection, current_flavor, param)) if should_expect_alternatives(newsection, param) then section_function = expect_alternatives + elseif newsection == "files" then + section_function = files_line else section_function = print_altered end @@ -405,11 +425,7 @@ local param = "" if tonumber(nparams) > 0 then param = rpm.expand("%1") end - if _python_subpackages_emitted and is_called_python and not old_python2 then - print("-n " .. package_name(flavor, modname, param)) - else - print(param) - end + print("-n " .. package_name(flavor, modname, param)) if not _python_subpackages_emitted then print("\n/%python_subpackages_macro_not_present\n") @@ -438,3 +454,16 @@ print(rpm.expand(string.format("%%{prepare_alternative -t %s %s}\n", link, name))) end end + +function python_module() + rpm.expand("%_python_macro_init") + local params = rpm.expand("%**") + for _, python in ipairs(pythons) do + if python == "python2" then + print(rpm.expand("%python2_prefix") .. "-" .. params) + else + print(python .. "-" .. params) + end + print(" ") + end +end