Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(pypi): use host micro version instead of a constant #2525

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions python/private/pypi/whl_installer/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ def host_interpreter_minor_version() -> int:
return sys.version_info.minor


def host_interpreter_micro_version() -> int:
return sys.version_info.micro


@dataclass(frozen=True)
class Platform:
os: Optional[OS] = None
Expand Down Expand Up @@ -281,6 +285,13 @@ def platform_machine(self) -> str:
def env_markers(self, extra: str) -> Dict[str, str]:
# If it is None, use the host version
minor_version = self.minor_version or host_interpreter_minor_version()
# NOTE: We use the `micro_version` from the current interpreter, which
# currently works around
# https://github.com/bazelbuild/rules_python/issues/2319
#
# If we wanted to pass it to this function then we would have a combinatorial
# explosion.
micro_version = host_interpreter_micro_version()

return {
"extra": extra,
Expand All @@ -291,11 +302,8 @@ def env_markers(self, extra: str) -> Dict[str, str]:
"platform_release": "", # unset
"platform_version": "", # unset
"python_version": f"3.{minor_version}",
# FIXME @aignas 2024-01-14: is putting zero last a good idea? Maybe we should
# use `20` or something else to avoid having weird issues where the full version is used for
# matching and the author decides to only support 3.y.5 upwards.
"implementation_version": f"3.{minor_version}.0",
"python_full_version": f"3.{minor_version}.0",
"implementation_version": f"3.{minor_version}.{micro_version}",
"python_full_version": f"3.{minor_version}.{micro_version}",
# we assume that the following are the same as the interpreter used to setup the deps:
# "implementation_name": "cpython"
# "platform_python_implementation: "CPython",
Expand Down