!34 [sync] PR-23: Fixed wheel pack duplicating WHEEL contents on build number
From: @openeuler-sync-bot Reviewed-by: @lyn1001 Signed-off-by: @lyn1001
This commit is contained in:
commit
1dc80adc2c
@ -0,0 +1,78 @@
|
||||
From 3f1a73a2b282ed55044541d3c28e0618d8b1de14 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Alex=20Gr=C3=B6nholm?= <alex.gronholm@nextday.fi>
|
||||
Date: Sun, 15 Aug 2021 23:58:47 +0300
|
||||
Subject: [PATCH] Fixed wheel pack duplicating WHEEL contents on build number
|
||||
change
|
||||
|
||||
Fixes #415.
|
||||
---
|
||||
docs/news.rst | 4 ++++
|
||||
src/wheel/cli/pack.py | 5 ++++-
|
||||
tests/cli/test_pack.py | 15 ++++++++++++---
|
||||
3 files changed, 20 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/docs/news.rst b/docs/news.rst
|
||||
index 2653b0a..4fc4f4c 100644
|
||||
--- a/docs/news.rst
|
||||
+++ b/docs/news.rst
|
||||
@@ -1,6 +1,10 @@
|
||||
Release Notes
|
||||
=============
|
||||
|
||||
+**UNRELEASED**
|
||||
+
|
||||
+- Fixed ``wheel pack`` duplicating the ``WHEEL`` contents when the build number has changed (#415)
|
||||
+
|
||||
**0.37.0 (2021-08-09)**
|
||||
|
||||
- Added official Python 3.10 support
|
||||
diff --git a/src/wheel/cli/pack.py b/src/wheel/cli/pack.py
|
||||
index 1e77fdb..9403c51 100644
|
||||
--- a/src/wheel/cli/pack.py
|
||||
+++ b/src/wheel/cli/pack.py
|
||||
@@ -57,9 +57,12 @@ def pack(directory, dest_dir, build_number):
|
||||
replacement = ('Build: %s\r\n' % build_number).encode('ascii') if build_number else b''
|
||||
with open(wheel_file_path, 'rb+') as f:
|
||||
wheel_file_content = f.read()
|
||||
- if not BUILD_NUM_RE.subn(replacement, wheel_file_content)[1]:
|
||||
+ wheel_file_content, num_replaced = BUILD_NUM_RE.subn(replacement,
|
||||
+ wheel_file_content)
|
||||
+ if not num_replaced:
|
||||
wheel_file_content += replacement
|
||||
|
||||
+ f.seek(0)
|
||||
f.truncate()
|
||||
f.write(wheel_file_content)
|
||||
|
||||
diff --git a/tests/cli/test_pack.py b/tests/cli/test_pack.py
|
||||
index ff36d6f..3f689a4 100644
|
||||
--- a/tests/cli/test_pack.py
|
||||
+++ b/tests/cli/test_pack.py
|
||||
@@ -1,4 +1,5 @@
|
||||
import os
|
||||
+from textwrap import dedent
|
||||
from zipfile import ZipFile
|
||||
|
||||
import pytest
|
||||
@@ -47,7 +48,15 @@ def test_pack(tmpdir_factory, tmpdir, build_tag_arg, existing_build_tag, filenam
|
||||
assert new_record_lines == old_record_lines
|
||||
|
||||
expected_build_num = build_tag_arg or existing_build_tag
|
||||
+ expected_wheel_content = dedent("""\
|
||||
+ Wheel-Version: 1.0
|
||||
+ Generator: bdist_wheel (0.30.0)
|
||||
+ Root-Is-Purelib: false
|
||||
+ Tag: py2-none-any
|
||||
+ Tag: py3-none-any
|
||||
+ """.replace('\n', '\r\n'))
|
||||
if expected_build_num:
|
||||
- assert ('Build: %s\r\n' % expected_build_num).encode() in new_wheel_file_content
|
||||
- else:
|
||||
- assert b'Build: ' not in new_wheel_file_content
|
||||
+ expected_wheel_content += 'Build: %s\r\n' % expected_build_num
|
||||
+
|
||||
+ expected_wheel_content = expected_wheel_content.encode('ascii')
|
||||
+ assert new_wheel_file_content == expected_wheel_content
|
||||
--
|
||||
2.42.0.windows.2
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
%bcond_with bootstrap
|
||||
Name: python-wheel
|
||||
Version: 0.37.0
|
||||
Release: 2
|
||||
Release: 3
|
||||
Epoch: 1
|
||||
Summary: Built-package format for Python
|
||||
License: MIT
|
||||
@ -9,6 +9,8 @@ URL: https://github.com/pypa/wheel
|
||||
Source0: %{url}/archive/%{version}/wheel-%{version}.tar.gz
|
||||
BuildArch: noarch
|
||||
|
||||
Patch01: 0001-Fixed-wheel-pack-duplicating-WHEEL-contents-on-build.patch
|
||||
|
||||
%description
|
||||
A built-package format for Python.
|
||||
A wheel is a ZIP-format archive with a specially formatted filename and the
|
||||
@ -79,6 +81,9 @@ PYTHONPATH=%{buildroot}%{python3_sitelib} py.test-3 -v --ignore build
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Fri Oct 13 2023 liubo <liubo1@xfusion.com> - 0.37.0-3
|
||||
- Fixed wheel pack duplicating WHEEL contents on build number
|
||||
|
||||
* Thu Oct 27 2022 zhangruifang <zhangruifang1@h-partners.com> - 0.37.0-2
|
||||
- Rebuild for next release
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user