Skip to content

Commit

Permalink
(fea) selectable download using pkg-config
Browse files Browse the repository at this point in the history
  • Loading branch information
MementoRC committed Dec 20, 2023
1 parent e56a4d6 commit 90f33ab
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
12 changes: 8 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,25 @@ def download_library(command):
class egg_info(_egg_info):
def run(self):
# Ensure library has been downloaded (sdist might have been skipped)
download_library(self)
if not has_system_lib():
download_library(self)

_egg_info.run(self)


class sdist(_sdist):
def run(self):
download_library(self)
if not has_system_lib():
download_library(self)
_sdist.run(self)


if _bdist_wheel:

class bdist_wheel(_bdist_wheel):
def run(self):
download_library(self)
if not has_system_lib():
download_library(self)
_bdist_wheel.run(self)


Expand All @@ -113,7 +116,8 @@ def finalize_options(self):

def get_source_files(self):
# Ensure library has been downloaded (sdist might have been skipped)
download_library(self)
if not has_system_lib():
download_library(self)

return [
absolute(os.path.join(root, filename))
Expand Down
4 changes: 3 additions & 1 deletion setup_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ def _find_lib():
ffi = FFI()
try:
ffi.dlopen('secp256k1')
return os.path.exists('/usr/include/secp256k1_ecdh.h')
include_path = subprocess.check_output(['pkg-config', '--static', '--cflags-only-I', 'libsecp256k1']) # noqa S603
include_path = include_path.decode('UTF-8').strip().split()[0][2:]
return os.path.exists(f'{include_path}/secp256k1_ecdh.h')
except OSError:
if 'LIB_DIR' in os.environ:
for path in glob.glob(os.path.join(os.environ['LIB_DIR'], '*secp256k1*')):
Expand Down

0 comments on commit 90f33ab

Please sign in to comment.