Skip to content

Commit

Permalink
New method finding correct "cpu" sting
Browse files Browse the repository at this point in the history
Except of using the platform.architecture for the check, I'm using the platform.machine output to check for the cpu detection.
I'm not sure about different outputs on other devices, eg. different ARM versions, so added a dictionary which translates these strings to the correct one found in <jre_home>/lib/*.
In case a platform.machine output is unknown to the dictionary, the code will fall back to i386 like the old code and warn the user about that. A missing translation can be easily added to the dictionary to support other platforms.

WARNING: This commit is untested and was coded via github webpage.
  • Loading branch information
thopiekar committed Nov 19, 2015
1 parent f2e6666 commit c999bb3
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from os import environ
from os.path import dirname, join, exists
import sys
from platform import architecture
from platform import machine

PY3 = sys.version_info >= (3,0,0)

Expand Down Expand Up @@ -110,8 +110,20 @@ def getenv(key):
shell=True, stdout=subprocess.PIPE).communicate()[0].strip()
if not jre_home:
raise Exception('Unable to determine JRE_HOME')
cpu = 'amd64' if architecture()[0] == '64bit' else 'i386'


# This dictionary converts values from platform.machine() to a "cpu" string.
# It is needed to set the correct lib path, found in the jre_home, eg. <jre_home>/lib/<cpu>/.
machine2cpu = {"i686" : "i386"
"x86_64" : "amd64",
"armv7l" : "arm"
}
if machine() in machine2cpu.keys():
cpu = machine2cpu[machine()]
else:
print("WARNING: Not able to assign machine() = %s to a cpu value!" %(machine()))
print(" Using cpu = 'i386' instead!")
cpu = 'i386'

if platform == 'win32':
incl_dir = join(jdk_home, 'include', 'win32')
libraries = ['jvm']
Expand Down

0 comments on commit c999bb3

Please sign in to comment.