Example #1
0
    def test_platform_in_subprocess(self):
        my_platform = sysconfig.get_platform()

        # Test without MACOSX_DEPLOYMENT_TARGET in the environment

        env = os.environ.copy()
        if 'MACOSX_DEPLOYMENT_TARGET' in env:
            del env['MACOSX_DEPLOYMENT_TARGET']

        with open('/dev/null', 'w') as devnull_fp:
            p = subprocess.Popen([
                    sys.executable, '-c',
                    'from distlib._backport import sysconfig; '
                    'print(sysconfig.get_platform())',
                ],
                stdout=subprocess.PIPE,
                stderr=devnull_fp,
                env=env)
        test_platform = p.communicate()[0].strip()
        test_platform = test_platform.decode('utf-8')
        status = p.wait()

        self.assertEqual(status, 0)
        self.assertEqual(my_platform, test_platform)

        # Test with MACOSX_DEPLOYMENT_TARGET in the environment, and
        # using a value that is unlikely to be the default one.
        env = os.environ.copy()
        env['MACOSX_DEPLOYMENT_TARGET'] = '10.1'

        with open('/dev/null') as dev_null:
            p = subprocess.Popen([
                    sys.executable, '-c',
                    'from distlib._backport import sysconfig; '
                    'print(sysconfig.get_platform())',
                ],
                stdout=subprocess.PIPE,
                stderr=dev_null,
                env=env)
            test_platform = p.communicate()[0].strip()
            test_platform = test_platform.decode('utf-8')
            status = p.wait()

            self.assertEqual(status, 0)
            self.assertEqual(my_platform, test_platform)
Example #2
0
    def test_platform_in_subprocess(self):
        my_platform = sysconfig.get_platform()

        # Test without MACOSX_DEPLOYMENT_TARGET in the environment

        env = os.environ.copy()
        if "MACOSX_DEPLOYMENT_TARGET" in env:
            del env["MACOSX_DEPLOYMENT_TARGET"]

        with open("/dev/null", "w") as devnull_fp:
            p = subprocess.Popen(
                [sys.executable, "-c", "from distlib._backport import sysconfig; " "print(sysconfig.get_platform())"],
                stdout=subprocess.PIPE,
                stderr=devnull_fp,
                env=env,
            )
        test_platform = p.communicate()[0].strip()
        test_platform = test_platform.decode("utf-8")
        status = p.wait()

        self.assertEqual(status, 0)
        self.assertEqual(my_platform, test_platform)

        # Test with MACOSX_DEPLOYMENT_TARGET in the environment, and
        # using a value that is unlikely to be the default one.
        env = os.environ.copy()
        env["MACOSX_DEPLOYMENT_TARGET"] = "10.1"

        with open("/dev/null") as dev_null:
            p = subprocess.Popen(
                [sys.executable, "-c", "from distlib._backport import sysconfig; " "print(sysconfig.get_platform())"],
                stdout=subprocess.PIPE,
                stderr=dev_null,
                env=env,
            )
            test_platform = p.communicate()[0].strip()
            test_platform = test_platform.decode("utf-8")
            status = p.wait()

            self.assertEqual(status, 0)
            self.assertEqual(my_platform, test_platform)
Example #3
0
    def test_get_platform(self):

        # get_config_vars() needs to be called before messing with
        # the variables as we do below. Otherwise, when we call
        # get_config_vars() below AFTER changing os.name to 'posix',
        # we'll get a failure because _init_posix() will get called
        # and look for a Makefile - which will not work on Windows :-(
        #
        # With the call to get_config_vars() here while os.name is still
        # 'nt', we call _init_non_posix(), _CONFIG_VARS is set up OK,
        # and so _init_posix() never gets called on Windows.
        get_config_vars()

        # windows XP, 32bits
        os.name = "nt"
        sys.version = "2.4.4 (#71, Oct 18 2006, 08:34:43) " "[MSC v.1310 32 bit (Intel)]"
        sys.platform = "win32"
        self.assertEqual(get_platform(), "win32")

        # windows XP, amd64
        os.name = "nt"
        sys.version = "2.4.4 (#71, Oct 18 2006, 08:34:43) " "[MSC v.1310 32 bit (Amd64)]"
        sys.platform = "win32"
        self.assertEqual(get_platform(), "win-amd64")

        # windows XP, itanium
        os.name = "nt"
        sys.version = "2.4.4 (#71, Oct 18 2006, 08:34:43) " "[MSC v.1310 32 bit (Itanium)]"
        sys.platform = "win32"
        self.assertEqual(get_platform(), "win-ia64")

        # macbook
        os.name = "posix"
        sys.version = "2.5 (r25:51918, Sep 19 2006, 08:49:13) " "\n[GCC 4.0.1 (Apple Computer, Inc. build 5341)]"
        sys.platform = "darwin"
        self._set_uname(
            (
                "Darwin",
                "macziade",
                "8.11.1",
                ("Darwin Kernel Version 8.11.1: " "Wed Oct 10 18:23:28 PDT 2007; " "root:xnu-792.25.20~1/RELEASE_I386"),
                "PowerPC",
            )
        )
        get_config_vars()["MACOSX_DEPLOYMENT_TARGET"] = "10.3"

        get_config_vars()["CFLAGS"] = "-fno-strict-aliasing -DNDEBUG -g " "-fwrapv -O3 -Wall -Wstrict-prototypes"

        maxint = sys.maxsize
        try:
            sys.maxsize = 2147483647
            self.assertEqual(get_platform(), "macosx-10.3-ppc")
            sys.maxsize = 9223372036854775807
            self.assertEqual(get_platform(), "macosx-10.3-ppc64")
        finally:
            sys.maxsize = maxint

        self._set_uname(
            (
                "Darwin",
                "macziade",
                "8.11.1",
                ("Darwin Kernel Version 8.11.1: " "Wed Oct 10 18:23:28 PDT 2007; " "root:xnu-792.25.20~1/RELEASE_I386"),
                "i386",
            )
        )
        get_config_vars()["MACOSX_DEPLOYMENT_TARGET"] = "10.3"
        get_config_vars()["MACOSX_DEPLOYMENT_TARGET"] = "10.3"

        get_config_vars()["CFLAGS"] = "-fno-strict-aliasing -DNDEBUG -g " "-fwrapv -O3 -Wall -Wstrict-prototypes"
        maxint = sys.maxsize
        try:
            sys.maxsize = 2147483647
            self.assertEqual(get_platform(), "macosx-10.3-i386")
            sys.maxsize = 9223372036854775807
            self.assertEqual(get_platform(), "macosx-10.3-x86_64")
        finally:
            sys.maxsize = maxint

        # macbook with fat binaries (fat, universal or fat64)
        get_config_vars()["MACOSX_DEPLOYMENT_TARGET"] = "10.4"
        get_config_vars()["CFLAGS"] = (
            "-arch ppc -arch i386 -isysroot "
            "/Developer/SDKs/MacOSX10.4u.sdk  "
            "-fno-strict-aliasing -fno-common "
            "-dynamic -DNDEBUG -g -O3"
        )

        self.assertEqual(get_platform(), "macosx-10.4-fat")

        get_config_vars()["CFLAGS"] = (
            "-arch x86_64 -arch i386 -isysroot "
            "/Developer/SDKs/MacOSX10.4u.sdk  "
            "-fno-strict-aliasing -fno-common "
            "-dynamic -DNDEBUG -g -O3"
        )

        self.assertEqual(get_platform(), "macosx-10.4-intel")

        get_config_vars()["CFLAGS"] = (
            "-arch x86_64 -arch ppc -arch i386 -isysroot "
            "/Developer/SDKs/MacOSX10.4u.sdk  "
            "-fno-strict-aliasing -fno-common "
            "-dynamic -DNDEBUG -g -O3"
        )
        self.assertEqual(get_platform(), "macosx-10.4-fat3")

        get_config_vars()["CFLAGS"] = (
            "-arch ppc64 -arch x86_64 -arch ppc -arch i386 -isysroot "
            "/Developer/SDKs/MacOSX10.4u.sdk  "
            "-fno-strict-aliasing -fno-common "
            "-dynamic -DNDEBUG -g -O3"
        )
        self.assertEqual(get_platform(), "macosx-10.4-universal")

        get_config_vars()["CFLAGS"] = (
            "-arch x86_64 -arch ppc64 -isysroot "
            "/Developer/SDKs/MacOSX10.4u.sdk  "
            "-fno-strict-aliasing -fno-common "
            "-dynamic -DNDEBUG -g -O3"
        )

        self.assertEqual(get_platform(), "macosx-10.4-fat64")

        for arch in ("ppc", "i386", "x86_64", "ppc64"):
            get_config_vars()["CFLAGS"] = (
                "-arch %s -isysroot "
                "/Developer/SDKs/MacOSX10.4u.sdk  "
                "-fno-strict-aliasing -fno-common "
                "-dynamic -DNDEBUG -g -O3" % arch
            )

            self.assertEqual(get_platform(), "macosx-10.4-%s" % arch)

        # linux debian sarge
        os.name = "posix"
        sys.version = "2.3.5 (#1, Jul  4 2007, 17:28:59) " "\n[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)]"
        sys.platform = "linux2"
        self._set_uname(("Linux", "aglae", "2.6.21.1dedibox-r7", "#1 Mon Apr 30 17:25:38 CEST 2007", "i686"))

        self.assertEqual(get_platform(), "linux-i686")
Example #4
0
    def test_get_platform(self):

        # get_config_vars() needs to be called before messing with
        # the variables as we do below. Otherwise, when we call
        # get_config_vars() below AFTER changing os.name to 'posix',
        # we'll get a failure because _init_posix() will get called
        # and look for a Makefile - which will not work on Windows :-(
        #
        # With the call to get_config_vars() here while os.name is still
        # 'nt', we call _init_non_posix(), _CONFIG_VARS is set up OK,
        # and so _init_posix() never gets called on Windows.
        get_config_vars()

        # windows XP, 32bits
        os.name = 'nt'
        sys.version = ('2.4.4 (#71, Oct 18 2006, 08:34:43) '
                       '[MSC v.1310 32 bit (Intel)]')
        sys.platform = 'win32'
        self.assertEqual(get_platform(), 'win32')

        # windows XP, amd64
        os.name = 'nt'
        sys.version = ('2.4.4 (#71, Oct 18 2006, 08:34:43) '
                       '[MSC v.1310 32 bit (Amd64)]')
        sys.platform = 'win32'
        self.assertEqual(get_platform(), 'win-amd64')

        # windows XP, itanium
        os.name = 'nt'
        sys.version = ('2.4.4 (#71, Oct 18 2006, 08:34:43) '
                       '[MSC v.1310 32 bit (Itanium)]')
        sys.platform = 'win32'
        self.assertEqual(get_platform(), 'win-ia64')

        # macbook
        os.name = 'posix'
        sys.version = ('2.5 (r25:51918, Sep 19 2006, 08:49:13) '
                       '\n[GCC 4.0.1 (Apple Computer, Inc. build 5341)]')
        sys.platform = 'darwin'
        self._set_uname(('Darwin', 'macziade', '8.11.1',
                   ('Darwin Kernel Version 8.11.1: '
                    'Wed Oct 10 18:23:28 PDT 2007; '
                    'root:xnu-792.25.20~1/RELEASE_I386'), 'PowerPC'))
        get_config_vars()['MACOSX_DEPLOYMENT_TARGET'] = '10.3'

        get_config_vars()['CFLAGS'] = ('-fno-strict-aliasing -DNDEBUG -g '
                                       '-fwrapv -O3 -Wall -Wstrict-prototypes')

        maxint = sys.maxsize
        try:
            sys.maxsize = 2147483647
            self.assertEqual(get_platform(), 'macosx-10.3-ppc')
            sys.maxsize = 9223372036854775807
            self.assertEqual(get_platform(), 'macosx-10.3-ppc64')
        finally:
            sys.maxsize = maxint

        self._set_uname(('Darwin', 'macziade', '8.11.1',
                   ('Darwin Kernel Version 8.11.1: '
                    'Wed Oct 10 18:23:28 PDT 2007; '
                    'root:xnu-792.25.20~1/RELEASE_I386'), 'i386'))
        get_config_vars()['MACOSX_DEPLOYMENT_TARGET'] = '10.3'
        get_config_vars()['MACOSX_DEPLOYMENT_TARGET'] = '10.3'

        get_config_vars()['CFLAGS'] = ('-fno-strict-aliasing -DNDEBUG -g '
                                       '-fwrapv -O3 -Wall -Wstrict-prototypes')
        maxint = sys.maxsize
        try:
            sys.maxsize = 2147483647
            self.assertEqual(get_platform(), 'macosx-10.3-i386')
            sys.maxsize = 9223372036854775807
            self.assertEqual(get_platform(), 'macosx-10.3-x86_64')
        finally:
            sys.maxsize = maxint

        # macbook with fat binaries (fat, universal or fat64)
        get_config_vars()['MACOSX_DEPLOYMENT_TARGET'] = '10.4'
        get_config_vars()['CFLAGS'] = ('-arch ppc -arch i386 -isysroot '
                                       '/Developer/SDKs/MacOSX10.4u.sdk  '
                                       '-fno-strict-aliasing -fno-common '
                                       '-dynamic -DNDEBUG -g -O3')

        self.assertEqual(get_platform(), 'macosx-10.4-fat')

        get_config_vars()['CFLAGS'] = ('-arch x86_64 -arch i386 -isysroot '
                                       '/Developer/SDKs/MacOSX10.4u.sdk  '
                                       '-fno-strict-aliasing -fno-common '
                                       '-dynamic -DNDEBUG -g -O3')

        self.assertEqual(get_platform(), 'macosx-10.4-intel')

        get_config_vars()['CFLAGS'] = ('-arch x86_64 -arch ppc -arch i386 -isysroot '
                                       '/Developer/SDKs/MacOSX10.4u.sdk  '
                                       '-fno-strict-aliasing -fno-common '
                                       '-dynamic -DNDEBUG -g -O3')
        self.assertEqual(get_platform(), 'macosx-10.4-fat3')

        get_config_vars()['CFLAGS'] = ('-arch ppc64 -arch x86_64 -arch ppc -arch i386 -isysroot '
                                       '/Developer/SDKs/MacOSX10.4u.sdk  '
                                       '-fno-strict-aliasing -fno-common '
                                       '-dynamic -DNDEBUG -g -O3')
        self.assertEqual(get_platform(), 'macosx-10.4-universal')

        get_config_vars()['CFLAGS'] = ('-arch x86_64 -arch ppc64 -isysroot '
                                       '/Developer/SDKs/MacOSX10.4u.sdk  '
                                       '-fno-strict-aliasing -fno-common '
                                       '-dynamic -DNDEBUG -g -O3')

        self.assertEqual(get_platform(), 'macosx-10.4-fat64')

        for arch in ('ppc', 'i386', 'x86_64', 'ppc64'):
            get_config_vars()['CFLAGS'] = ('-arch %s -isysroot '
                                           '/Developer/SDKs/MacOSX10.4u.sdk  '
                                           '-fno-strict-aliasing -fno-common '
                                           '-dynamic -DNDEBUG -g -O3' % arch)

            self.assertEqual(get_platform(), 'macosx-10.4-%s' % arch)

        # linux debian sarge
        os.name = 'posix'
        sys.version = ('2.3.5 (#1, Jul  4 2007, 17:28:59) '
                       '\n[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)]')
        sys.platform = 'linux2'
        self._set_uname(('Linux', 'aglae', '2.6.21.1dedibox-r7',
                    '#1 Mon Apr 30 17:25:38 CEST 2007', 'i686'))

        self.assertEqual(get_platform(), 'linux-i686')