Skip to content

Commit

Permalink
improve platform detection for sling dependency
Browse files Browse the repository at this point in the history
- Replaced conditional logic with platform-specific dependency declarations using PEP 508 markers.
- This simplifies the setup.py script and makes it more robust.
- Improved readability and maintainability of the dependency management.
  • Loading branch information
flarco committed Feb 3, 2025
1 parent 76da57c commit 0fde30e
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions sling/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,14 @@
with readme_path.open() as file:
README = file.read()

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.')
install_requires = [
f'sling-linux-arm64=={SLING_VERSION} ; sys_platform=="linux" and platform_machine=="aarch64"',
f'sling-linux-amd64=={SLING_VERSION} ; sys_platform=="linux" and platform_machine!="aarch64"',
f'sling-windows-arm64=={SLING_VERSION} ; sys_platform=="win32" and platform_machine=="ARM64"',
f'sling-windows-amd64=={SLING_VERSION} ; sys_platform=="win32" and platform_machine!="ARM64"',
f'sling-mac-arm64=={SLING_VERSION} ; sys_platform=="darwin" and platform_machine=="arm64"',
f'sling-mac-amd64=={SLING_VERSION} ; sys_platform=="darwin" and platform_machine!="arm64"',
]

setup(
name='sling',
Expand Down

0 comments on commit 0fde30e

Please sign in to comment.