From 2010cba9cc048892f827893659d56d3af24f214d Mon Sep 17 00:00:00 2001 From: nir0s Date: Thu, 22 Oct 2015 18:24:21 +0300 Subject: [PATCH] fix platform --- wagon/tests/test_wagon.py | 8 ++++---- wagon/utils.py | 16 ++++------------ wagon/wagon.py | 2 +- 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/wagon/tests/test_wagon.py b/wagon/tests/test_wagon.py index d5b77a3..4777f00 100644 --- a/wagon/tests/test_wagon.py +++ b/wagon/tests/test_wagon.py @@ -130,9 +130,9 @@ def test_wheel_nonexisting_package(self): def test_machine_platform(self): if utils.IS_WIN: - self.assertIn('win', utils.get_machine_platform().lower()) + self.assertIn('win32', utils.get_platform()) else: - self.assertEqual(utils.get_machine_platform(), 'linux_x86_64') + self.assertEqual(utils.get_platform(), 'linux_x86_64') class TestCreateBadSources(testtools.TestCase): @@ -171,7 +171,7 @@ def tearDown(self): shutil.rmtree(TEST_PACKAGE_NAME) def _test(self): - # self.assertTrue(os.path.isfile(self.archive_name)) + self.assertTrue(os.path.isfile(self.archive_name)) utils.untar(self.archive_name, '.') with open(os.path.join( TEST_PACKAGE_NAME, @@ -245,7 +245,7 @@ def test_create_archive_from_url_with_requirements(self): if utils.IS_WIN: self.wagon.platform = 'win32' else: - self.wagon.platform = utils.get_machine_platform() + self.wagon.platform = utils.get_platform() self.archive_name = self.wagon.set_archive_name( TEST_PACKAGE_NAME, TEST_PACKAGE_VERSION) params = { diff --git a/wagon/utils.py b/wagon/utils.py index 725c306..c7111bc 100644 --- a/wagon/utils.py +++ b/wagon/utils.py @@ -10,6 +10,8 @@ from contextlib import closing import platform +from wheel import pep425tags as wheel_tags + import codes import logger @@ -223,18 +225,8 @@ def get_python_version(): return 'py{0}{1}'.format(version[0], version[1]) -def get_machine_platform(): - system = platform.system().lower() - machine = platform.machine().lower() - id = 'unidentified' - if system and machine: - id = '{0}_{1}'.format(system, machine) - elif system: - id = system - elif machine: - id = machine - lgr.info('Identified machine platform: {0}'.format(id)) - return id +def get_platform(): + return wheel_tags.get_platform() def get_os_properties(): diff --git a/wagon/wagon.py b/wagon/wagon.py index 85adcde..8138c1e 100644 --- a/wagon/wagon.py +++ b/wagon/wagon.py @@ -141,7 +141,7 @@ def install(self, virtualenv=None, requirements_file=None, upgrade=False, if not ignore_platform and supported_platform != 'any': lgr.debug('Validating Platform {0} is supported...'.format( supported_platform)) - machine_platform = utils.get_machine_platform() + machine_platform = utils.get_platform() if machine_platform != supported_platform: lgr.error('Platform unsupported for package ({0}).'.format( machine_platform))