Skip to content

Commit

Permalink
fix asset names for ubuntu distro
Browse files Browse the repository at this point in the history
  • Loading branch information
rawandahmad698 committed Jan 10, 2024
1 parent c6d8a9c commit a37c27c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
4 changes: 2 additions & 2 deletions noble_tls/__version__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__title__ = "Noble TLS"
__title__ = "noble_tls"
__description__ = "Advanced TLS/SSL wrapper for Python"
__version__ = "0.0.95"
__version__ = "0.0.96"
__author__ = "Rawand Ahmed Shaswar"
__license__ = "MIT"
8 changes: 8 additions & 0 deletions noble_tls/tests/test_asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ def test_generate_asset_name_linux_amd64(mocker):
expected_asset_name = 'tls-client-linux-amd64-v1.7.2.so'
assert generate_asset_name() == expected_asset_name

def test_generate_asset_name_ubuntu_arm64(mocker):
mocker.patch('noble_tls.utils.asset.get_system_platform', return_value='ubuntu')
mocker.patch('noble_tls.utils.asset.get_distro', return_value='ubuntu')
mocker.patch('platform.machine', return_value='x86_64')
mocker.patch('platform.system', return_value='Linux')
expected_asset_name = "tls-client-linux-ubuntu-amd64-v1.7.2.so"
assert generate_asset_name() == expected_asset_name

def test_generate_asset_name_windows_x86(mocker):
mocker.patch('noble_tls.utils.asset.get_system_platform', return_value='win32')
mocker.patch('platform.system', return_value='Windows')
Expand Down
9 changes: 9 additions & 0 deletions noble_tls/utils/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import platform
import sys
import distro

def root_dir():
# Get the absolute path of the current file
Expand All @@ -17,6 +18,8 @@ def root_dir():
def get_system_platform():
return sys.platform

def get_distro():
return distro.id()

def generate_asset_name(
custom_part: str = 'tls-client',
Expand All @@ -41,6 +44,7 @@ def generate_asset_name(
elif sys_platform in ('win32', 'cygwin'):
file_extension = '.dll'
asset_arch = '64' if 8 == ctypes.sizeof(ctypes.c_voidp) else '32'

else:
# I don't possess a Linux machine to test this on, so I'm not sure if this is correct
file_extension = '.so'
Expand All @@ -52,6 +56,11 @@ def generate_asset_name(
else:
asset_arch = 'amd64'

if system_os == 'linux':
distro_name = get_distro()
if distro_name.lower() == "ubuntu":
system_os = f"{system_os}-{distro_name}"

return f"{custom_part}-{system_os}-{asset_arch}-v{version}{file_extension}"


Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pytest
httpx
httpx
distro

0 comments on commit a37c27c

Please sign in to comment.