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: platform tag for GraalPy #711

Merged
merged 3 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 2 additions & 1 deletion src/packaging/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import logging
import platform
import struct
import subprocess
import sys
import sysconfig
Expand Down Expand Up @@ -37,7 +38,7 @@
}


_32_BIT_INTERPRETER = sys.maxsize <= 2**32
_32_BIT_INTERPRETER = struct.calcsize("P") == 4
brettcannon marked this conversation as resolved.
Show resolved Hide resolved


class Tag:
Expand Down
28 changes: 28 additions & 0 deletions tests/test_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
import ctypes
except ImportError:
ctypes = None
import importlib
import os
import pathlib
import platform
import struct
import sys
import sysconfig
import types
Expand Down Expand Up @@ -1341,3 +1343,29 @@ def test_cpython_first_none_any_tag(self, monkeypatch):

interpreter = f"cp{tags.interpreter_version()}"
assert tag == tags.Tag(interpreter, "none", "any")


class TestBitness:
def teardown_method(self):
importlib.reload(tags)

@pytest.mark.parametrize(
"maxsize, sizeof_voidp, expected",
[
# CPython, PyPy, pyston 64bit
(9223372036854775807, 8, False),
# GraalPy, IronPython, Jython 64bit
(2147483647, 8, False),
# CPython, PyPy, IronPython, Jython, pyodide 32bit
(2147483647, 4, True),
brettcannon marked this conversation as resolved.
Show resolved Hide resolved
],
)
def test_32bit_interpreter(self, maxsize, sizeof_voidp, expected, monkeypatch):
def _calcsize(fmt):
assert fmt == "P"
return sizeof_voidp

monkeypatch.setattr(sys, "maxsize", maxsize)
monkeypatch.setattr(struct, "calcsize", _calcsize)
importlib.reload(tags)
assert tags._32_BIT_INTERPRETER == expected