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

Centralize system checks to one method and rework RenvBuilder around this idea. #47

Open
grabear opened this issue Mar 21, 2019 · 7 comments

Comments

@grabear
Copy link
Member

grabear commented Mar 21, 2019

Instead of making system calls throughout various methods in the class, create a function (utils.get_sys_info or something) that will return system information. Based on a brief scan, this is what RenvBuilder uses in it's logic flow to determine system information, and therefore folder names etct.:

  • image

  • image

  • image

operating system

We are currently working with linux so it would be good to throw an error if os.name returns anything other than posix.

platform

Linux (and Cygwin?) vs Windows vs Mac installs look very different. Throw an error for darwin, and win32 (and cygwin?).

size (32 vs 64 bit platforms)

On Linux machines 32 vs 64 installs look different. Mainly, 32 bit systems use "lib" and 64 bit systems use "lib64". Windows filesystems are much different. I don't know the difference between 32 and 64 bit on windows.

import os
import sys

if os.name == "posix":
    if sys.platform in ["linux", "cygwin"]:
        # do stuff
        # do stuff
        if sys.maxsize > 2**32:
            _lib = "lib64"
        else:
            _lib = "lib"
else: 
    raise OSError
@grabear
Copy link
Member Author

grabear commented Mar 21, 2019

#43

@sdhutchins
Copy link
Member

That's perfect. I actually added a catch for that in one of my branches (sys.platform).

@sdhutchins
Copy link
Member

Also, perhaps we could consider throwing a Warning instead of an error for mac.

@sdhutchins
Copy link
Member

import os
import sys

def check_os():
    if os.name == "posix":
        if sys.platform in ["linux", "cygwin"]:
            if sys.maxsize > 2**32:
                _lib = "lib64"
            else:
                _lib = "lib"
            return _lib
    else: 
        raise OSError

@sdhutchins
Copy link
Member

Even less lines:

import os
import sys


def check_os():
    if os.name == "posix":
        if sys.platform in ["linux", "cygwin"] and sys.maxsize == 2**63-1:
            _lib = "lib64"
        elif sys.platform in ["linux", "cygwin"] and sys.maxsize == 2**31-1:
            _lib = "lib"
        return _lib
    else: 
        raise OSError

@grabear
Copy link
Member Author

grabear commented Mar 21, 2019

I like it @sdhutchins. Whenever we get to this, the best thing we can do is think forward...

How can we set up our code so that integrating windows/Mac is easy?
We can help do this with #43 as well.

@santina
Copy link
Collaborator

santina commented Mar 31, 2019

You can also do this: https://kite.com/python/examples/4187/platform-check-if-the-system-is-32-bit-or-64-bit
'
import platform
print platform.architecture()[0] == "32bit"
'
Looks better than hard coding value and have Python calculating 2**63

@BrunoGrandePhD BrunoGrandePhD removed their assignment Jun 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants