Oh! Thank you! This works.

On Thu, Sep 16, 2010 at 12:07 PM, Toshio Kuratomi <a.badger@gmail.com> wrote:
On Thu, Sep 16, 2010 at 10:03:21AM +0800, Robin Lee wrote:
> The main point I want to get is to set a proper python(abi) requirement at
> buildtime without using hard version number at all.
> %{?!py3_ver: %global py3_ver 3.2}
> Doing so of course will make the package built. But that uses a hard version
> number.
>
> I now suggest the requester to make a phantom file to get what we want.
> See this patch: https://bugzilla.redhat.com/attachment.cgi?id=447458&action=
> diff
>
I'm sorry I'm not being clear.  I thought that py3_ver was being set by the
python3 macros but I see now that you have to define that in the spec file.
I've added a more detailed comment in bugzilla, but the basic spec file code
to do this more simply is:

# get python3 version
%global py3_ver 0
%{?__python3: %global py3_ver %(%{__python3} -c "import sys; sys.stdout.write(sys.version[:3])")}

-Toshio

> Robin
>
> On Thu, Sep 16, 2010 at 12:17 AM, Toshio Kuratomi <a.badger@gmail.com> wrote:
>
>     On Wed, Sep 15, 2010 at 07:25:49PM +0800, Robin Lee wrote:
>     > For a more concrete example: https://bugzilla.redhat.com/show_bug.cgi?id=
>     567348
>     > I want to set the python(abi) requirement of the subpackage at buildtime.
>     So, I
>     > want to set it like this:
>     > Requires: python(abi) = %{py3_ver}
>     >
>     > But when build it, it will fail with the following output:
>     > $ rpmbuild -bp dreampie.spec
>     > Building target platforms: i686
>     > Building for target i686
>     > sh: python3: command not found
>     > sh: python3: command not found
>     > sh: python3: command not found
>     > error: line 46: Version required: Requires:   python(abi) =
>     >
>     > Even though python3-devel has been added as BR.
>     >
>     I think that where you're running into this problem is important.  It's
>     when
>     koji is constructing the srpm, isn't it?  at that stage, koji needs to
>     parse the spec file and it's running into the "Requires foo =\n" and
>     throwing that error.
>
>     I think that conditionally defining a py3_ver macro in the spec file will
>     do
>     what you wnat.  That way, when the package is actually built, the
>     python3-devel pakage will be present and your conditional will not set the
>     macro.  but when building the srpm and python3-devel is missing, it will.
>
>     Something like this:
>     %{?!py3_ver: %global py3_ver 3.2}
>
>     would work.  I'm not sure of the safest thing that we can use there and
>     still not run into problems when building the srpm.
>
>     -Toshio
>
>     > On Wed, Sep 15, 2010 at 7:06 PM, Ignacio Vazquez-Abrams <
>     ivazqueznet@gmail.com>
>     > wrote:
>     >
>     >     On Wed, 2010-09-15 at 18:22 +0800, Robin Lee wrote:
>     >     > python3 rpm macros not available without python3-devel installed.
>     >     > 'rpmbuild --viewrc' will show you.
>     >     >
>     >     > So if you use the python3 macros to define another macro and you
>     have
>     >     > no python3-devel installed, you must fail.
>     >     >
>     >     > So, how to define, for example, a %py3_ver macro for the major
>     version
>     >     > of Python3? Must yum be used?
>     >     >
>     >     > Robin
>     >
>     >     Adding a "BuildRequires: python3-devel" should be enough to pull them
>     >     in.
>     >
>     >     --
>     >     Ignacio Vazquez-Abrams <ivazqueznet@gmail.com>
>     >
>     >     _______________________________________________
>     >     python-devel mailing list
>     >     python-devel@lists.fedoraproject.org
>     >     https://admin.fedoraproject.org/mailman/listinfo/python-devel
>     >
>     >
>
>     > _______________________________________________
>     > python-devel mailing list
>     > python-devel@lists.fedoraproject.org
>     > https://admin.fedoraproject.org/mailman/listinfo/python-devel
>
>
>     _______________________________________________
>     python-devel mailing list
>     python-devel@lists.fedoraproject.org
>     https://admin.fedoraproject.org/mailman/listinfo/python-devel
>
>

> _______________________________________________
> python-devel mailing list
> python-devel@lists.fedoraproject.org
> https://admin.fedoraproject.org/mailman/listinfo/python-devel


_______________________________________________
python-devel mailing list
python-devel@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/python-devel