Revert "feat(pypi): use the none-any wheel as a fallback with target_platforms = ["*"]" This reverts commit 5149b91edef1df7d213e8e46382b3f36d9032ea2.
diff --git a/news/pip-target-platforms-all.added.md b/news/pip-target-platforms-all.added.md index 374a45f..cb690ce 100644 --- a/news/pip-target-platforms-all.added.md +++ b/news/pip-target-platforms-all.added.md
@@ -1,4 +1,2 @@ (pypi) {attr}`pip.parse.target_platforms` accepts `"*"` to evaluate the -requirements for all of the platforms configured with {obj}`pip.default`. With -{attr}`pip.parse.uv_lock`, the `none-any` wheel of a package is also used for -the platforms that are not configured. +requirements for all of the platforms configured with {obj}`pip.default`.
diff --git a/python/private/pypi/extension.bzl b/python/private/pypi/extension.bzl index fa328d6..908a40b 100644 --- a/python/private/pypi/extension.bzl +++ b/python/private/pypi/extension.bzl
@@ -907,9 +907,7 @@ a string `"{os}_{arch}"` as the value here. You could also use `"{os}_{arch}_freethreaded"` as well. Use `"*"` to evaluate the requirements for all of the platforms configured with -{obj}`pip.default`. When used together with {attr}`uv_lock`, the platform -independent (`none-any`) wheel of a package, if present, is also used for the -platforms that are not configured with {obj}`pip.default`. +{obj}`pip.default`. :::{include} /_includes/experimental_api.md :::
diff --git a/python/private/pypi/hub_builder.bzl b/python/private/pypi/hub_builder.bzl index 1f61a5e..df0c487 100644 --- a/python/private/pypi/hub_builder.bzl +++ b/python/private/pypi/hub_builder.bzl
@@ -577,7 +577,6 @@ extra_pip_args = pip_attr.extra_pip_args, get_index_urls = self._get_index_urls.get(python_version), toml_decode = getattr(self._config, "toml_decode", None), - any_src = "*" in pip_attr.target_platforms, logger = logger, ) @@ -632,29 +631,6 @@ repo = repo, ) - if getattr(whl, "any_src", None): - # Use the platform independent wheel for the platforms that are - # not configured, so it has no target platforms and the more - # specific config settings take precedence. - _add_whl_library( - self, - python_version = python_version, - whl = whl, - repo = _whl_repo( - src = whl.any_src, - index_url = whl.index_url, - whl_library_args = whl_library_args, - download_only = pip_attr.download_only, - netrc = self._config.netrc or pip_attr.netrc, - use_downloader = True, - auth_patterns = self._config.auth_patterns or pip_attr.auth_patterns, - python_version = _major_minor_version(python_version), - is_multiple_versions = whl.is_multiple_versions, - interpreter = interpreter, - enable_pipstar_extract = enable_pipstar_extract, - ), - ) - def _common_args(self, module_ctx, *, pip_attr): # Construct args separately so that the lock file can be smaller and does not include unused # attrs.
diff --git a/python/private/pypi/parse_requirements.bzl b/python/private/pypi/parse_requirements.bzl index 7913602..2d8c4b4 100644 --- a/python/private/pypi/parse_requirements.bzl +++ b/python/private/pypi/parse_requirements.bzl
@@ -47,7 +47,6 @@ extract_url_srcs = True, uv_lock = None, toml_decode = None, - any_src = False, logger): """Get the requirements with platforms that the requirements apply to. @@ -72,9 +71,6 @@ requirements files if both are provided. toml_decode: {type}`callable | None` A function to decode TOML content (e.g. `toml.decode`). Required when `uv_lock` is provided. - any_src: {type}`bool` whether to add the `any_src` field to each - returned struct, which is the platform independent wheel of the - package or `None`. Only supported with `uv_lock`. logger: repo_utils.logger, a simple struct to log diagnostic messages. Returns: @@ -100,7 +96,6 @@ get_index_urls = get_index_urls, extract_url_srcs = extract_url_srcs, uv_lock = uv_lock, - any_src = any_src, logger = logger, ) @@ -131,13 +126,11 @@ get_index_urls, extract_url_srcs, uv_lock, - any_src, logger): """Parse requirements using uv.lock as the primary source.""" if uv_lock: return _parse_uv_lock_json( uv_lock = uv_lock, - any_src = any_src, all_platforms = _get_all_platforms(requirements_by_platform) if requirements_by_platform else sorted(platforms.keys()), platforms = platforms, extra_pip_args = extra_pip_args, @@ -227,7 +220,7 @@ queue.append(target) return result -def _parse_uv_lock_json(uv_lock, all_platforms, logger, extra_pip_args = None, platforms = {}, any_src = False): +def _parse_uv_lock_json(uv_lock, all_platforms, logger, extra_pip_args = None, platforms = {}): """Parse uv.lock JSON and build the same return structs as parse_requirements. Args: @@ -237,8 +230,6 @@ extra_pip_args: {type}`list[str] | None` Extra pip arguments to pass through. platforms: {type}`dict[str, struct]` A dict of platform name to platform info (containing `.env` with PEP 508 marker environment). - any_src: {type}`bool` whether to add the `any_src` field with the platform - independent wheel of each package. Returns: {type}`list[struct]` The same format as {func}`parse_requirements`. @@ -256,7 +247,6 @@ version = pkg["version"] norm_name = normalize_name(name) entry = uv_packages.setdefault(norm_name, { - "any_srcs": {}, "distribution": name, "resolved_srcs": [], "versions": {}, @@ -313,35 +303,6 @@ requirement = _uv_lock_git_requirement(pkg["source"]["git"]), ) - # The platform independent wheel, if there is one, which can be used - # as a fallback for the platforms that are not configured. - if any_src and candidates and pkg_platforms and platforms.get(pkg_platforms[0]): - platform = platforms[pkg_platforms[0]] - any_whl = select_whl( - whls = candidates, - python_version = platform.env.get("python_full_version", "3"), - whl_platform_tags = ["any"], - whl_abi_tags = ["none"], - implementation_name = platform.env.get("implementation_name", "cpython"), - limit = 1, - logger = logger, - ) - if any_whl: - entry["any_srcs"][any_whl.filename + any_whl.digest] = struct( - distribution = name, - extra_pip_args = extra_pip_args or [], - requirement_line = "{name}{extras}=={version}".format( - name = name, - extras = extra_str, - version = version, - ), - target_platforms = [], - filename = any_whl.filename, - digest = any_whl.digest, - url = any_whl.url, - yanked = None, - ) - plat_to_src = {} for p in pkg_platforms: platform = platforms.get(p) @@ -407,7 +368,7 @@ for src in info["resolved_srcs"]: for p in src.target_platforms: resolved_platforms[p] = None - item = dict( + item = struct( name = norm_name, # Only expose packages that resolved on all configured platforms. # Workspace/root members (e.g. `source = { virtual = "." }` or @@ -423,11 +384,7 @@ index_url = info["index_url"], srcs = info["resolved_srcs"], ) - if any_src: - # The platform independent wheel, if there is exactly one. - any_srcs = info["any_srcs"].values() - item["any_src"] = any_srcs[0] if len(any_srcs) == 1 else None - ret.append(struct(**item)) + ret.append(item) logger.debug(lambda: "Parsed {} packages from uv.lock".format(len(ret))) return ret
diff --git a/tests/pypi/hub_builder/hub_builder_tests.bzl b/tests/pypi/hub_builder/hub_builder_tests.bzl index 2470cf7..0a5c319 100644 --- a/tests/pypi/hub_builder/hub_builder_tests.bzl +++ b/tests/pypi/hub_builder/hub_builder_tests.bzl
@@ -183,25 +183,7 @@ os_name = "osx", arch_name = "aarch64", mock_files = { - "uv.lock": json.encode({"package": [ - { - "name": "plat", - "source": {"registry": "https://pypi.org/simple"}, - "version": "0.0.1", - "wheels": [ - {"hash": "sha256:deadb00f", "url": "https://files.pythonhosted.org/packages/plat-0.0.1-cp315-cp315-manylinux_2_17_x86_64.whl"}, - {"hash": "sha256:deadbeef", "url": "https://files.pythonhosted.org/packages/plat-0.0.1-py3-none-any.whl"}, - ], - }, - { - "name": "platonly", - "source": {"registry": "https://pypi.org/simple"}, - "version": "0.0.1", - "wheels": [ - {"hash": "sha256:deadbaaf", "url": "https://files.pythonhosted.org/packages/platonly-0.0.1-cp315-cp315-manylinux_2_17_x86_64.whl"}, - ], - }, - ]}), + "uv.lock": """{"package":[{"name":"simple","source":{"registry":"https://pypi.org/simple"},"version":"0.0.1","wheels":[{"hash":"sha256:deadbeef","url":"https://files.pythonhosted.org/packages/simple-0.0.1-py3-none-any.whl"}]}]}""", }, ), _parse( @@ -214,39 +196,20 @@ ) pypi = builder.build() - # Only the packages that are available on all of the platforms are exposed. - pypi.exposed_packages().contains_exactly(["plat"]) + pypi.exposed_packages().contains_exactly(["simple"]) pypi.whl_map().contains_exactly({ - "plat": { - "pypi_315_plat_cp315_cp315_manylinux_2_17_x86_64_deadb00f": [ - whl_config_setting( - target_platforms = ("cp315_linux_x86_64",), - version = "3.15", - ), - ], - "pypi_315_plat_py3_none_any_deadbeef": [ + "simple": { + "pypi_315_simple_py3_none_any_deadbeef": [ whl_config_setting( target_platforms = ( "cp315_linux_aarch64", + "cp315_linux_x86_64", "cp315_linux_x86_64_freethreaded", "cp315_osx_aarch64", "cp315_windows_aarch64", ), version = "3.15", ), - # The fallback for the platforms that are not configured. - whl_config_setting( - version = "3.15", - ), - ], - }, - # There is no platform independent wheel, so there is no fallback. - "platonly": { - "pypi_315_platonly_cp315_cp315_manylinux_2_17_x86_64_deadbaaf": [ - whl_config_setting( - target_platforms = ("cp315_linux_x86_64",), - version = "3.15", - ), ], }, })