From 76da57ce2ce1d24372b7fe66817fffdd6338a800 Mon Sep 17 00:00:00 2001 From: Fritz Larco Date: Sun, 2 Feb 2025 22:08:50 -0300 Subject: [PATCH] Improve platform detection for sling dependencies - Replaced conditional dependency specification with more readable and maintainable code. - Added error handling for unsupported platforms. - Improved code clarity and readability. --- sling/setup.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/sling/setup.py b/sling/setup.py index eb209df..042ef14 100755 --- a/sling/setup.py +++ b/sling/setup.py @@ -16,14 +16,24 @@ with readme_path.open() as file: README = file.read() -install_requires = [ - f'sling-linux-arm64=={SLING_VERSION} ; platform_system=="Linux" and platform_machine=="aarch64"', - f'sling-linux-amd64=={SLING_VERSION} ; platform_system=="Linux" and platform_machine=="aarch64"', - f'sling-windows-arm64=={SLING_VERSION} ; platform_system=="Windows" and platform_machine=="ARM64"', - f'sling-windows-amd64=={SLING_VERSION} ; platform_system=="Windows" and platform_machine!="ARM64"', - f'sling-mac-arm64=={SLING_VERSION} ; platform_system=="Darwin" and platform_machine=="arm64"', - f'sling-mac-amd64=={SLING_VERSION} ; platform_system=="Darwin" and platform_machine!="arm64"', -] +install_requires = [] +if platform.system() == 'Linux': + if platform.machine() == 'aarch64': + install_requires = [f'sling-linux-arm64=={SLING_VERSION}'] + else: + install_requires = [f'sling-linux-amd64=={SLING_VERSION}'] +elif platform.system() == 'Windows': + if platform.machine() == 'ARM64': + install_requires = [f'sling-windows-arm64=={SLING_VERSION}'] + else: + install_requires = [f'sling-windows-amd64=={SLING_VERSION}'] +elif platform.system() == 'Darwin': + if platform.machine() == 'arm64': + install_requires = [f'sling-mac-arm64=={SLING_VERSION}'] + else: + install_requires = [f'sling-mac-amd64=={SLING_VERSION}'] +else: + raise Exception(f'platform "{platform.system()}" ({platform.system()}) not supported.') setup( name='sling',