Updated pip and packaging versions to work with free-threading packages (#2514)
We had an issue to install jaxlib with bazel when running the following
command (using rules_python v0.39):
```bash
bazel test \
--repo_env=HERMETIC_PYTHON_VERSION=3.13-ft \
--repo_env=JAX_NUM_GENERATED_CASES=$JAX_NUM_GENERATED_CASES \
--repo_env=JAX_ENABLE_X64=$JAX_ENABLE_X64 \
--repo_env=JAX_SKIP_SLOW_TESTS=$JAX_SKIP_SLOW_TESTS \
--repo_env=PYTHON_GIL=$PYTHON_GIL \
--repo_env=TSAN_OPTIONS="halt_on_error=1" \
--//jax:build_jaxlib=false \
--nocache_test_results \
--test_output=all \
//tests:cpu_tests
```
According to @vam-google, this was due to old pip/packaging versions. We
updated them and this helped to make work the whole building/testing
pipeline: https://github.com/jax-ml/jax/pull/24898
So, we would like to upstream the patch:
https://github.com/jax-ml/jax/pull/24898/files#diff-e3dc8d7d2bf5d057f95b86bcff7360b6c99fa1f458882fd112b58da4aceb53e4
diff --git a/CHANGELOG.md b/CHANGELOG.md
index da411c2..6ee4425 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -65,6 +65,8 @@
* (rules) The version-aware rules have been folded into the base rules and
the version-aware rules are now simply aliases for the base rules. The
`python_version` attribute is still used to specify the Python version.
+* (pypi) Updated versions of packages: `pip` to 24.3.1 and
+ `packaging` to 24.2.
{#v0-0-0-deprecations}
#### Deprecations
diff --git a/python/private/pypi/dependency_resolver/dependency_resolver.py b/python/private/pypi/dependency_resolver/dependency_resolver.py
index 293377d..6f6c202 100644
--- a/python/private/pypi/dependency_resolver/dependency_resolver.py
+++ b/python/private/pypi/dependency_resolver/dependency_resolver.py
@@ -16,6 +16,7 @@
import atexit
import os
+import re
import shutil
import sys
from pathlib import Path
@@ -117,7 +118,6 @@
absolute_path_prefix = resolved_requirements_file[
: -(len(requirements_file) - len(repository_prefix))
]
-
# As srcs might contain references to generated files we want to
# use the runfiles file first. Thus, we need to compute the relative path
# from the execution root.
@@ -162,12 +162,19 @@
argv.append(
f"--output-file={requirements_file_relative if UPDATE else requirements_out}"
)
- argv.extend(
+ src_files = [
(src_relative if Path(src_relative).exists() else resolved_src)
for src_relative, resolved_src in zip(srcs_relative, resolved_srcs)
- )
+ ]
+ argv.extend(src_files)
argv.extend(extra_args)
+ # Replace in the output lock file
+ # the lines like: # via -r /absolute/path/to/<requirements_file>
+ # with: # via -r <requirements_file>
+ # For Windows, we should explicitly call .as_posix() to convert \\ -> /
+ absolute_src_prefixes = [Path(src).absolute().parent.as_posix() + "/" for src in src_files]
+
if UPDATE:
print("Updating " + requirements_file_relative)
@@ -185,14 +192,14 @@
# and we should copy the updated requirements back to the source tree.
if not absolute_output_file.samefile(requirements_file_tree):
atexit.register(
- lambda: shutil.copy(
- absolute_output_file, requirements_file_tree
- )
+ lambda: shutil.copy(absolute_output_file, requirements_file_tree)
)
- cli(argv, standalone_mode = False)
+ cli(argv, standalone_mode=False)
requirements_file_relative_path = Path(requirements_file_relative)
content = requirements_file_relative_path.read_text()
content = content.replace(absolute_path_prefix, "")
+ for absolute_src_prefix in absolute_src_prefixes:
+ content = content.replace(absolute_src_prefix, "")
requirements_file_relative_path.write_text(content)
else:
# cli will exit(0) on success
@@ -214,6 +221,15 @@
golden = open(_locate(bazel_runfiles, requirements_file)).readlines()
out = open(requirements_out).readlines()
out = [line.replace(absolute_path_prefix, "") for line in out]
+
+ def replace_via_minus_r(line):
+ if "# via -r " in line:
+ for absolute_src_prefix in absolute_src_prefixes:
+ line = line.replace(absolute_src_prefix, "")
+ return line
+ return line
+
+ out = [replace_via_minus_r(line) for line in out]
if golden != out:
import difflib
diff --git a/python/private/pypi/deps.bzl b/python/private/pypi/deps.bzl
index 31a5201..21dd777 100644
--- a/python/private/pypi/deps.bzl
+++ b/python/private/pypi/deps.bzl
@@ -51,8 +51,8 @@
),
(
"pypi__packaging",
- "https://files.pythonhosted.org/packages/49/df/1fceb2f8900f8639e278b056416d49134fb8d84c5942ffaa01ad34782422/packaging-24.0-py3-none-any.whl",
- "2ddfb553fdf02fb784c234c7ba6ccc288296ceabec964ad2eae3777778130bc5",
+ "https://files.pythonhosted.org/packages/88/ef/eb23f262cca3c0c4eb7ab1933c3b1f03d021f2c48f54763065b6f0e321be/packaging-24.2-py3-none-any.whl",
+ "09abb1bccd265c01f4a3aa3f7a7db064b36514d2cba19a2f694fe6150451a759",
),
(
"pypi__pep517",
@@ -61,8 +61,8 @@
),
(
"pypi__pip",
- "https://files.pythonhosted.org/packages/8a/6a/19e9fe04fca059ccf770861c7d5721ab4c2aebc539889e97c7977528a53b/pip-24.0-py3-none-any.whl",
- "ba0d021a166865d2265246961bec0152ff124de910c5cc39f1156ce3fa7c69dc",
+ "https://files.pythonhosted.org/packages/ef/7d/500c9ad20238fcfcb4cb9243eede163594d7020ce87bd9610c9e02771876/pip-24.3.1-py3-none-any.whl",
+ "3790624780082365f47549d032f3770eeb2b1e8bd1f7b2e02dace1afa361b4ed",
),
(
"pypi__pip_tools",