Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create hook-coincurve #659

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/658.new.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add a hook for ``coincurve`` to collect data, binaries and hidden imports.
38 changes: 38 additions & 0 deletions src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-coincurve
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# ------------------------------------------------------------------
# Copyright (c) 2020 PyInstaller Development Team.
#
# This file is distributed under the terms of the GNU General Public
# License (version 2.0 or later).
#
# The full license is available in LICENSE.GPL.txt, distributed with
# this software.
#
# SPDX-License-Identifier: GPL-2.0-or-later
# ------------------------------------------------------------------

from PyInstaller.utils.hooks import collect_data_files, get_package_paths
import os
import re

hiddenimports = ['_cffi_backend']

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

# Collect data files
datas = collect_data_files('coincurve')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What data files are there to collect?


# Regular expression pattern for libsecp256k1
libsecp256k1_pattern = re.compile(r'(libsecp256k1|_libsecp256k1).*\.(dll|so)')

# Search for libsecp256k1 file within the 'coincurve' folder
coincurve_path = os.path.join(package_path, 'coincurve')
libsecp256k1_path = None
for root, _, files in os.walk(coincurve_path):
for file in files:
if libsecp256k1_pattern.search(file):
libsecp256k1_path = os.path.join(root, file)
datas.append((libsecp256k1_path, 'coincurve'))
break

assert libsecp256k1_path, f"can't find coincurve libsecp256k1, look in {coincurve_path} and then modify this hook"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason this is not using binaries = collect_dynamic_libs('coincurve')? This should pick up the DLL on Windows.

On linux and macOS, _libsecp256k1 seems to be an extension and should be picked up automatically.