Skip to content

Commit 309ee59

Browse files
authored
revert: Updated pip and packaging versions to work with free-threading packages (bazel-contrib#2514) (bazel-contrib#2584)
This reverts commit fbf8bc1 (bazel-contrib#2514) Also, update the CHANGELOG about the reverting. Fixes bazel-contrib#908, which is about the `pip-compile` not using the right files for performing the locking. It seems that the `pip` upgrade regressed this error.
1 parent 18f76f9 commit 309ee59

File tree

3 files changed

+16
-27
lines changed

3 files changed

+16
-27
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ Unreleased changes template.
5757
* (rules) deprecation warnings for deprecated symbols have been turned off by
5858
default for now and can be enabled with `RULES_PYTHON_DEPRECATION_WARNINGS`
5959
env var.
60+
* (pypi) Downgraded versions of packages: `pip` from `24.3.2` to `24.0.0` and
61+
`packaging` from `24.2` to `24.0`.
6062

6163
{#v0-0-0-fixed}
6264
### Fixed
@@ -67,6 +69,9 @@ Unreleased changes template.
6769
as UTF-8 on all platforms.
6870
* (coverage) Coverage with `--bootstrap_impl=script` is fixed
6971
([#2572](https://github.com/bazelbuild/rules_python/issues/2572)).
72+
* (pypi) Non deterministic behaviour in requirement file usage has been fixed
73+
by reverting [#2514](https://github.com/bazelbuild/rules_python/pull/2514).
74+
The related issue is [#908](https://github.com/bazelbuild/rules_python/issue/908).
7075
* (sphinxdocs) Do not crash when `tag_class` does not have a populated `doc` value.
7176
Fixes ([#2579](https://github.com/bazelbuild/rules_python/issues/2579)).
7277

python/private/pypi/dependency_resolver/dependency_resolver.py

+7-23
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
import atexit
1818
import os
19-
import re
2019
import shutil
2120
import sys
2221
from pathlib import Path
@@ -118,6 +117,7 @@ def main(
118117
absolute_path_prefix = resolved_requirements_file[
119118
: -(len(requirements_file) - len(repository_prefix))
120119
]
120+
121121
# As srcs might contain references to generated files we want to
122122
# use the runfiles file first. Thus, we need to compute the relative path
123123
# from the execution root.
@@ -162,19 +162,12 @@ def main(
162162
argv.append(
163163
f"--output-file={requirements_file_relative if UPDATE else requirements_out}"
164164
)
165-
src_files = [
165+
argv.extend(
166166
(src_relative if Path(src_relative).exists() else resolved_src)
167167
for src_relative, resolved_src in zip(srcs_relative, resolved_srcs)
168-
]
169-
argv.extend(src_files)
168+
)
170169
argv.extend(extra_args)
171170

172-
# Replace in the output lock file
173-
# the lines like: # via -r /absolute/path/to/<requirements_file>
174-
# with: # via -r <requirements_file>
175-
# For Windows, we should explicitly call .as_posix() to convert \\ -> /
176-
absolute_src_prefixes = [Path(src).absolute().parent.as_posix() + "/" for src in src_files]
177-
178171
if UPDATE:
179172
print("Updating " + requirements_file_relative)
180173

@@ -192,14 +185,14 @@ def main(
192185
# and we should copy the updated requirements back to the source tree.
193186
if not absolute_output_file.samefile(requirements_file_tree):
194187
atexit.register(
195-
lambda: shutil.copy(absolute_output_file, requirements_file_tree)
188+
lambda: shutil.copy(
189+
absolute_output_file, requirements_file_tree
190+
)
196191
)
197-
cli(argv, standalone_mode=False)
192+
cli(argv, standalone_mode = False)
198193
requirements_file_relative_path = Path(requirements_file_relative)
199194
content = requirements_file_relative_path.read_text()
200195
content = content.replace(absolute_path_prefix, "")
201-
for absolute_src_prefix in absolute_src_prefixes:
202-
content = content.replace(absolute_src_prefix, "")
203196
requirements_file_relative_path.write_text(content)
204197
else:
205198
# cli will exit(0) on success
@@ -221,15 +214,6 @@ def main(
221214
golden = open(_locate(bazel_runfiles, requirements_file)).readlines()
222215
out = open(requirements_out).readlines()
223216
out = [line.replace(absolute_path_prefix, "") for line in out]
224-
225-
def replace_via_minus_r(line):
226-
if "# via -r " in line:
227-
for absolute_src_prefix in absolute_src_prefixes:
228-
line = line.replace(absolute_src_prefix, "")
229-
return line
230-
return line
231-
232-
out = [replace_via_minus_r(line) for line in out]
233217
if golden != out:
234218
import difflib
235219

python/private/pypi/deps.bzl

+4-4
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ _RULE_DEPS = [
5151
),
5252
(
5353
"pypi__packaging",
54-
"https://files.pythonhosted.org/packages/88/ef/eb23f262cca3c0c4eb7ab1933c3b1f03d021f2c48f54763065b6f0e321be/packaging-24.2-py3-none-any.whl",
55-
"09abb1bccd265c01f4a3aa3f7a7db064b36514d2cba19a2f694fe6150451a759",
54+
"https://files.pythonhosted.org/packages/49/df/1fceb2f8900f8639e278b056416d49134fb8d84c5942ffaa01ad34782422/packaging-24.0-py3-none-any.whl",
55+
"2ddfb553fdf02fb784c234c7ba6ccc288296ceabec964ad2eae3777778130bc5",
5656
),
5757
(
5858
"pypi__pep517",
@@ -61,8 +61,8 @@ _RULE_DEPS = [
6161
),
6262
(
6363
"pypi__pip",
64-
"https://files.pythonhosted.org/packages/ef/7d/500c9ad20238fcfcb4cb9243eede163594d7020ce87bd9610c9e02771876/pip-24.3.1-py3-none-any.whl",
65-
"3790624780082365f47549d032f3770eeb2b1e8bd1f7b2e02dace1afa361b4ed",
64+
"https://files.pythonhosted.org/packages/8a/6a/19e9fe04fca059ccf770861c7d5721ab4c2aebc539889e97c7977528a53b/pip-24.0-py3-none-any.whl",
65+
"ba0d021a166865d2265246961bec0152ff124de910c5cc39f1156ce3fa7c69dc",
6666
),
6767
(
6868
"pypi__pip_tools",

0 commit comments

Comments
 (0)