Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-rpm-macros for openSUSE:Factory checked in at 2021-01-15 19:42:56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-rpm-macros (Old) and /work/SRC/openSUSE:Factory/.python-rpm-macros.new.28504 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-rpm-macros" Fri Jan 15 19:42:56 2021 rev:33 rq:862532 version:20210112.86f4d9d Changes: -------- --- /work/SRC/openSUSE:Factory/python-rpm-macros/python-rpm-macros.changes 2020-08-28 21:17:58.968225809 +0200 +++ /work/SRC/openSUSE:Factory/.python-rpm-macros.new.28504/python-rpm-macros.changes 2021-01-15 19:42:57.349714070 +0100 @@ -1,0 +2,128 @@ +Tue Jan 12 07:18:43 UTC 2021 - mc...@cepl.eu + +- Update to version 20210112.86f4d9d: + * fix gh#openSUSE/python-rpm-macros#84: python_sysconfig_ macros + +------------------------------------------------------------------- +Mon Dec 07 17:09:23 UTC 2020 - mc...@cepl.eu + +- Update to version 20201207.2177fcf: + * README update after merge + +------------------------------------------------------------------- +Mon Dec 07 16:31:52 UTC 2020 - mc...@cepl.eu + +- Update to version 20201207.259cdda: + * Update python_expand description in README + * python_expand to basename only + +------------------------------------------------------------------- +Fri Dec 04 09:47:39 UTC 2020 - mc...@cepl.eu + +- Update to version 20201204.32a910e: + * fix print_provided_flavor again + +------------------------------------------------------------------- +Thu Dec 03 07:08:14 UTC 2020 - mc...@cepl.eu + +- Update to version 20201203.5331183: + * fix print_provided_flavor + +------------------------------------------------------------------- +Sat Nov 28 22:11:52 UTC 2020 - mc...@cepl.eu + +- Update to version 20201128.669edb3: + * fix provides (for python-numpy f2py, in gh#openSUSE/python-rpm-macros#66) + +------------------------------------------------------------------- +Mon Nov 23 14:41:05 UTC 2020 - mc...@cepl.eu + +- Update to version 20201123.6978323: + * also rewrite subpackage_only default providers + * pytest: ignore _build dirs for all flavors + +------------------------------------------------------------------- +Thu Nov 19 07:53:17 UTC 2020 - mc...@cepl.eu + +- Update to version 20201119.6bb5f69: + * add default provider properties + * don't replace %name, for subpackage_only + * expand parameters for subpackage_only packages + +------------------------------------------------------------------- +Thu Nov 12 18:19:15 UTC 2020 - mc...@cepl.eu + +- Update to version 20201112.a4c80dc: + * handle python_subpackage_only, fixes gh#openSUSE/python-rpm-macros#73 + * define default providers for pythonX from pythonXY flavors: fixes #69 + +------------------------------------------------------------------- +Tue Nov 03 20:59:11 UTC 2020 - mc...@cepl.eu + +- Update to version 20201103.cec67c2: + * document python_find_lang + * add python_find_lang and allow to specify in %python_files. Fixes #5 + +------------------------------------------------------------------- +Mon Nov 02 18:34:58 UTC 2020 - mc...@cepl.eu + +- Update to version 20201102.31ccfc2: + * fix python_clone shebang replacement + * one less expansion for python_exec + * expand default %python_ macros earlier + * update README for multiple flavors + * more command delimiters for %python_expand + +------------------------------------------------------------------- +Thu Oct 22 18:47:52 UTC 2020 - mc...@cepl.eu + +- Update to version 20201022.7f87908: + * Add python36 and python38 flavours. + +------------------------------------------------------------------- +Wed Oct 21 11:22:16 UTC 2020 - mc...@cepl.eu + +- Update to version 20201021.adb6953: + * Prepare for multiple python3 flavors +- Remove multiple_flavors.patch as it is included in the upstream + tarball. + +------------------------------------------------------------------- +Fri Oct 16 20:05:52 UTC 2020 - mc...@cepl.eu + +- Update to version 20201016.5d22545: + * fix whitespace after escape in compileall macro + +------------------------------------------------------------------- +Fri Oct 16 14:31:59 UTC 2020 - mc...@cepl.eu + +- Update to version 20201016.db09189: + * Delete pycache files before compilealll + * Update macros/010-common-defs + * Reword compileall + * mention pyproject.toml and link to PEP517 and PEP518 + * add description for pyunittest macro + * add description for python_compileall macro + * add description for pyproject macros + * add python_compileall macro and use it in pyproject_install + * disable pip version check: no connection to pypi.org + +------------------------------------------------------------------- +Tue Sep 22 19:29:03 UTC 2020 - Matej Cepl <mc...@suse.com> + +- Update multiple_flavors.patch to generate correct names of the + python binary. + +------------------------------------------------------------------- +Wed Sep 9 18:00:03 UTC 2020 - Matej Cepl <mc...@suse.com> + +- %__#FLAVOR# should be defined as + /usr/bin/python%{#FLAVOR#_version} not just /usr/bin/#FLAVOR# + +------------------------------------------------------------------- +Wed Sep 2 11:44:33 UTC 2020 - Matej Cepl <mc...@suse.com> + +- Add patch multiple_flavors.patch which makes compile_macros.sh + generate alternative flavours as well. + +------------------------------------------------------------------- Old: ---- python-rpm-macros-20200824.8fa42a7.tar.xz New: ---- python-rpm-macros-20210112.86f4d9d.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-rpm-macros.spec ++++++ --- /var/tmp/diff_new_pack.b2ilpi/_old 2021-01-15 19:42:57.961715072 +0100 +++ /var/tmp/diff_new_pack.b2ilpi/_new 2021-01-15 19:42:57.965715079 +0100 @@ -1,7 +1,7 @@ # # spec file for package python-rpm-macros # -# Copyright (c) 2020 SUSE LLC +# Copyright (c) 2021 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,17 +17,17 @@ Name: python-rpm-macros -Version: 20200824.8fa42a7 +Version: 20210112.86f4d9d Release: 0 Summary: RPM macros for building of Python modules License: WTFPL URL: https://github.com/opensuse/python-rpm-macros Source: python-rpm-macros-%{version}.tar.xz +# To keep user expectations reasonably sane +Recommends: python-rpm-generators # Fedora compatibility Provides: python2-rpm-macros Provides: python3-rpm-macros -# To keep user expectations reasonably sane -Recommends: python-rpm-generators BuildArch: noarch %description @@ -38,18 +38,17 @@ %package -n python-rpm-generators Summary: Dependency generator dependencies for Python RPMs Requires: %{name} = %{version}-%{release} -# Fedora compatibility -Provides: python3-rpm-generators # For the dep generator macros Requires: python3-setuptools +# Fedora compatibility +Provides: python3-rpm-generators %description -n python-rpm-generators This package contains the dependencies for Python RPMs to generate dependencies automatically. %prep -%setup -q -%autopatch -p1 +%autosetup %if 0%{?suse_version} < 1330 mv macros-default-pythons macros/035-default-pythons ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.b2ilpi/_old 2021-01-15 19:42:58.033715190 +0100 +++ /var/tmp/diff_new_pack.b2ilpi/_new 2021-01-15 19:42:58.033715190 +0100 @@ -1,4 +1,4 @@ <servicedata> <service name="tar_scm"> <param name="url">git://github.com/openSUSE/python-rpm-macros.git</param> - <param name="changesrevision">13628e66c3f31b07ef4a4227a1b45e766350f94c</param></service></servicedata> \ No newline at end of file + <param name="changesrevision">16d3497aadc60ea99a1e28894b8d9bd073ac3e29</param></service></servicedata> \ No newline at end of file ++++++ python-rpm-macros-20200824.8fa42a7.tar.xz -> python-rpm-macros-20210112.86f4d9d.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-rpm-macros-20200824.8fa42a7/README.md new/python-rpm-macros-20210112.86f4d9d/README.md --- old/python-rpm-macros-20200824.8fa42a7/README.md 2020-08-24 10:07:22.000000000 +0200 +++ new/python-rpm-macros-20210112.86f4d9d/README.md 2021-01-12 08:17:34.000000000 +0100 @@ -9,36 +9,48 @@ ### Terminology -__flavor__ is a kind of python interpreter. At this point, we recognize the following flavors: -`python2`, `python3` and `pypy3`. +__``<flavor>``__ is a kind of python interpreter. At this point, we recognize the following flavors: +`python2`, `python3`, `python36`, `python38` and `pypy3`. `python3` points to the default of +coinstallable flavors `python3<M>` where `<M>` is the minor version number. + +The flavor is used as a prefix for all flavor-specific macros. +Some macros are redefined with "short" flavor for compatibility +reasons, such as `py3` for `python3`. All of them have a "long" form too. For compatibility reasons you see sometimes `python`. In most places, using `python` is either a redefinition of `python2`, or an alternative for "flavor-agnostic". Conditionals are in place to switch `python` to mean `python3` in the future. -The name of the flavor is the name of the binary in `/usr/bin`. It is also used as a prefix -for all flavor-specific macros. Some macros are redefined with "short" flavor for compatibility -reasons, such as `py2` for `python2`. All of them have a "long" form too. +The name of the binary in `%_bindir` (`/usr/bin`) is the name of the flavor with an addtional `.` +between the major and minor version number, in case the latter is part of the flavor name: + +- `/usr/bin/python2` +- `/usr/bin/python3` +- `/usr/bin/python3.8` +- ... __modname__ is the PyPI name, or, if the package in question is not on PyPI, the moniker that we chose to stand in for it. -Packages adhering to the SUSE Python module naming policy are usually called `%{flavor}-%{modname}`. -In some cases, it is only `%{modname}` though. +Packages adhering to the SUSE Python module naming policy are usually called `<flavor>-modname`. +In some cases, it is only `modname` though. -__pkgname__, or __subpackage name__, is internal to a spec file, and is that thing you put after the -`%package` macro. Pkgname of the package itself is an empty string. Pkgname of a `%package -n -something` is at this point `-n something`, and denotes that this subpackage should not be handled -by the generator. -That means, if you want a subpackage to be skipped, rename it from `%package foo` to -`%package -n %{name}-foo`. +__pkgname__, or __subpackage name__, is internal to a spec file, and is that thing you put after +the `%package` macro. Pkgname of the package itself is an empty string. Pkgname of a +`%package -n something` is at this point `-n something`, and denotes that this subpackage should +not be handled by the generator. That means, if you want a subpackage to be skipped, rename it +from `%package foo` to `%package -n %{name}-foo`. -The purpose of the singlespec system is to take a package called `%{flavor}-%{modname}` for a +The purpose of the singlespec system is to take a package called `<flavor>-modname` for a particular flavor, and autogenerate subpackages for all the other flavors. -Alternately, it is to take package `python-%{modname}` and generate subpackages for all flavors, +Alternately, it is to take package `python-modname` and generate subpackages for all flavors, leaving the top-level package empty. +Additionally it is possible for non-Python packages which define a subpackage +`%package -n python-modname` and corresponding `%description -n python-modname` etc., +to autogenerate all desired flavor subpackages `<flavor>-modname`. + ### Build Set The default build set is listed in the __`%pythons`__ macro. Every entry in `%pythons` generates a @@ -47,7 +59,7 @@ and `_expand`. To control the build set, you can either completely redefine `%pythons`, or exclude -particular flavor(s) by defining __`%skip_$flavor`__. For example, if you `%define skip_python2 1`, +particular flavor(s) by defining __`%skip_<flavor>`__. For example, if you `%define skip_python2 1`, then Python 2 will be excluded from the default build set. Skip-macros are intended __for per-package use only__. Never define a skip-macro in prjconf or @@ -65,16 +77,20 @@ * __`%pythons`__ - the build set. See above for details. -* __`%have_python2`, `%have_python3`, `%have_pypy3`__. Defined as 1 if the flavor is present in the -build environment. Undefined otherwise. -_Note:_ "present in build environment" does not mean "part of build set". Under some circumstances, -you can get a Python flavor pulled in through dependencies, even if you exclude it from the build -set. In such case, `%have_$flavor` will be defined but packages will not be generated for it. +* __`%have_<flavor`__. Defined as 1 if the flavor is present in the build environment. + Undefined otherwise. + + _Note:_ "present in build environment" does not mean "part of build set". Under some + circumstances, you can get a Python flavor pulled in through dependencies, even if you exclude it + from the build set. In such case, `%have_<flavor>` will be defined but packages will not be + generated for it. -* __`%skip_python2`, `%skip_python3`, `%skip_pypy3`__. Undefined by default. Define in order to exclude -a flavor from build set. +* __`%skip_<flavor>`__. Undefined by default. Define in order to exclude a flavor from build set. -* __`%{python_module modname [= version]}`__ expands to `$flavor-modname [= version]` for every + _Note:_ You do not need to define `%skip_python2` for Tumbleweed. Only define, if you need to skip it + for older distributions. + +* __`%{python_module modname [= version]}`__ expands to `<flavor>-modname [= version]` for every flavor. Intended as: `BuildRequires: %{python_module foo}`. * __`%{python_dist_name modname}`__. Given a standardized name (i.e. dist name, name on PyPI) of `modname`, @@ -89,45 +105,108 @@ when listing dependencies. Intended as `(Build)Requires: %{python3_dist foo}`. * __`%python_flavor`__ expands to the `%pythons` entry that is currently being processed. -Does not apply in `%prep`, `%build`, `%install` and `%check` sections, except when evaluated -as `%{$python_flavor}` in `%python_expand`. +Does not apply in `%prep`, `%build`, `%install` and `%check` sections. For those, check for the +expansion of `$python_` inside the `%python_expand` macro (see below). -* __`%ifpython2`, `%ifpython3`, `%ifpypy3`__: applies the following section only to subpackages of -that particular flavor. -__`%ifpycache`__: applies the following section only to subpackages of flavors that generate a -`__pycache__` directory. -_Note:_ These are shortcuts for `%if "%python_flavor" == "$flavor"`. Due to how RPM evaluates the +* __`%python_subpackages`__ expands to the autogenerated subpackages. This should go at the end of the +main headers section. + +* __`%python_subpackage_only`__. Undefined by default. If you want to generate `<flavor>-modname` +subpackages for a non-python main package, make sure to `%define python_subpackage_only 1` before +`%python_subpackages` and use `-n python-modname` for section headers (except for `%files`, see below). + +* __`%python_enable_dependency_generator`__ expands to a define to enable automatic requires generation +of Python module dependencies using egg-info/dist-info metadata. This should go above the +`%python_subpackages` macro, preferably closer to the top of the spec. Intended usage: +`%{?python_enable_dependency_generator}`. This macro will eventually be removed when the generator +is configured to automatically run, hence the `?` at the beginning of the macro invocation. + + +#### Conditionals + +These are shortcuts for `%if "%python_flavor" == "<flavor>"`. Due to how RPM evaluates the shortcuts, they will fail when nested with other `%if` conditions. If you need to nest your -conditions, use the full `%if %python_flavor` spelling. +conditions, use the full `%if "%python_flavor"` spelling. + +* __`%if<flavor>`__: applies the following section only to subpackages of that particular flavor. + +* __`%ifpycache`__: applies the following section only to subpackages of flavors that generate a +`__pycache__` directory. + +* __`%<flavor>_only`__: applies the contents of the line only to subpackages of that particular flavor. -* __`%python2_only`, `%python3_only`, `%pypy3_only`__: applies the contents of the line only to -subpackages of that particular flavor. * __`%pycache_only`__: applies the contents of the line only to subpackages of flavors that generate `__pycache__` directories. Useful in filelists: `%pycache_only %{python_sitelib}/__pycache__/*` -* __`%python_build`__ expands to build instructions for all flavors. -* __`%python_install`__ expands to install instructions for all flavors. +#### Flavor expansion -* __`%python_exec something.py`__ expands to `$flavor something.py` for all flavors, and moves around -the distutils-generated `build` directory so that you are never running `python2` script with a -python3-generated `build`. This is only useful for distutils/setuptools. - -* __`%python_expand something`__ is a more general form of the above. Performs the moving-around for -distutils' `build` directory, and performs rpm macro expansion of its argument for every flavor. -Importantly, `$python` is replaced by current flavor name, even in macros. So: -`%{python_expand $python generatefile.py %$python_bin_suffix}` -expands to: -`python2 generatefile.py %python2_bin_suffix` -`python3 generatefile.py %python3_bin_suffix` -etc. +The following macros expand to command lists for all flavors and move around the distutils-generated +`build` directory so that you are never running a `python2` command with a python3-generated `build` +and vice versa. -* __`%pytest`__ runs `pytest` in all flavors with appropriate environmental variables -(namely, it sets `$PYTHONPATH` to ``%{python_sitelib}``). All paramteres to this macro are -passed without change to the pytest command. Explicit `BuildRequires` on `%{python_module pytest}` -is still required. +##### General command expansion macros + +* __`%python_exec something.py`__ expands to `$python something.py` for all flavors, where `$python` +is the basename of the flavor executable. Make sure it is in `$PATH`. + +* __`%python_expand something`__ is a more general form of the above. It performs rpm macro expansion + of its arguments for every flavor. Importantly, `$python` is not expanded by the shell, but replaced + beforehand for the current flavor, even in macros: + + - When used as command delimited by space or one of `"'\)&|;<>`, it is replaced by the path to the executable + - When used as part of a macro name or other string, it is replaced by the current flavor name. + + So: + `%{python_expand $python generatefile.py %{$python_bin_suffix}}` + expands to: + + ``` + python2 generatefile.py 2.7 + python3.6 generatefile.py 3.6 + python3.8 generatefile.py 3.8 + ``` + + etc. (plus the moving around of the `build` directory in between). + + If you want to check for the current python flavor inside `%python_expand` use something like + + ```spec + %{python_expand # + if [ $python_ = python36_ ]; then + $python command-for-py-36-only (we have %{$python_version}) + fi + } + ``` + + which expands to + + ```sh + # + if [ python38_ = python36_ ]; then + python3.8 command-for-py-36-only (we have 3.8) + fi + ``` + + and so on for all flavors. + +##### Install macros + +* __`%python_build`__ expands to distutils/setuptools build instructions for all flavors. -* __`%pytest_arch`__ the same as the above, except it sets ``$PYTHONPATH`` to ``%{$python_sitearch}`` +* __`%python_install`__ expands to distutils/setuptools install instructions for all flavors. + +* __`%pyproject_wheel`__ expands to +[PEP517](https://www.python.org/dev/peps/pep-0517)/[PEP518](https://www.python.org/dev/peps/pep-0518/) +build instructions for all flavors and creates wheels. This is useful if the package has a +``pyproject.toml`` file but no ``setup.py`` + +* __`%pyproject_install`__ expands to install instructions for all flavors to install the created wheels. + +* __`%python_compileall`__ precompiles all python source files in `%{python_sitelib}` and `%{python_sitearch}` +for all flavors. Generally Python 2 creates the cached byte-code `.pyc` files directly in the script directories, while +newer flavors generate `__pycache__` directories. Use this if you have modified the source files in `%buildroot` after +`%python_install` or `%pyproject_install` has compiled the files the first time. * __`%python_clone filename`__ creates a copy of `filename` under a flavor-specific name for every flavor. This is useful for packages that install unversioned executables: `/usr/bin/foo` is copied @@ -135,22 +214,25 @@ __`%python_clone -a filename`__ will also invoke __`%prepare_alternative`__ with the appropriate arguments. -* __`%python2_build`, `%python3_build`, `%pypy3_build`__ expands to build instructions for the -particular flavor. +* __`%python_find_lang foo`__ calls `%find_lang foo` for all flavors and creates flavor specific + files `%{python_prefix}-foo.lang`. Additional arguments of `%find_lang` are supported. The filelist + can then be used as `%files %{python_files} -f %{python_prefix}-foo.lang` in the `%files` section header. -* __`%python2_install`, `%python3_install`, `%pypy3_install`__ expands to install -instructions for the particular flavor. -* __`%python_subpackages`__ expands to the autogenerated subpackages. This should go at the end of the -main headers section. +##### Unit testing -* __`%python_enable_dependency_generator`__ expands to a define to enable automatic requires generation -of Python module dependencies using egg-info/dist-info metadata. This should go above the -`%python_subpackages` macro, preferably closer to the top of the spec. Intended usage: -`%{?python_enable_dependency_generator}`. This macro will eventually be removed when the generator -is configured to automatically run, hence the `?` at the beginning of the macro invocation. +* __`%pytest`__ runs `pytest` in all flavors with appropriate environmental variables +(namely, it sets `$PYTHONPATH` to ``%{$python_sitelib}``). All paramteres to this macro are +passed without change to the pytest command. Explicit `BuildRequires` on `%{python_module pytest}` +is still required. + +* __`%pytest_arch`__ the same as the above, except it sets ``$PYTHONPATH`` to ``%{$python_sitearch}``. -Alternative-related, general: +* __`%pyunittest`__ and __`%pyunittest_arch`__ run `$python -m unittest` on all flavors with +appropriate environmental variables very similar to `%pytest` and `%pytest_arch`. + + +#### Alternative-related, general: * __`%prepare_alternative [-t <targetfile> ] <name>`__ replaces `<targetfile>` with a symlink to `/etc/alternatives/<name>`, plus related housekeeping. If no `<targetfile>` is given, it is @@ -167,7 +249,8 @@ * __`%alternative_to <file>`__ generates a filelist entry for `<file>` and a ghost entry for `basename <file>` in `/etc/alternatives` -Alternative-related, for Python: + +#### Alternative-related, for Python: * __`%python_alternative <file>`__: expands to filelist entries for `<file>`, its symlink in `/etc/alternatives`, and the target file called `<file>-%python_bin_suffix`. @@ -187,33 +270,53 @@ Each of these has a flavor-specific spelling: `%python2_alternative` etc. + +#### Flavor-specific macros + In addition, the following flavor-specific macros are known and supported by the configuration: -* __`%__python2`__: path to the $flavor executable. -This exists mostly for Fedora compatibility. In SUSE code, it is preferable to use `$flavor` -directly, as it is specified to be the name in `/usr/bin`, and we don't support multiple competing -binaries (in the OBS environment at least). +* __`%__<flavor>`__: path to the ``<flavor>`` executable. + +* __`%<flavor>_build`__ expands to build instructions for the particular flavor. + +* __`%<flavor>_install`__ expands to install instructions for the particular flavor. -* __`%python2_sitelib`, `%python2_sitearch`__: path to noarch and arch-dependent `site-packages` +* __`%<flavor>_sitelib`, `%<flavor>_sitearch`__: path to noarch and arch-dependent `site-packages` directory. -* __`%python2_version`__: dotted major.minor version. `2.7` for CPython 2.7. +* __`%<flavor>_version`__: dotted major.minor version. `2.7` for CPython 2.7. -* __`%python2_version_nodots`__: concatenated major.minor version. `27` for CPython 2.7. +* __`%<flavor>_version_nodots`__: concatenated major.minor version. `27` for CPython 2.7. -* __`%python2_bin_suffix`, `%python3_bin_suffix`, `%pypy3_bin_suffix`__: what to put after +* __`%<flavor>_bin_suffix`__: what to put after a binary name. Binaries for CPython are called `binary-%{python_version}`, for PyPy the name is `binary-pp%{pypy3_version}` -* __`%python2_prefix`__: prefix of the package name. `python` for old-style distros, `python2` for +* __`%<flavor>_prefix`__: prefix of the package name. `python` for old-style distros, `python2` for new-style. For other flavors, the value is the same as flavor name. - For reasons of preferred-flavor-agnosticity, aliases `python_*` are available for all of these. +For reasons of preferred-flavor-agnosticity, aliases `python_*` are available for all of these. - We recognize `%py_ver`, `%py2_ver` and `%py3_ver` as deprecated spellings of `%flavor_version`. No +We recognize `%py_ver`, `%py2_ver` and `%py3_ver` as deprecated spellings of `%<flavor>_version`. No such shortcut is in place for `pypy3`. Furthermore, `%py2_build`, `_install` and `_shbang_opts`, as well as `py3` variants, are recognized for Fedora compatibility. +### `%files` section + +* __`%files %{python_files}`__ expands the `%files` section for all generated flavor packages of + `<flavor>-modname`. + +* __`%files %{python_files foo}`__ expands the `%files` section for all generated flavor subpackages + of `<flavor>-modname-foo`. + +For subpackages of non-python packages with `%python_subpackage_only`and + `%package -n %{python_flavor}-modname`, also use `%files %{python_files modname}`. + +Always use the flavor-agnostic macro versions `%python_*` inside `%python_files` marked `%files` sections. + +See also the Filelists section of the +[openSUSE:Packaging Python](https://en.opensuse.org/openSUSE:Packaging_Python#Filelists) +guidelines ### Files in Repository @@ -229,13 +332,16 @@ * __`macros/030-fallbacks`__: compatibility and deprecated spellings for some macros. -* __`compile-macros.sh`__: the compile script. Builds flavor-specific macros, Lua script definition, -and concatenates all of it into `macros.python_all`. - * __`apply-macros.sh`__: compile macros and run `rpmspec` against first argument. Useful for examining what is going on with your spec file. -* __`flavor.in`__: template for flavor-specific macros. Generates `macros/020-flavor-$flavor` for +* __`buildset.in`__: template to generate `macros/040-buildset` for the `%pythons`, `%skip_<flavor>` and + `%python_module` macros. + +* __`compile-macros.sh`__: the compile script. Builds flavor-specific macros, Lua script definition, +and concatenates all of it into `macros.python_all`. + +* __`flavor.in`__: template for flavor-specific macros. Generates `macros/020-flavor-<flavor>` for every flavor listed in `compile-macros.sh`. * __`functions.lua`__: Lua function definitions used in `macros.lua` and elsewhere. In the compile @@ -254,12 +360,4 @@ where this is not provided by your Python installation. The spec file uses this for SUSE <= Leap 42.3. `apply-macros` also uses it implicitly (for now). -* __`embed-macros.pl`__: takes care of slash-escaping and wrapping the Lua functions and inserting -them into the `macros.in` file in order to generate the resulting macros. - -* __`python-rpm-macros.spec`__: spec file for the `python-rpm-macros` package generated from this -GitHub repository. - -* __`process-spec.pl`__: Simple regexp-based converter into the singlespec format. - * __`README.md`__: This file. As if you didn't know. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-rpm-macros-20200824.8fa42a7/compile-macros.sh new/python-rpm-macros-20210112.86f4d9d/compile-macros.sh --- old/python-rpm-macros-20200824.8fa42a7/compile-macros.sh 2020-08-24 10:07:22.000000000 +0200 +++ new/python-rpm-macros-20210112.86f4d9d/compile-macros.sh 2021-01-12 08:17:34.000000000 +0100 @@ -1,15 +1,19 @@ #!/bin/bash -FLAVORS="python2 python3 pypy3" +FLAVORS="python2 python3 python36 python38 pypy3" # order of BUILDSET is important, it is copied to order of %pythons, # and that determines the last installed binary -BUILDSET="python2 python3" +BUILDSET="python2 python3 python36 python38" ### flavor-specific: generate from flavor.in for flavor in $FLAVORS; do sed 's/#FLAVOR#/'$flavor'/g' flavor.in > macros/020-flavor-$flavor + if [ "$flavor" = "python2" ]; then + # special old-style package provides and obsoletes for python2 + echo "%${flavor}_provides python" >> macros/020-flavor-$flavor + fi done diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-rpm-macros-20200824.8fa42a7/flavor.in new/python-rpm-macros-20210112.86f4d9d/flavor.in --- old/python-rpm-macros-20200824.8fa42a7/flavor.in 2020-08-24 10:07:22.000000000 +0200 +++ new/python-rpm-macros-20210112.86f4d9d/flavor.in 2021-01-12 08:17:34.000000000 +0100 @@ -1,17 +1,29 @@ ##### macro definitions for flavor "#FLAVOR#" ##### -%__#FLAVOR# /usr/bin/#FLAVOR# - %#FLAVOR#_shbang_opts %py_shbang_opts -%#FLAVOR#_prefix #FLAVOR# -%#FLAVOR#_sitelib %{_python_sysconfig_path #FLAVOR# purelib} -%#FLAVOR#_sitearch %{_python_sysconfig_path #FLAVOR# platlib} -%#FLAVOR#_version %{_python_sysconfig_var #FLAVOR# py_version_short} -%#FLAVOR#_version_nodots %{_python_sysconfig_var #FLAVOR# py_version_nodot} +%__#FLAVOR# %{_bindir}/%{lua: print((string.gsub("#FLAVOR#", "(%w+%d)(%d)", "%1.%2")))} -%#FLAVOR#_sysconfig_path() %{_rec_macro_helper}%{lua:call_sysconfig("path", "#FLAVOR#")} -%#FLAVOR#_sysconfig_var() %{_rec_macro_helper}%{lua:call_sysconfig("var", "#FLAVOR#")} +%#FLAVOR#_prefix #FLAVOR# +%#FLAVOR#_sitelib %{_python_sysconfig_path %__#FLAVOR# purelib} +%#FLAVOR#_sitearch %{_python_sysconfig_path %__#FLAVOR# platlib} +%#FLAVOR#_version %{_python_sysconfig_var %__#FLAVOR# py_version_short} +%#FLAVOR#_version_nodots %{_python_sysconfig_var %__#FLAVOR# py_version_nodot} + +%#FLAVOR#_sysconfig_path() %{_python_sysconfig_path %__#FLAVOR# %1} +%#FLAVOR#_sysconfig_var() %{_python_sysconfig_var %__#FLAVOR# %1} + +%#FLAVOR#_bin_suffix %{?!_#FLAVOR#_bin_suffix:%#FLAVOR#_version}%{?_#FLAVOR#_bin_suffix} + +# Check if there is a major version symlink to our flavor in the current build system. If so, we are the primary provider. +%#FLAVOR#_provides %(provides=""; \ +for flavorbin in %{_bindir}/python?; do \ + if [ $flavorbin != %__#FLAVOR# -a $(realpath $flavorbin) = %__#FLAVOR# ]; then \ + provides+=" $(basename $flavorbin)"; \ + fi; \ +done; \ +echo ${provides# }; \ +) %if#FLAVOR# %if "%{python_flavor}" == "#FLAVOR#" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-rpm-macros-20200824.8fa42a7/functions.lua new/python-rpm-macros-20210112.86f4d9d/functions.lua --- old/python-rpm-macros-20200824.8fa42a7/functions.lua 2020-08-24 10:07:22.000000000 +0200 +++ new/python-rpm-macros-20210112.86f4d9d/functions.lua 2021-01-12 08:17:34.000000000 +0100 @@ -34,7 +34,7 @@ function replace_macros(str, targetflavor) local LONG_MACROS = { "sitelib", "sitearch", "alternative", "install_alternative", "uninstall_alternative", - "version", "version_nodots", "bin_suffix", "prefix"} + "version", "version_nodots", "bin_suffix", "prefix", "provides"} local SHORT_MACROS = { "ver" } for _, srcflavor in ipairs({flavor, "python"}) do str = str:gsub("%%__" .. srcflavor, "%%__" .. targetflavor) @@ -64,7 +64,7 @@ name = name .. "-" .. subpkg end if append and append ~= "" then - name = name .. " " .. append + name = name .. " " .. replace_macros(append, flavor) end return name end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-rpm-macros-20200824.8fa42a7/macros/010-common-defs new/python-rpm-macros-20210112.86f4d9d/macros/010-common-defs --- old/python-rpm-macros-20200824.8fa42a7/macros/010-common-defs 2020-08-24 10:07:22.000000000 +0200 +++ new/python-rpm-macros-20210112.86f4d9d/macros/010-common-defs 2021-01-12 08:17:34.000000000 +0100 @@ -9,13 +9,9 @@ %_rec_macro_helper %{lua: rpm.define("_rec_macro_helper %{nil}") function expand_macro(name, args) - local interp = rpm.expand("%python_flavor") + local pflavor = rpm.expand("%python_flavor") local args = args and rpm.expand(args) or "" - print(rpm.expand("%{" .. interp .. "_" .. name .. " " .. args .."}")) - end - function call_sysconfig(which, interp) - local arg = rpm.expand("%1") - print(rpm.expand("%{_python_sysconfig_" .. which .. " " .. interp .. " " .. arg .. "}")) + print(rpm.expand("%{" .. pflavor .. "_" .. name .. " " .. args .."}")) end } @@ -24,24 +20,25 @@ %py_setup setup.py %py_shbang_opts -s -##### binary suffixes for flavors ##### +##### non-standard binary suffixes for flavors ##### + +%_pypy3_bin_suffix pp%{pypy3_version} -%python2_bin_suffix %python2_version -%python3_bin_suffix %python3_version -%pypy3_bin_suffix pp%{pypy3_version} ##### preferred configuration ##### -%python_sitelib %{_python_sysconfig_path %python_flavor purelib} -%python_sitearch %{_python_sysconfig_path %python_flavor platlib} -%python_version %{_python_sysconfig_var %python_flavor py_version_short} -%python_version_nodots %{_python_sysconfig_var %python_flavor py_version_nodot} +%python_sitelib %{_python_sysconfig_path %{expand:%__%{python_flavor}} purelib} +%python_sitearch %{_python_sysconfig_path %{expand:%__%{python_flavor}} platlib} +%python_version %{_python_sysconfig_var %{expand:%__%{python_flavor}} py_version_short} +%python_version_nodots %{_python_sysconfig_var %{expand:%__%{python_flavor}} py_version_nodot} + +%python_sysconfig_path() %{_python_sysconfig_path %{expand:%__%{python_flavor}} %1} +%python_sysconfig_var() %{_python_sysconfig_var %{expand:%__%{python_flavor}} %1} %python_prefix %{_rec_macro_helper}%{lua:expand_macro("prefix")} %python_bin_suffix %{_rec_macro_helper}%{lua:expand_macro("bin_suffix")} +%python_provides %{_rec_macro_helper}%{lua:expand_macro("provides")} -%python_sysconfig_path() %{_rec_macro_helper}%{lua:call_sysconfig("path", "%python_flavor")} -%python_sysconfig_var() %{_rec_macro_helper}%{lua:call_sysconfig("var", "%python_flavor")} %python_alternative() %{_rec_macro_helper}%{lua:expand_macro("alternative", "%**")} %python_install_alternative() %{_rec_macro_helper}%{lua:expand_macro("install_alternative", "%**")} @@ -129,7 +126,8 @@ local args = rpm.expand("%**"); \ local broot = rpm.expand("%buildroot"); \ local intro = "%{python_expand PYTHONPATH=${PYTHONPATH:+$PYTHONPATH:}" .. broot .. "%{$python_sitelib} PYTHONDONTWRITEBYTECODE=1 "; \ - intro = intro .. "pytest-%{$python_bin_suffix} --ignore=_build.python2 --ignore=_build.python3 --ignore=_build.pypy3 -v "; \ + local ignore_build = "--ignore=_build." .. rpm.expand("%pythons"):gsub("%s+", " --ignore=_build."); \ + intro = intro .. "pytest-%{$python_bin_suffix} " .. ignore_build .. " -v "; \ print(rpm.expand(intro .. args .. "}")) \ } @@ -137,7 +135,8 @@ local args = rpm.expand("%**"); \ local broot = rpm.expand("%buildroot"); \ local intro = "%{python_expand PYTHONPATH=${PYTHONPATH:+$PYTHONPATH:}" .. broot .. "%{$python_sitearch} PYTHONDONTWRITEBYTECODE=1 "; \ - intro = intro .. "pytest-%{$python_bin_suffix} --ignore=_build.python2 --ignore=_build.python3 --ignore=_build.pypy3 -v "; \ + local ignore_build = "--ignore=_build." .. rpm.expand("%pythons"):gsub("%s+", " --ignore=_build."); \ + intro = intro .. "pytest-%{$python_bin_suffix} " .. ignore_build .. " -v "; \ print(rpm.expand(intro .. args .. "}")) \ } @@ -145,7 +144,7 @@ %pyproject_wheel(+abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-=) %{lua:\ local args = rpm.expand("%**"); \ local intro = "%{python_expand $python -mpip wheel --no-deps %{?py_setup_args:--build-option %{py_setup_args}}"; \ - intro = intro .. " --use-pep517 --no-build-isolation --progress-bar off --verbose . "; \ + intro = intro .. " --disable-pip-version-check --use-pep517 --no-build-isolation --progress-bar off --verbose . "; \ print(rpm.expand(intro .. args .. "}")) \ } @@ -153,8 +152,31 @@ %pyproject_install(+abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-=) %{lua:\ local args = rpm.expand("%**"); \ local broot = rpm.expand("--root %buildroot"); \ - local intro = "%{python_expand $python -mpip install " .. broot .. " --no-compile --no-deps --progress-bar off *.whl "; \ + local intro = "%{python_expand $python -mpip install " .. broot .. " --disable-pip-version-check --no-compile --no-deps --progress-bar off *.whl "; \ print(rpm.expand(intro .. args .. "}")) \ + print(rpm.expand("%python_compileall")) } -#vi:tw=0 nowrap: +##### Precompile scripts macro ##### + +%python_compileall \ +%{python_expand for d in %{buildroot}%{$python_sitelib} %{buildroot}%{$python_sitearch}; do \ + if [ -d $d ]; then \ + find $d -name '*.pyc' -delete; \ + $python -m compileall $d; \ + $python -O -m compileall $d; \ + fi; \ +done \ +} \ +%{nil} + +##### Find language files ##### + +%python_find_lang() \ +%find_lang %{**} \ +langfile=%{?2}%{!?2:%1.lang} \ +%{python_expand # \ +grep -v 'python.*site-packages' ${langfile} > %{$python_prefix}-${langfile} \ +grep -F %{$python_sitelib} ${langfile} >> %{$python_prefix}-${langfile} \ +} \ +%{nil} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-rpm-macros-20200824.8fa42a7/macros.lua new/python-rpm-macros-20210112.86f4d9d/macros.lua --- old/python-rpm-macros-20200824.8fa42a7/macros.lua 2020-08-24 10:07:22.000000000 +0200 +++ new/python-rpm-macros-20210112.86f4d9d/macros.lua 2021-01-12 08:17:34.000000000 +0100 @@ -52,6 +52,12 @@ flavor = spec_name_prefix end + subpackage_only = rpm.expand("0%{?python_subpackage_only}") ~= "0" + if subpackage_only then + is_called_python = false + modname = "" + end + -- find the spec file specpath = rpm.expand("%_specfile") @@ -77,7 +83,9 @@ -- line processing functions local function print_altered(line) -- set %name macro to proper flavor-name - line = line:gsub("%%{?name}?", current_flavor .. "-" .. modname) + if not subpackage_only then + line = line:gsub("%%{?name}?", current_flavor .. "-" .. modname) + end -- print expanded print(rpm.expand(replace_macros(line, current_flavor)) .. "\n") end @@ -102,6 +110,9 @@ "Requires(pre):", "Requires(preun):", "Requires(post):", "Requires(postun):", "Requires(pretrans):", "Requires(posttrans):", } + local PROPERTY_COPY_DEFAULT_PROVIDER = lookup_table { + "Conflicts:", "Obsoletes:", "Provides:", "Supplements:", "Enhances:", + } local function process_package_line(line) -- This function processes lines like "Requires: something something". @@ -152,15 +163,29 @@ print_altered(line) elseif PROPERTY_COPY_MODIFIED[property] then -- specifically handle %name macro before expansion - line = line:gsub("%%{?name}?", current_flavor .. "-" .. modname) - -- convert value using the appropriate function - if value:startswith("packageand") then - value = fix_packageand(value, flavor) + if not subpackage_only then + line = line:gsub("%%{?name}?", current_flavor .. "-" .. modname) + end + local function print_property_copy_modified(value) + -- convert value using the appropriate function + if value:startswith("packageand") then + value = fix_packageand(value, flavor) + else + value = rename_package(value, flavor) + end + -- rely on print_altered to perform expansion on the result + print_altered(string.format("%s %s", property, value)) + end + if PROPERTY_COPY_DEFAULT_PROVIDER[property] then + -- print renamed lines for all flavors which the current_flavor provides. + for iflavor in string.gmatch(rpm.expand("%{?" .. current_flavor .. "_provides}") .. " " .. current_flavor, "%S+" ) do + current_flavor = iflavor -- make sure to process the main current_flavor last for final reset. + print_property_copy_modified(value) + end else - value = rename_package(value, flavor) + print_property_copy_modified(value) end - -- rely on print_altered to perform expansion on the result - print_altered(string.format("%s %s", property, value)) + end end @@ -187,10 +212,11 @@ end -- end line processing functions - local function print_obsoletes(modname) - if current_flavor == "python2" then - print(rpm.expand("Obsoletes: python-" .. modname .. " < %{?epoch:%{epoch}:}%{version}-%{release}\n")) - print(rpm.expand("Provides: python-" .. modname .. " = %{?epoch:%{epoch}:}%{version}-%{release}\n")) + local function print_provided_flavor(modname) + for provided_flavor in string.gmatch(rpm.expand("%{?" .. current_flavor .. "_provides}"), "%S+" ) do + local pkg = provided_flavor .. "-" .. modname + print(rpm.expand("Obsoletes: " .. pkg .. " < %{?epoch:%{epoch}:}%{version}-%{release}\n")) + print(rpm.expand("Provides: " .. pkg .. " = %{?epoch:%{epoch}:}%{version}-%{release}\n")) end end @@ -280,7 +306,7 @@ "pre", "post", "preun", "postun", "pretrans", "posttrans"} -- before we start, print Provides: python2-modname - if is_called_python and old_python2 then + if is_called_python and old_python2 and not subpackage_only then print(rpm.expand("Provides: python2-" .. modname .. " = %{?epoch:%{epoch}:}%{version}-%{release}\n")) end @@ -300,15 +326,21 @@ current_flavor = python -- rescan spec for each flavor - if not is_current_flavor then + if not is_current_flavor or subpackage_only then local spec, err = io.open(specpath, "r") if err then print ("could not find spec file at path: " .. specpath) return end rpm.define("python_flavor " .. python) - local section_function = process_package_line - print(section_headline("package", current_flavor, nil)) - print_obsoletes(modname) + local section_function + + if subpackage_only then + section_function = ignore_line + else + section_function = process_package_line + print(section_headline("package", current_flavor, nil)) + print_provided_flavor(modname) + end while true do -- collect lines until braces match. it's what rpm does, kind of. @@ -330,12 +362,36 @@ if KNOWN_SECTIONS[newsection] then -- enter new section - if param and param:startswith("-n") then - -- ignore named section + local ignore_section = false + if subpackage_only then + ignore_section = true + if param then + local subparam + if newsection == "files" then + subparam = param:match("%%{python_files%s+(.*)}") + else + subparam = param:match("^%-n%s+python%-(.*)$") + end + if subparam then + local submodname, subsubparam = rpm.expand(subparam):match("^(%S+)%s*(.*)$") + modname = submodname + param = subsubparam + ignore_section = false + end + end + elseif (param and param:startswith("-n")) then + ignore_section = true + end + if ignore_section then section_function = ignore_line elseif newsection == "package" then print(section_headline("package", current_flavor, param)) - print_obsoletes(modname .. "-" .. param) + if subpackage_only then + print_provided_flavor(modname) + else + -- only valid param is a regular subpackage name + print_provided_flavor(modname .. "-" .. param) + end section_function = process_package_line elseif newsection == "files" and current_flavor == flavor then section_function = ignore_line @@ -388,7 +444,7 @@ function python_exec(+abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-=) local args = rpm.expand("%**") - print(rpm.expand("%{python_expand %__$python " .. args .. "}")) + print(rpm.expand("%{python_expand $python " .. args .. "}")) end function python_expand(+abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-=) @@ -398,6 +454,9 @@ for _, python in ipairs(pythons) do print(rpm.expand("%{_python_use_flavor " .. python .. "}\n")) local cmd = replace_macros(args, python) + -- when used as call of the executable, basename only + cmd = cmd:gsub("$python%f[%s\"\'\\%)&|;<>]", string.basename(rpm.expand("%__" .. python))) + -- when used as flavor expansion for a custom macro cmd = cmd:gsub("$python", python) print(rpm.expand(cmd .. "\n")) end @@ -423,6 +482,11 @@ local param = "" if tonumber(nparams) > 0 then param = rpm.expand("%1") end + if subpackage_only then + modname = param + param = "" + end + print("-n " .. package_name(flavor, modname, param)) if not _python_subpackages_emitted then @@ -442,7 +506,7 @@ local binsuffix = rpm.expand("%" .. python .. "_bin_suffix") link,name,path = python_alternative_names(param, binsuffix, true) print(rpm.expand(string.format("cp %s %s\n", param, path))) - print(rpm.expand(string.format("sed -ri '1s@#!.*python.*@#!/usr/bin/%s@' %s\n", python, path))) + print(rpm.expand(string.format("sed -ri '1s@#!.*python.*@#!%s@' %s\n", "%__" .. python, path))) end -- %python_clone -a