Skip to content

Commit

Permalink
Update cffi library with new versions #22
Browse files Browse the repository at this point in the history
Fixes the error in which residual files from previous hrequests version cause errors in v0.8.0
  • Loading branch information
daijro committed Oct 15, 2023
1 parent b1af435 commit 4953bab
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion hrequests/cffi.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from httpx import get, stream
from orjson import loads


root_dir = os.path.abspath(os.path.dirname(__file__))

# map machine architecture to hrequests-cgo binary name
Expand All @@ -30,6 +31,9 @@


class LibraryManager:
# specify specific version of hrequests-cgo library
BRIDGE_VERSION = '1.'

def __init__(self):
self.parent_path = os.path.join(root_dir, 'bin')
self.file_cont, self.file_ext = self.get_name()
Expand All @@ -50,8 +54,12 @@ def get_name() -> Tuple[str, str]:

def check_library(self):
for file in os.listdir(self.parent_path):
if file.endswith(self.file_ext):
if not file.endswith(self.file_ext):
continue
if file.startswith(f'hrequests-cgo-{self.BRIDGE_VERSION}'):
return file
# delete residual files from previous versions
os.remove(os.path.join(self.parent_path, file))
self.download_library()
return self.check_library()

Expand Down

0 comments on commit 4953bab

Please sign in to comment.