XBMC System Architecture query
#16
I use this, seems to work fine:
Code:
is_64bits = sys.maxsize > 2**32
Addons I wrote &/or maintain:
OzWeather (Australian BOM weather) | Check Previous Episode | Playback Resumer | Unpause Jumpback | XSqueezeDisplay | (Legacy - XSqueeze & XZen)
Sorry, no help w/out a *full debug log*.
Reply
#17
(2013-01-06, 11:37)bossanova808 Wrote: I use this, seems to work fine:
Code:
is_64bits = sys.maxsize > 2**32

I can confirm that, on my Win7 64bit with 32bit Python, is_64bits becomes True.
My GitHub. My Add-ons:
Image
Reply
#18
hmm.. on 32bit also working.
PHP Code:
>>> import sys
>>> sys.maxsize 2**32
False
>>> sys.maxsize
2147483647
>>> print 0xffffffff
4294967295
>>> print 0xffffffff 2
2147483647
>>> print 0xffffffff 2**32
False 
Reply
#19
Tip: You could check how SpotiMC does this, it also needs to load different libraries (libspotify) based on platform.

PHP Code:
import structossysplatform
from __main__ import __addon_path__


def get_platform
():
    if 
sys.platform.startswith('linux'):
        return 
'linux'
    
    
elif os.name == 'nt':
        return 
'windows'
    
    
#TODO: Identify ios and osx properly
    
elif sys.platform == 'darwin':
        return 
'osx'
    
    
#Fail if platform cannot be determined
    
else:
        
raise OSError('Platform not supported')


def get_architecture():
    try:
        
machine platform.machine()
        
        
#Some filtering...
        
if machine.startswith('armv6'):
            return 
'armv6'
        
        
elif machine.startswith('i686'):
            return 
'x86'
    
    
except:
        return 
None


def add_library_path
(path):
    
#Build the full path and publish it
    
full_path os.path.join(__addon_path__path)
    
sys.path.append(full_path)


def set_library_paths(base_dir):
    
platform_str get_platform()
    
arch_str get_architecture()
    
    if 
platform_str == 'linux':
        if 
arch_str in(None'x86'):
            
add_library_path(os.path.join(base_dir'linux/x86'))
        
        if 
arch_str in(None'x86_64'):
            
add_library_path(os.path.join(base_dir'linux/x86_64'))
        
        if 
arch_str in(None'armv6'):
            
add_library_path(os.path.join(base_dir'linux/armv6'))
    
    
elif platform_str == 'windows':
        if 
arch_str in(None'x86'):
            
add_library_path(os.path.join(base_dir'windows/x86'))
    
    
elif platform_str == 'osx':
        
add_library_path(os.path.join(base_dir'osx')) 

It is not ideal but it works for all libraries currently supported Wink
Reply

Logout Mark Read Team Forum Stats Members Help
XBMC System Architecture query0