Am 19.06.21 um 11:56 schrieb Michael Ströder:
HI!
I'm trying to update the Flask/Werkzeug stack.
Werkzeug now uses dataclasses which is not part of Python 3.6. I already found python36-dataclasses.
But now I wonder what's the official way to specify Python-version-specific (build) dependencies?
https://en.opensuse.org/openSUSE:Packaging_Python#BuildRequires If you need a package under certain conditions, useRPM boolean dependencies <https://rpm.org/user_doc/boolean_dependencies.html>. For projects inheriting their project configuration from openSUSE:Factory or devel:languages:python:backports, you can reference the Python version of the expanded flavor itself by using the pseudo|%python|macro (don't define|%python|anywhere else): BuildRequires: %{python_module aiocontextvars >= 0.2.2 if %python-base < 3.7} #### Until gh#openSUSE/python-rpm-macros#112 is merged and accepted into Factory, RPM boolean dependencies do not work for runtime dependencies of generated python flavor subpackages. Use this instead: https://en.opensuse.org/openSUSE:Packaging_Python#Conditionals_on_Python_ver... If you need to differentiate between python versions you can use the|%python_version_nodots|macro, which expands to the Python major and minor version of the currently auto-generated flavor package, with the dot removed. For example: %if %python_version_nodots < 39 Requires: python-importlib_resources %endif #### SLE/Leap has python3-dataclasses, TW python36-dataclasses. (which also automatically made it into d:l:p:backports, but it's useless there) So: BuildRequires: %{python_module dataclasses if %python-base < 3.7} %if %python_version_nodots < 37 Requires: python-dataclasses %endif The longer version for SLE/Leap targets without a recent python-rpm-macros (boo#1187473): %if 0%{?suse_version} >= 1550 # python36 only, be sure to remove it when python36 flavor is disabled. BuildRequires: python36-dataclasses %else # python2 (if not skipped) and python3 BuildRequires: %{python_module dataclasses} %endif %if %python_version_nodots < 37 Requires: python-dataclasses %endif
(IMO it was a huge mistake to stick Python 3.6 in Leap. Even old Debian buster has 3.7.)
Agreed.
Ciao, Michael.
Ben