Import missing pip packages for --config=k8_upstream_python
There are still a bunch of packages that were not available for
`rules_python`. This patch imports them.
I was running into some trouble with pip insisting on listing
`pyyaml_env_tag` as `pyyaml-env-tag` in the lock file. This caused
some trouble in the interaction between our wheel override and
rules_python. I adjusted both to use the same name.
Signed-off-by: Philipp Schrader <philipp.schrader@gmail.com>
Change-Id: Ibc501461deae41c4285f9149dd020678a2ee91b0
diff --git a/tools/python/mirror_pip_packages.py b/tools/python/mirror_pip_packages.py
index 19bb477..76a33a8 100644
--- a/tools/python/mirror_pip_packages.py
+++ b/tools/python/mirror_pip_packages.py
@@ -26,6 +26,22 @@
PY_DEPS_WWWW_DIR = "/var/www/html/files/frc971/Build-Dependencies/wheelhouse"
+def sanitize_name(name: str) -> str:
+ """Sanitizes a package name so it's consistent across all use cases.
+
+ pip is really inconsistent about using real package names vs. whatever
+ users typed into the requirements file. It feels random.
+ Everything is lower-cased and dashes are replaced by underscores.
+
+ Args:
+ name: The name to sanitize.
+
+ Returns:
+ The sanitized name.
+ """
+ return name.lower().replace("-", "_").replace(".", "_")
+
+
def compute_sha256(data: bytes) -> str:
"""Computes the sha256 checksum of a bytes sequence.
@@ -215,7 +231,7 @@
# We use lower-case for the package names here because that's what the
# requirements.lock.txt file uses.
info = Wheel(wheel)
- override_information[f"{info.name.lower()}=={info.version}"] = {
+ override_information[f"{sanitize_name(info.name)}=={info.version}"] = {
"url": override_url,
"sha256": sha256,
}