Overview

Request 1078338 superseded

Simplify spec file by dropping Python multi-spec and update-alternatives facilities, among other things.


Luciano Santos's avatar
author source maintainer

Using unless boolean dep wasn't the answer too. I went with:

BuildRequires:  (python39-tomli if python39-base)
BuildRequires:  (python310-tomli if python310-base)

And this is the last time I make this much change to a package at once. It's hard to review it. Better use iterations instead.


Luciano Santos's avatar
author source maintainer

Switching to Meson does more harm than good for us here. I'm gonna drop it.


Luciano Santos's avatar
author source maintainer

OK. I revised the changes I'm doing here and, as long as the package is named python-gi-docgen, it's best we keep the single-spec stuff (I misused the term multi-spec before).


Bjørn Lie's avatar

Are you sure about this: - Use tomli module buildtime/runtime requirement for Python older than 3.11. Otherwise, the tomllib module from the standard library is going to be used instead. I ask cause when looking at upstream code in meson.build, I'm starting to think that the changes are just wrong.

Please see

https://gitlab.gnome.org/GNOME/gi-docgen/-/blob/main/meson.build


Luciano Santos's avatar
author source maintainer

Yes, I am. All that meson.build and pyproject.toml are saying is that if the Python version is less than 3.11 it will fallback to tomli/toml (external modules):

  if tomli_version.version_compare('>=1.0')
    message('Falling back to toml on Python <3.11')
  else
    toml_version = run_command(
      py, '-c', 'import toml; print(toml.__version__)',
      check: false,
    ).stdout().strip()
    if toml_version.version_compare('>=0.10.2')
      warning('Falling back to deprecated toml module; please update to tomli')
    else
      error('tomli 1.0 or newer required on Python 3.10 and older')
    endif
  endif

That part of the code is nested inside the IF statement: if py.language_version().version_compare('<3.11'). So, if Python < 3.11 use the tomli module. And if tomli >= 1.0 (if tomli_version.version_compare('>=1.0')) use the deprecated toml module.

You can see that if py.language_version().version_compare('<3.11') has no else statements and that's because in Python 3.11 the tomllib module, that's provided by the standard library, is used instead. Thus there's no need to use additional requirements other than Python 3.11.


Dominique Leuenberger's avatar
+%if "%python_version" < "3.11"
+BuildRequires:  python3-tomli
+%endif

OBS won't see this - python_version is only known once the buildroot is setup


Luciano Santos's avatar
author source maintainer

Argh, that's true. %python_version is setup in macros.python_all. Is there an easy way to go about this?


Luciano Santos's avatar
author source maintainer

Maybe:

%define have_python311 %(command -v python3.11 >&/dev/null && python3.11 --version | awk '{print $2}')

Or just:

%define have_python311 %(command -v python3.11 >&/dev/null && echo 1)

Dominique Leuenberger's avatar

obs scheduler does not execute %()


Dominique Leuenberger's avatar

BuildRequires: ( python3-tomli if python311-base) ?


Luciano Santos's avatar
author source maintainer

Oh, boolean deps! Yes, they should work. But we want this instead, to install python3-tomli when python311-base is not present: BuldRequires: (python3-tomli unless python311-base).

It would be handy if boolean deps could support some from of globbing or versioning, though. Otherwise we're going to have: BuldRequires: (python3-tomli unless python311-base or python312-base [or ...]).


Luciano Santos's avatar
author source maintainer

Ah, unless we'd have a python3-base meta-package, versioning won't work (even though we can use version with boolean deps).

Note that ‘'’Provides’’’ are not dependencies and ‘'’cannot contain Boolean Expressions’’’.
Request History
Luciano Santos's avatar

luc14n0 created request

Simplify spec file by dropping Python multi-spec and update-alternatives facilities, among other things.


GNOME Review Bot's avatar

gnome-review-bot accepted review

Check script succeeded


GNOME Review Bot's avatar

gnome-review-bot approved review

Check script succeeded


Luciano Santos's avatar

luc14n0 superseded request

superseded by 1078831

openSUSE Build Service is sponsored by