Skip to content

Commit 31201aa

Browse files
earonestytrigger67
andauthored
merge in coincurve hook fix (OpenAgentsInc#20)
Co-authored-by: earonesty <[email protected]> Co-authored-by: Trigger <[email protected]>
1 parent 08be919 commit 31201aa

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

hooks/hook-coincurve.py

+15-16
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
11
from PyInstaller.utils.hooks import collect_data_files, get_package_paths
22
import os
3+
import re
34

4-
hiddenimports=['_cffi_backend']
5+
hiddenimports = ['_cffi_backend']
56

67
# Get the package path
78
package_path = get_package_paths('coincurve')[0]
89

910
# Collect data files
1011
datas = collect_data_files('coincurve')
1112

12-
# Append the additional .dll or .so file
13-
if os.name == 'nt': # Windows
14-
dll_path = os.path.join(package_path, 'coincurve', 'libsecp256k1.dll')
15-
datas.append((dll_path, 'coincurve'))
16-
elif os.name == 'posix': # Linux/Mac
17-
so_paths =[
18-
os.path.join(package_path, 'coincurve', 'libsecp256k1.so'),
19-
os.path.join(package_path, 'coincurve', '_libsecp256k1.cpython-311-x86_64-linux-gnu.so')
20-
]
21-
so_path = None
22-
for p in so_paths:
23-
if os.path.exists(p):
24-
so_path = p
25-
assert so_path, f"can't find coincurve lib, look in {package_path} and then modify this hook"
26-
datas.append((so_path, 'coincurve'))
13+
# Regular expression pattern for libsecp256k1
14+
libsecp256k1_pattern = re.compile(r'(libsecp256k1|_libsecp256k1).*\.(dll|so)')
2715

16+
# Search for libsecp256k1 file within the 'coincurve' folder
17+
coincurve_path = os.path.join(package_path, 'coincurve')
18+
libsecp256k1_path = None
19+
for root, _, files in os.walk(coincurve_path):
20+
for file in files:
21+
if libsecp256k1_pattern.search(file):
22+
libsecp256k1_path = os.path.join(root, file)
23+
datas.append((libsecp256k1_path, 'coincurve'))
24+
break
25+
26+
assert libsecp256k1_path, f"can't find coincurve libsecp256k1, look in {coincurve_path} and then modify this hook"

0 commit comments

Comments
 (0)