#186 define bare __python macro
Merged 2 years ago by scoady. Opened 2 years ago by scoady.
fedora-infra/ scoady/rpmautospec bare-python-macro  into  main

@@ -2,6 +2,7 @@ 

  import logging

  import re

  import subprocess

+ import sys

  from collections import defaultdict

  from fnmatch import fnmatchcase

  from functools import lru_cache, reduce
@@ -91,6 +92,8 @@ 

              AUTORELEASE_MACRO + " E%{?-e*}_S%{?-s*}_P%{?-p:1}%{!?-p:0}_B%{?-b*}"

          )

  

+         python_version = str(sys.version_info[0]) + "." + str(sys.version_info[1])

+ 

          rpm_cmd = [

              "rpm",

              "--define",
@@ -99,6 +102,10 @@ 

              autorelease_definition,

              "--define",

              "autochangelog %nil",

+             "--define",

+             f"__python /usr/bin/python{python_version}",

+             "--define",

+             f"python_sitelib /usr/lib/python{python_version}/site-packages",

              "--qf",

              query,

              "--specfile",

this fixes: https://pagure.io/fedora-infra/rpmautospec/issue/170

verification steps:

  • clone the python-arrow rpm repo
  • replace the release and changelog with auto macros
  • run rpmautospec master against this repo.
  • the changelog should have something along the lines of None-1 for releases towards the end of the changelog
  • checkout this branch of rpmautospec
  • run again and those None values should be replaced by real release numbers.

Signed-off-by: Stephen Coady scoady@redhat.com

Build succeeded.

We've avoided using legacy file/path APIs in favour of pathlib, so let's not start here. Instead, do it like this:

    macros_workaround = Path.cwd() / "rpmautospec" / "support_files" / "macros.workarounds"
...
    "--load",
    str(macros_workaround),
...

Let's not hardcode Python 3.8 hereā€¦ Have you encountered something where this wasn't defined and made a problem? If so, I'd rather build the macros on the fly in code and set each with its own --define arg when invoking rpm.

NB: The directory or file would have to be added to MANIFEST.in or it would be missing from the source tarball built with python setup.py sdist.

Yes, I've seen rpm throw an error for a bare python_sitelib too. You're right though, calculating it on the fly and inserting it directly into the rpm command is way cleaner and means we don't need to carry a clunky file around.

rebased onto d7d9c225a810bc42fc507ed5472eaa1f1fc349de

2 years ago

Build succeeded.

Build succeeded.

Joined @scoady on a call to verify, working as expected. +1

Pull-Request has been merged by scoady

2 years ago
Metadata