diff --git a/okonomiyaki/platforms/epd_platform.py b/okonomiyaki/platforms/epd_platform.py
index 441712a..d32d37a 100644
--- a/okonomiyaki/platforms/epd_platform.py
+++ b/okonomiyaki/platforms/epd_platform.py
@@ -172,20 +172,16 @@ def _guess_architecture():
     """
     Returns the architecture of the running python.
     """
-    x86 = "x86"
-    amd64 = "amd64"
-    bits = platform.architecture()[0]
     machine = platform.machine()
-    if machine in ("AMD64", "x86_64"):
-        if bits == "32bit":
-            return x86
-        elif bits == "64bit":
-            return amd64
-    elif machine in ("x86", "i386", "i686") and bits == "32bit":
-        return x86
+
+    if machine in ("AMD64", "x86_64", "x86", "i386", "i686"):
+        if sys.maxsize > 2 ** 32:
+            return "amd64"
+        else:
+            return "x86"
     else:
-        raise OkonomiyakiError("Unknown bits/machine combination {0}/{1}".
-                               format(bits, machine))
+        raise OkonomiyakiError("Unknown machine combination {0!r}".
+                               format(machine))
 
 
 def _guess_epd_platform(arch=None):
diff --git a/okonomiyaki/platforms/platform.py b/okonomiyaki/platforms/platform.py
index bb20a39..f5db84f 100644
--- a/okonomiyaki/platforms/platform.py
+++ b/okonomiyaki/platforms/platform.py
@@ -3,6 +3,8 @@ from __future__ import absolute_import
 import platform
 import sys
 
+from okonomiyaki.platforms import epd_platform
+
 from okonomiyaki.bundled.traitlets import HasTraits, Enum, Instance, Unicode
 from okonomiyaki.platforms.epd_platform import EPDPlatform
 from okonomiyaki.errors import OkonomiyakiError
@@ -200,18 +202,14 @@ def _guess_architecture():
     """
     Returns the architecture of the running python.
     """
-    bits = platform.architecture()[0]
-    machine = platform.machine()
-    if machine in ("AMD64", "x86_64"):
-        if bits == "32bit":
-            return Arch.from_name(X86)
-        elif bits == "64bit":
-            return Arch.from_name(X86_64)
-    elif machine in ("x86", "i386", "i686") and bits == "32bit":
+    epd_platform_arch = epd_platform._guess_architecture()
+    if epd_platform_arch == "x86":
         return Arch.from_name(X86)
+    elif epd_platform_arch == "amd64":
+        return Arch.from_name(X86_64)
     else:
-        raise OkonomiyakiError("Unknown bits/machine combination {0}/{1}".
-                               format(bits, machine))
+        raise OkonomiyakiError("Unknown architecture {0!r}".
+                               format(epd_platform_arch))
 
 
 def _guess_machine():

Fix platform guessing on 64 bits processes on 32 bits kernel
See #31 
diff --git a/okonomiyaki/platforms/tests/common.py b/okonomiyaki/platforms/tests/common.py
index b7ff851..8eb942b 100644
--- a/okonomiyaki/platforms/tests/common.py
+++ b/okonomiyaki/platforms/tests/common.py
@@ -63,14 +63,12 @@ mock_osx_10_7 = MultiPatcher([
 # Architecture mocking
 mock_machine = lambda machine: Patcher(mock.patch("platform.machine",
                                                   lambda: machine))
-mock_architecture = lambda arch: Patcher(mock.patch("platform.architecture",
-                                                    lambda: arch))
 
 mock_machine_x86 = Patcher(mock_machine("x86"))
-mock_architecture_32bit = Patcher(mock_architecture(("32bit",)))
+mock_architecture_32bit = Patcher(mock.patch("sys.maxsize", 2**32-1))
 
 mock_machine_x86_64 = Patcher(mock_machine("x86_64"))
-mock_architecture_64bit = Patcher(mock_architecture(("64bit",)))
+mock_architecture_64bit = Patcher(mock.patch("sys.maxsize", 2**64-1))
 
 mock_x86 = MultiPatcher([mock_machine_x86, mock_architecture_32bit])
 mock_x86_64 = MultiPatcher([mock_machine_x86_64, mock_architecture_64bit])
diff --git a/okonomiyaki/platforms/tests/test_epd_platform.py b/okonomiyaki/platforms/tests/test_epd_platform.py
index edb27a8..9cf711f 100644
--- a/okonomiyaki/platforms/tests/test_epd_platform.py
+++ b/okonomiyaki/platforms/tests/test_epd_platform.py
@@ -8,9 +8,12 @@ from okonomiyaki.platforms.epd_platform import (_guess_architecture,
                                                 _guess_epd_platform, applies)
 from okonomiyaki.platforms.legacy import _SUBDIR
 
-from .common import (mock_centos_3_5, mock_centos_5_8, mock_centos_6_3,
-                     mock_darwin, mock_machine_armv71, mock_solaris,
-                     mock_ubuntu_raring, mock_windows, mock_x86, mock_x86_64)
+from .common import (mock_architecture_32bit, mock_architecture_64bit,
+                     mock_centos_3_5, mock_centos_5_8, mock_centos_6_3,
+                     mock_darwin, mock_machine_x86, mock_machine_x86_64,
+                     mock_machine_armv71, mock_solaris,
+                     mock_ubuntu_raring, mock_windows, mock_x86,
+                     mock_x86_64)
 
 
 class TestEPDPlatform(unittest.TestCase):
@@ -94,12 +97,52 @@ class TestGuessEPDPlatform(unittest.TestCase):
 
     @mock_darwin
     def test_guess_darwin_platform(self):
-        epd_platform = _guess_epd_platform("x86")
+        # When
+        with mock_machine_x86:
+            epd_platform = _guess_epd_platform("x86")
+
+        # Then
         self.assertEqual(epd_platform.short, "osx-32")
 
-        epd_platform = _guess_epd_platform("amd64")
+        # When
+        with mock_machine_x86:
+            epd_platform = _guess_epd_platform("amd64")
+
+        # Then
+        self.assertEqual(epd_platform.short, "osx-64")
+
+        # When
+        with mock_machine_x86:
+            with mock_architecture_32bit:
+                epd_platform = _guess_epd_platform()
+
+        # Then
+        self.assertEqual(epd_platform.short, "osx-32")
+
+        # When
+        with mock_machine_x86:
+            with mock_architecture_64bit:
+                epd_platform = _guess_epd_platform()
+
+        # Then
         self.assertEqual(epd_platform.short, "osx-64")
 
+        # When
+        with mock_machine_x86_64:
+            with mock_architecture_64bit:
+                epd_platform = _guess_epd_platform()
+
+        # Then
+        self.assertEqual(epd_platform.short, "osx-64")
+
+        # When
+        with mock_machine_x86_64:
+            with mock_architecture_32bit:
+                epd_platform = _guess_epd_platform()
+
+        # Then
+        self.assertEqual(epd_platform.short, "osx-32")
+
     def test_guess_linux2_platform(self):
         with mock_centos_5_8:
             epd_platform = _guess_epd_platform("x86")
@@ -109,27 +152,27 @@ class TestGuessEPDPlatform(unittest.TestCase):
             self.assertEqual(epd_platform.short, "rh5-64")
 
             with mock.patch("platform.machine", lambda: "x86"):
-                with mock.patch("platform.architecture", lambda: ("32bit",)):
+                with mock_architecture_32bit:
                     epd_platform = _guess_epd_platform()
                     self.assertEqual(epd_platform.short, "rh5-32")
 
             with mock.patch("platform.machine", lambda: "i386"):
-                with mock.patch("platform.architecture", lambda: ("32bit",)):
+                with mock_architecture_32bit:
                     epd_platform = _guess_epd_platform()
                     self.assertEqual(epd_platform.short, "rh5-32")
 
             with mock.patch("platform.machine", lambda: "i686"):
-                with mock.patch("platform.architecture", lambda: ("32bit",)):
+                with mock_architecture_32bit:
                     epd_platform = _guess_epd_platform()
                     self.assertEqual(epd_platform.short, "rh5-32")
 
             with mock.patch("platform.machine", lambda: "x86_64"):
-                with mock.patch("platform.architecture", lambda: ("32bit",)):
+                with mock_architecture_32bit:
                     epd_platform = _guess_epd_platform()
                     self.assertEqual(epd_platform.short, "rh5-32")
 
             with mock.patch("platform.machine", lambda: "x86_64"):
-                with mock.patch("platform.architecture", lambda: ("64bit",)):
+                with mock_architecture_64bit:
                     epd_platform = _guess_epd_platform()
                     self.assertEqual(epd_platform.short, "rh5-64")
 

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest
3.7
dev_requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
certifi @ file:///croot/certifi_1671487769961/work/certifi
coverage==7.2.7
docutils==0.20.1
enum34==1.1.10
exceptiongroup==1.2.2
flake8==5.0.4
haas==0.9.0
importlib-metadata==4.2.0
iniconfig==2.0.0
mccabe==0.7.0
mock==5.2.0
-e git+https://github.com/enthought/okonomiyaki.git@d32923ad74059883e31aaed8c12d3cd5e0288acd#egg=okonomiyaki
packaging==24.0
pbr==6.1.1
pluggy==1.2.0
pycodestyle==2.9.1
pyflakes==2.5.0
pytest==7.4.4
six==1.17.0
statistics==1.0.3.5
stevedore==3.5.2
tomli==2.0.1
typing_extensions==4.7.1
zipp==3.15.0

name: okonomiyaki
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2022.12.7=py37h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=22.3.1=py37h06a4308_0
  - python=3.7.16=h7a1cb2a_0
  - readline=8.2=h5eee18b_0
  - setuptools=65.6.3=py37h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.38.4=py37h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - coverage==7.2.7
      - docutils==0.20.1
      - enum34==1.1.10
      - exceptiongroup==1.2.2
      - flake8==5.0.4
      - haas==0.9.0
      - importlib-metadata==4.2.0
      - iniconfig==2.0.0
      - mccabe==0.7.0
      - mock==5.2.0
      - packaging==24.0
      - pbr==6.1.1
      - pluggy==1.2.0
      - pycodestyle==2.9.1
      - pyflakes==2.5.0
      - pytest==7.4.4
      - six==1.17.0
      - statistics==1.0.3.5
      - stevedore==3.5.2
      - tomli==2.0.1
      - typing-extensions==4.7.1
      - zipp==3.15.0
prefix: /opt/conda/envs/okonomiyaki

okonomiyaki/platforms/tests/test_epd_platform.py::TestEPDPlatformApplies::test_all okonomiyaki/platforms/tests/test_epd_platform.py::TestEPDPlatformApplies::test_current_linux okonomiyaki/platforms/tests/test_epd_platform.py::TestEPDPlatformApplies::test_current_windows okonomiyaki/platforms/tests/test_epd_platform.py::TestGuessEPDPlatform::test_guess_darwin_platform okonomiyaki/platforms/tests/test_epd_platform.py::TestGuessEPDPlatform::test_guess_linux2_platform
okonomiyaki/platforms/tests/test_epd_platform.py::TestEPDPlatform::test_epd_platform_from_string okonomiyaki/platforms/tests/test_epd_platform.py::TestEPDPlatform::test_guessed_epd_platform okonomiyaki/platforms/tests/test_epd_platform.py::TestEPDPlatform::test_short_names_consistency okonomiyaki/platforms/tests/test_epd_platform.py::TestEPDPlatformApplies::test_applies_rh okonomiyaki/platforms/tests/test_epd_platform.py::TestGuessEPDPlatform::test_guess_linux2_unsupported okonomiyaki/platforms/tests/test_epd_platform.py::TestGuessEPDPlatform::test_guess_solaris_unsupported okonomiyaki/platforms/tests/test_epd_platform.py::TestGuessEPDPlatform::test_guess_unsupported_processor okonomiyaki/platforms/tests/test_epd_platform.py::TestGuessEPDPlatform::test_guess_win32_platform
okonomiyaki/platforms/platform.py okonomiyaki/platforms/epd_platform.py
okonomiyaki/platforms/platform.py okonomiyaki/platforms/epd_platform.py