Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When the reject file is simple, replace it by rpmdev-bumpspec #10

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

encukou
Copy link
Member

@encukou encukou commented Aug 19, 2020

No description provided.

@encukou
Copy link
Member Author

encukou commented Sep 2, 2020

It's green!

Copy link
Member

@hroncok hroncok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A forgotten suggestion from 14 days ago.

README.md Outdated Show resolved Hide resolved
@hroncok
Copy link
Member

hroncok commented Sep 2, 2020

I'll test this on some real situation, hopefully soon enough.

Co-authored-by: Miro Hrončok <miro@hroncok.cz>
@hroncok
Copy link
Member

hroncok commented Sep 2, 2020

ferrypick.py Show resolved Hide resolved
This is on the strict side, but hopefully we keep our trees clean.
@encukou
Copy link
Member Author

encukou commented Nov 4, 2020

I'm not sure what the date even means (change was started? code finished? posted for review? reviewed? merged? built?), I don't care what it is and so I'm quite OK with always using today's date :)

I'd start using --datestamp when rpmdevtools 9.2 makes it to all the Fedoras.

@hroncok
Copy link
Member

hroncok commented Nov 4, 2020

I'm quite OK with always using today's date :)

I don't care what date there is, but I was worried that using a different date might make further git ams fail again. However with this tooling, it might no longer be important.

@hroncok
Copy link
Member

hroncok commented Jun 30, 2022

I'm afraid this got a bit stalled :D

Will check it out when my next conflict happens.

@hroncok
Copy link
Member

hroncok commented Jul 19, 2022

Finally, I was able to check this.

On package python-rpm-macros, branch f36, HEAD is d174f03.

[python-rpm-macros (f36-cache_tag)]$ ferrypick https://src.fedoraproject.org/rpms/python-rpm-macros/pull-request/138
Downloading https://src.fedoraproject.org/rpms/python-rpm-macros/pull-request/138.patch
$ git am --committer-date-is-author-date --reject ferrypick.patch
Applying: Define %python3_cache_tag / %python_cache_tag, e.g. cpython-311
Checking patch macros.python...
Checking patch macros.python3...
Checking patch python-rpm-macros.spec...
error: while searching for:
end
}
Version:        %{__default_python3_version}
Release:        1%{?dist}

BuildArch:      noarch


error: patch failed: python-rpm-macros.spec:49
error: while searching for:


%changelog
* Mon Jun 13 2022 Tomáš Hrnčiar <thrnciar@redhat.com> - 3.11-1
- Update main Python to Python 3.11
- https://fedoraproject.org/wiki/Changes/Python3.11

error: patch failed: python-rpm-macros.spec:151
Checking patch tests/test_evals.py...
Applied patch macros.python cleanly.
Applied patch macros.python3 cleanly.
Applying patch python-rpm-macros.spec with 2 rejects...
Rejected hunk #1.
Rejected hunk #2.
Applied patch tests/test_evals.py cleanly.
Patch failed at 0001 Define %python3_cache_tag / %python_cache_tag, e.g. cpython-311
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

git am failed with exit code 128
Patch stored as: ferrypick.patch
Processing rejects in python-rpm-macros.spec.rej
 end
 }
 Version:        %{__default_python3_version}
-Release:        1%{?dist}
+Release:        2%{?dist}

 BuildArch:      noarch

@@ -151,6 +151,9 @@ grep -E '^#[^%%]*%%[^%%]' %{buildroot}%{rpmmacrodir}/macros.* && exit 1 || true


 %changelog
+* Mon Jun 20 2022 Miro Hrončok <mhroncok@redhat.com> - 3.11-2
+- Define %%python3_cache_tag / %%python_cache_tag, e.g. cpython-311
+
 * Mon Jun 13 2022 Tomáš Hrnčiar <thrnciar@redhat.com> - 3.11-1
 - Update main Python to Python 3.11
 - https://fedoraproject.org/wiki/Changes/Python3.11
Rejects in python-rpm-macros.spec.rej look harmless
$ rpmdev-bumpspec -u 'Miro Hrončok <mhroncok@redhat.com>' -c '- Define %%python3_cache_tag / %%python_cache_tag, e.g. cpython-311' python-rpm-macros.spec
$ git add python-rpm-macros.spec
$ git add tests/pythontest.spec
$ git am --continue
Applying: Define %python3_cache_tag / %python_cache_tag, e.g. cpython-311
[python-rpm-macros (f36-cache_tag *)]$ git status 
On branch f36-cache_tag
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   macros.python
	modified:   macros.python3
	modified:   tests/test_evals.py

no changes added to commit (use "git add" and/or "git commit -a")
[python-rpm-macros (f36-cache_tag *)]$ git diff
diff --git a/macros.python b/macros.python
index cfe89b6..f060340 100644
--- a/macros.python
+++ b/macros.python
@@ -10,6 +10,7 @@
 %python_platform %(RPM_BUILD_ROOT= %{__python} -Esc "import sysconfig; print(sysconfig.get_platform())")
 %python_platform_triplet %(RPM_BUILD_ROOT= %{__python} -Esc "import sysconfig; print(sysconfig.get_config_var('MULTIARCH'))")
 %python_ext_suffix %(RPM_BUILD_ROOT= %{__python} -Esc "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))")
+%python_cache_tag %(RPM_BUILD_ROOT= %{__python} -Esc "import sys; print(sys.implementation.cache_tag)")
 
 %py_setup setup.py
 %py_shbang_opts -s
diff --git a/macros.python3 b/macros.python3
index 3977e7a..4f2b2d2 100644
--- a/macros.python3
+++ b/macros.python3
@@ -8,6 +8,7 @@
 %python3_platform %(RPM_BUILD_ROOT= %{__python3} -Ic "import sysconfig; print(sysconfig.get_platform())")
 %python3_platform_triplet %(RPM_BUILD_ROOT= %{__python3} -Ic "import sysconfig; print(sysconfig.get_config_var('MULTIARCH'))")
 %python3_ext_suffix %(RPM_BUILD_ROOT= %{__python3} -Ic "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))")
+%python3_cache_tag %(RPM_BUILD_ROOT= %{__python3} -Ic "import sys; print(sys.implementation.cache_tag)")
 %py3dir %{_builddir}/python3-%{name}-%{version}-%{release}
 
 %py3_shbang_opts -s
@@ -103,6 +104,7 @@
     pyminor = path:match("/python3.(%d+)/") or "*"
     dirname = path:match("(.*/)")
     modulename = path:match(".*/([^/]+).py")
diff --git a/macros.python b/macros.python
index cfe89b6..f060340 100644
--- a/macros.python
+++ b/macros.python
@@ -10,6 +10,7 @@
 %python_platform %(RPM_BUILD_ROOT= %{__python} -Esc "import sysconfig; print(sysconfig.get_platform())")
 %python_platform_triplet %(RPM_BUILD_ROOT= %{__python} -Esc "import sysconfig; print(sysconfig.get_config_var('MULTIARCH'))")
 %python_ext_suffix %(RPM_BUILD_ROOT= %{__python} -Esc "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))")
+%python_cache_tag %(RPM_BUILD_ROOT= %{__python} -Esc "import sys; print(sys.implementation.cache_tag)")
 
 %py_setup setup.py
 %py_shbang_opts -s
diff --git a/macros.python3 b/macros.python3
index 3977e7a..4f2b2d2 100644
--- a/macros.python3
+++ b/macros.python3
@@ -8,6 +8,7 @@
 %python3_platform %(RPM_BUILD_ROOT= %{__python3} -Ic "import sysconfig; print(sysconfig.get_platform())")
 %python3_platform_triplet %(RPM_BUILD_ROOT= %{__python3} -Ic "import sysconfig; print(sysconfig.get_config_var('MULTIARCH'))")
 %python3_ext_suffix %(RPM_BUILD_ROOT= %{__python3} -Ic "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))")
+%python3_cache_tag %(RPM_BUILD_ROOT= %{__python3} -Ic "import sys; print(sys.implementation.cache_tag)")
 %py3dir %{_builddir}/python3-%{name}-%{version}-%{release}
 
 %py3_shbang_opts -s
@@ -103,6 +104,7 @@
     pyminor = path:match("/python3.(%d+)/") or "*"
     dirname = path:match("(.*/)")
     modulename = path:match(".*/([^/]+).py")
+    -- %%python3_cache_tag is not used here because this macro supports not-installed CPythons
     print("\\n" .. dirname .. "__pycache__/" .. modulename .. ".cpython-3" .. pyminor .. "{,.opt-?}.pyc")
   end
 }
diff --git a/tests/test_evals.py b/tests/test_evals.py
index 2489644..7a5c66f 100644
--- a/tests/test_evals.py
+++ b/tests/test_evals.py
@@ -72,8 +72,17 @@ def get_alt_x_y():
         raise ValueError(f"${env_name} must be X.Y")
     return alternate_python_version
 
-# We don't use the decorator, to be able to call the function itselef
+
+def get_alt_xy():
+    """
+    Same as get_alt_x_y() but without a dot
+    """
+    return get_alt_x_y().replace(".", "")
+
+
+# We don't use decorators, to be able to call the functions directly
 alt_x_y = pytest.fixture(scope="session")(get_alt_x_y)
+alt_xy = pytest.fixture(scope="session")(get_alt_xy)
 
 
 def shell_stdout(script):
@@ -638,6 +647,7 @@ unversioned_macros = pytest.mark.parametrize('macro', [
     '%python_platform',
     '%python_platform_triplet',
     '%python_ext_suffix',
+    '%python_cache_tag',
     '%py_shebang_fix',
     '%py_build',
     '%py_build_egg',
@@ -676,6 +686,18 @@ def test_ext_suffix():
     assert rpm_eval("%python3_ext_suffix") == [f".cpython-{XY}-x86_64-linux-gnu.so"]
 
 
+def test_cache_tag():
+    assert rpm_eval("%python3_cache_tag") == [f"cpython-{XY}"]
+
+
+def test_cache_tag_alternate_python(alt_x_y, alt_xy):
+    assert rpm_eval("%python_cache_tag", __python=f"/usr/bin/python{alt_x_y}") == [f"cpython-{alt_xy}"]
+
+
+def test_cache_tag_alternate_python3(alt_x_y, alt_xy):
+    assert rpm_eval("%python3_cache_tag", __python3=f"/usr/bin/python{alt_x_y}") == [f"cpython-{alt_xy}"]
+
+
 def test_python_sitelib_value_python3():
     macro = '%python_sitelib'
     assert rpm_eval(macro, __python='%__python3') == [f'/usr/lib/python{X_Y}/site-packages']
[python-rpm-macros (f36-cache_tag *)]$ git show
commit 702a675a3c6d965701ac5417acec8b7647a3c941 (HEAD -> f36-cache_tag)
Author: Miro Hrončok <miro@hroncok.cz>
Date:   Tue Jul 19 09:42:56 2022 +0000

    Define %python3_cache_tag / %python_cache_tag, e.g. cpython-311
    
    When reviewing https://src.fedoraproject.org/rpms/pyproject-rpm-macros/pull-request/291
    we have discovered that there is no macronized way to get this part of some paths
    and that packagers need to hardcode it as cpython-%{python3_version_nodots}.
    
    This way, we have a standardized macro packagers (and other macros) can use.

diff --git a/python-rpm-macros.spec b/python-rpm-macros.spec
index ed58330..d88e0d0 100644
--- a/python-rpm-macros.spec
+++ b/python-rpm-macros.spec
@@ -49,7 +49,7 @@ elseif posix.stat('macros.python-srpm') then
 end
 }
 Version:        %{__default_python3_version}
-Release:        18%{?dist}
+Release:        19%{?dist}
 
 BuildArch:      noarch
 
@@ -151,6 +151,9 @@ grep -E '^#[^%%]*%%[^%%]' %{buildroot}%{rpmmacrodir}/macros.* && exit 1 || true
 
 
 %changelog
+* Tue Jul 19 2022 Miro Hrončok <mhroncok@redhat.com> - 3.10-19
+- Define %%python3_cache_tag / %%python_cache_tag, e.g. cpython-311
+
 * Thu May 26 2022 Owen Taylor <otaylor@redhat.com> - 3.10-18
 - Support installing to %%{_prefix} other than /usr

So the changes appear to be OK, but only the release bump was committed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants