Confuse about build condition (%bcond_with/out)

Hello,

I am confuse about how to use %bcond

Lets say “A” depend on “B” for testing.
But B hard depend on A.

So therefore should the spec file of A be like this?


%bcond_with test
...
%if %{with test}
BuildRequires:  B
%endif

The reason I ask is because python repo maintainer suggest the correct way to do it is,


%bcond_without test
...
%if %{with test}
BuildRequires:  B
%endif

But this result in unsolvable (using %bcond_without ): https://build.opensuse.org/package/show/devel:languages:python/python-tifffile

The package using %bcond_with that I did which fix the unsolvable is here: https://build.opensuse.org/package/show/home:andythe_great/python-tifffile
Thanks.

%bcond_with defaults value to 0, %bcond_without defaults to 1. This is the only difference. It works in your case because it evaluates to 0 and so skips whatever requires you defined.

I see, so the plan is to skip requires with %bcond_with, then after other dependencies arrived change it to %bcond_without?

Was it question to me?

to skip requires with %bcond_with, then after other dependencies arrived change it to %bcond_without?

I suspect you misunderstand what %bcond macros do and how to use them, but as you neither describe what you are trying to achieve nor show any real code used to implement your requirement there is not much to say.

I have this python-tifffile package Show home:andythe_great / python-tifffile - openSUSE Build Service

python-tifffile depend on the following packages for testing only.

Requires:       python-cmapfile
Requires:       python-czifile
Requires:       python-imagecodecs
Requires:       python-lfdfiles
Requires:       python-oiffile
Requires:       python-roifile

However, those packages (czifile, imagecodecs, etc) depend on python-tifffile to be able to build.
So my understanding is that, I have to build python-tifffile without testing it (and without czifile, imagecodecs, etc).
Then proceed to build czifile, imagecodecs, etc which depend on tifffile.
After czifile, imagecodecs, etc build, I have to re-enable testing for tifffile.

What I think is to use %bcond_with tests (on tifffile spec file) to allow tifffile to build without test and its testing dependencies.
Then once the czifile, imagecodecs, etc builds, change it to %bcond_without tests to build tifffile with tests.

Does bcond allow me to do this?

I still do not understand what “for testing only” means. Do you mean %check section in spec file? This section is empty in your spec.

Yes, I meant %check section.
Testing need network connection, now that I think about it, since testing cannot be done on OBS anyway.
I will just remove


BuildRequires:  %{python_module cmapfile}
BuildRequires:  %{python_module czifile}
BuildRequires:  %{python_module imagecodecs}
BuildRequires:  %{python_module lfdfiles}
BuildRequires:  %{python_module oiffile}
BuildRequires:  %{python_module roifile} 

and %bcond
Leaving only,

Requires:       python-cmapfile
Requires:       python-czifile
Requires:       python-imagecodecs
Requires:       python-lfdfiles
Requires:       python-oiffile
Requires:       python-roifile

Would that be acceptable?

Hi,
To explain what’s going on. tifffile want imagecodecs, czifile, cmapfile, oiffile, lfdfiles, and roifile for testing. imagecodecs, czifile, cmapfile, oiffile, lfdfiles, and roifile depend on tifffile to build.

But the test for tifffile required network connection, therefore I disable the test.

I have removed imagecodecs, czifile, cmapfile, oiffile, lfdfiles, and roifile on BuildRequires: section of tifffile to allow tifffile itself to build first.

Since tifffile still need imagecodecs, czifile, cmapfile, oiffile, lfdfiles, and roifile for testing which can be done locally, I have put it into Requires: section only

Is this ok?

I found out that those deps are not necessary.
It build normally now.

closing