[opensuse-packaging] No %if inside %with?
Hi, For the package python-termstyle[0] I want to deactivate the tests because of problems with the default encoding which I can't solve. The requirement of the project maintainers is to not comment them out but change the `%bcond_without tests` to `%bcond_with tests`. But now I have a problem inside %check, which looks like this: %if %{with tests} %check export LANG=C.UTF-8 %ifpython2 python2 setup.py test -s test2 %endif %ifpython3 python3 setup.py test -s test3 %endif %endif With `%bcond_without tests`, rpm does not complain (the checks fail, but we know that already), but when I use `%bcond_with tests` I get: [ 52s] error: /home/abuild/rpmbuild/SOURCES/python-termstyle.spec:72: Got a %endif with no %if Where lne 72 is the last %endif in that section. If I comment out both %ifpythons, then it works. Does someone maybe has a clue why this is happening? Sebastian [0]: https://build.opensuse.org/package/show/home:sebix:branches:devel:languages:... -- python programming - mail server - photo - video - https://sebix.at cryptographic key at https://sebix.at/DC9B463B.asc and on public keyservers
On dimanche, 10 décembre 2017 17.58:43 h CET Sebastian wrote:
Hi,
For the package python-termstyle[0] I want to deactivate the tests because of problems with the default encoding which I can't solve. The requirement of the project maintainers is to not comment them out but change the `%bcond_without tests` to `%bcond_with tests`. But now I have a problem inside %check, which looks like this:
%if %{with tests} %check export LANG=C.UTF-8 %ifpython2 python2 setup.py test -s test2 %endif %ifpython3 python3 setup.py test -s test3 %endif %endif
With `%bcond_without tests`, rpm does not complain (the checks fail, but we know that already), but when I use `%bcond_with tests` I get:
[ 52s] error: /home/abuild/rpmbuild/SOURCES/python-termstyle.spec:72: Got a %endif with no %if Where lne 72 is the last %endif in that section. If I comment out both %ifpythons, then it works.
Does someone maybe has a clue why this is happening?
Sebastian
[0]: https://build.opensuse.org/package/show/home:sebix:branches:devel:languages :python/python-termstyle
If i remember I've been hit by this perhaps using %python3_only %python2_only it could work ? I've been almost pretty sure this kind of writing would have work %check # A full language is needed to make test successful # C.UTF-8 used normally on obs is not enough %{python_expand #Try to build lang export LANG=en_US.UTF-8 $python setup.py test -s test$(echo "%{py_ver}" | cut -d "." -f1) } But I didn't get it right. Tried patch against your package are temporaly here http://susepaste.org/40610078 -- Bruno Friedmann Ioda-Net Sàrl www.ioda-net.ch Bareos Partner, openSUSE Member, fsfe fellowship GPG KEY : D5C9B751C4653227 irc: tigerfoot -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
On 12/10/2017 09:30 PM, Bruno Friedmann wrote:
If i remember I've been hit by this perhaps using %python3_only %python2_only it could work ? Isn't that the shorthand for the same feature but in %files? I get these errors then: [ 9s] Unknown option s in python2_only() [ 9s] Unknown option s in python3_only()
I've been almost pretty sure this kind of writing would have work %check # A full language is needed to make test successful # C.UTF-8 used normally on obs is not enough %{python_expand #Try to build lang export LANG=en_US.UTF-8 $python setup.py test -s test$(echo "%{py_ver}" | cut -d "." -f1) } Using en_US.UTF-8 does not work too. I tried that already several times, but in a `osc chroot` session it does.
Moving `%if %{with tests}` inside the %check as pointed out off-list, does not help too. Sebastian -- python programming - mail server - photo - video - https://sebix.at cryptographic key at https://sebix.at/DC9B463B.asc and on public keyservers
On Dez 10 2017, Sebastian
%if %{with tests} %check export LANG=C.UTF-8 %ifpython2 python2 setup.py test -s test2 %endif %ifpython3 python3 setup.py test -s test3 %endif %endif
Are both %ifpython2 and %ifpython3 defined macros? If either is undefined then the rpm parser will not see the %if that is presumably supposed to be hidden behind that. Andreas. -- Andreas Schwab, SUSE Labs, schwab@suse.de GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different." -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
On Mon, Dec 11, 2017 at 6:41 AM, Andreas Schwab
On Dez 10 2017, Sebastian
wrote: %if %{with tests} %check export LANG=C.UTF-8 %ifpython2 python2 setup.py test -s test2 %endif %ifpython3 python3 setup.py test -s test3 %endif %endif
Are both %ifpython2 and %ifpython3 defined macros? If either is undefined then the rpm parser will not see the %if that is presumably supposed to be hidden behind that.
I actually elect to use the following construct instead: %if "%{python_flavor}" == "python2" .. %endif %if "%{python_flavor}" == "python3" .. %endif The rpm spec parser doesn't barf then... -- 真実はいつも一つ!/ Always, there's only one truth! -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
On 12/11/2017 12:41 PM, Andreas Schwab wrote:
Are both %ifpython2 and %ifpython3 defined macros? If either is undefined then the rpm parser will not see the %if that is presumably supposed to be hidden behind that. Yes. In `osc chroot`:
abuild@host:~> rpmspec -E "%ifpython2" %if "python2" == "python2" abuild@host:~> rpmspec -E "%ifpython3" %if "python2" == "python3" Sebastian
On 10.12.2017 17:58, Sebastian wrote:
Hi,
For the package python-termstyle[0] I want to deactivate the tests because of problems with the default encoding which I can't solve. The requirement of the project maintainers is to not comment them out but change the `%bcond_without tests` to `%bcond_with tests`. But now I have a problem inside %check, which looks like this:
%if %{with tests} %check export LANG=C.UTF-8 %ifpython2 python2 setup.py test -s test2 %endif %ifpython3 python3 setup.py test -s test3 %endif %endif
%ifpython2 / %ifpython3 don't work like this, in the first place. what you want is instead: %if 0%{?have_python2} / have_python3 difference being: %ifpython2/3 applies to parts that are different between subpackages. That is: %package, %description, %files, %pre, %post etc. it does nothing for parts that are *common*: %prep, %build, %install, %check that is because %ifpython2 is a rewrite-time check: "should this part of the spec go into a python2 subpackage"? whereas %have_python2 is asking "is a python2 present in the environment?" (*) In addition, %ifpython2/3 can't be nested within other ifs, due to the way RPM parses it. That is what Neal said, for nested conditions you need to use the longer form, "%if %python_flavor". (*) Which is not even the right question to ask, it should be "is python2 in the build set?". There is currently no good way to ask that. I've been working on it but I don't have a good solution yet. Also it would be nice if there was a way to do both without the "two spellings" confusion. I'm not convinced that it is possible though, without even worse magic that is already used.
With `%bcond_without tests`, rpm does not complain (the checks fail, but we know that already), but when I use `%bcond_with tests` I get:
[ 52s] error: /home/abuild/rpmbuild/SOURCES/python-termstyle.spec:72: Got a %endif with no %if Where lne 72 is the last %endif in that section. If I comment out both %ifpythons, then it works.
Does someone maybe has a clue why this is happening?
Sebastian
[0]: https://build.opensuse.org/package/show/home:sebix:branches:devel:languages:...
participants (5)
-
Andreas Schwab
-
Bruno Friedmann
-
jan matejek
-
Neal Gompa
-
Sebastian